mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Revert velocity change in powerview (#114337)
This commit is contained in:
parent
bec45dacf0
commit
a07dc85bf4
@ -41,7 +41,7 @@ def store_velocity(
|
|||||||
value: float | None,
|
value: float | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Store the desired shade velocity in the coordinator."""
|
"""Store the desired shade velocity in the coordinator."""
|
||||||
coordinator.data.update_shade_position(shade_id, ShadePosition(velocity=value))
|
coordinator.data.update_shade_velocity(shade_id, ShadePosition(velocity=value))
|
||||||
|
|
||||||
|
|
||||||
NUMBERS: Final = (
|
NUMBERS: Final = (
|
||||||
|
@ -13,14 +13,11 @@ from .util import async_map_data_by_id
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
POSITION_FIELDS = fields(ShadePosition)
|
POSITION_FIELDS = [field for field in fields(ShadePosition) if field.name != "velocity"]
|
||||||
|
|
||||||
|
|
||||||
def copy_position_data(source: ShadePosition, target: ShadePosition) -> ShadePosition:
|
def copy_position_data(source: ShadePosition, target: ShadePosition) -> ShadePosition:
|
||||||
"""Copy position data from source to target for None values only."""
|
"""Copy position data from source to target for None values only."""
|
||||||
# the hub will always return a velocity of 0 on initial connect,
|
|
||||||
# separate definition to store consistent value in HA
|
|
||||||
# this value is purely driven from HA
|
|
||||||
for field in POSITION_FIELDS:
|
for field in POSITION_FIELDS:
|
||||||
if (value := getattr(source, field.name)) is not None:
|
if (value := getattr(source, field.name)) is not None:
|
||||||
setattr(target, field.name, value)
|
setattr(target, field.name, value)
|
||||||
@ -76,3 +73,11 @@ class PowerviewShadeData:
|
|||||||
def update_shade_position(self, shade_id: int, new_position: ShadePosition) -> None:
|
def update_shade_position(self, shade_id: int, new_position: ShadePosition) -> None:
|
||||||
"""Update a single shades position."""
|
"""Update a single shades position."""
|
||||||
copy_position_data(new_position, self.get_shade_position(shade_id))
|
copy_position_data(new_position, self.get_shade_position(shade_id))
|
||||||
|
|
||||||
|
def update_shade_velocity(self, shade_id: int, shade_data: ShadePosition) -> None:
|
||||||
|
"""Update a single shades velocity."""
|
||||||
|
# the hub will always return a velocity of 0 on initial connect,
|
||||||
|
# separate definition to store consistent value in HA
|
||||||
|
# this value is purely driven from HA
|
||||||
|
if shade_data.velocity is not None:
|
||||||
|
self.get_shade_position(shade_id).velocity = shade_data.velocity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user