mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix dimming for ISY994 Z-Wave devices using percent instead of 8-bit brightness values (#42915)
This commit is contained in:
parent
bf9f3e1997
commit
121872c546
@ -193,6 +193,7 @@ UOM_HVAC_MODE_INSTEON = "98"
|
||||
UOM_FAN_MODES = "99"
|
||||
UOM_INDEX = "25"
|
||||
UOM_ON_OFF = "2"
|
||||
UOM_PERCENTAGE = "51"
|
||||
|
||||
# Do not use the Home Assistant consts for the states here - we're matching exact API
|
||||
# responses, not using them for Home Assistant states
|
||||
@ -369,7 +370,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"48": SPEED_MILES_PER_HOUR,
|
||||
"49": SPEED_METERS_PER_SECOND,
|
||||
"50": "Ω",
|
||||
"51": PERCENTAGE,
|
||||
UOM_PERCENTAGE: PERCENTAGE,
|
||||
"52": MASS_POUNDS,
|
||||
"53": "pf",
|
||||
"54": CONCENTRATION_PARTS_PER_MILLION,
|
||||
|
@ -53,7 +53,7 @@ class ISYCoverEntity(ISYNodeEntity, CoverEntity):
|
||||
if self._node.status == ISY_VALUE_UNKNOWN:
|
||||
return None
|
||||
if self._node.uom == UOM_8_BIT_RANGE:
|
||||
return int(self._node.status * 100 / 255)
|
||||
return round(self._node.status * 100.0 / 255.0)
|
||||
return sorted((0, self._node.status, 100))[1]
|
||||
|
||||
@property
|
||||
@ -83,7 +83,7 @@ class ISYCoverEntity(ISYNodeEntity, CoverEntity):
|
||||
"""Move the cover to a specific position."""
|
||||
position = kwargs[ATTR_POSITION]
|
||||
if self._node.uom == UOM_8_BIT_RANGE:
|
||||
position = int(position * 255 / 100)
|
||||
position = round(position * 255.0 / 100.0)
|
||||
if not self._node.turn_on(val=position):
|
||||
_LOGGER.error("Unable to set cover position")
|
||||
|
||||
|
@ -17,6 +17,7 @@ from .const import (
|
||||
CONF_RESTORE_LIGHT_STATE,
|
||||
DOMAIN as ISY994_DOMAIN,
|
||||
ISY994_NODES,
|
||||
UOM_PERCENTAGE,
|
||||
)
|
||||
from .entity import ISYNodeEntity
|
||||
from .helpers import migrate_old_unique_ids
|
||||
@ -65,6 +66,9 @@ class ISYLightEntity(ISYNodeEntity, LightEntity, RestoreEntity):
|
||||
"""Get the brightness of the ISY994 light."""
|
||||
if self._node.status == ISY_VALUE_UNKNOWN:
|
||||
return None
|
||||
# Special Case for ISY Z-Wave Devices using % instead of 0-255:
|
||||
if self._node.uom == UOM_PERCENTAGE:
|
||||
return round(self._node.status * 255.0 / 100.0)
|
||||
return int(self._node.status)
|
||||
|
||||
def turn_off(self, **kwargs) -> None:
|
||||
@ -76,6 +80,9 @@ class ISYLightEntity(ISYNodeEntity, LightEntity, RestoreEntity):
|
||||
def on_update(self, event: object) -> None:
|
||||
"""Save brightness in the update event from the ISY994 Node."""
|
||||
if self._node.status not in (0, ISY_VALUE_UNKNOWN):
|
||||
if self._node.uom == UOM_PERCENTAGE:
|
||||
self._last_brightness = round(self._node.status * 255.0 / 100.0)
|
||||
else:
|
||||
self._last_brightness = self._node.status
|
||||
super().on_update(event)
|
||||
|
||||
@ -84,6 +91,9 @@ class ISYLightEntity(ISYNodeEntity, LightEntity, RestoreEntity):
|
||||
"""Send the turn on command to the ISY994 light device."""
|
||||
if self._restore_light_state and brightness is None and self._last_brightness:
|
||||
brightness = self._last_brightness
|
||||
# Special Case for ISY Z-Wave Devices using % instead of 0-255:
|
||||
if brightness is not None and self._node.uom == UOM_PERCENTAGE:
|
||||
brightness = round(brightness * 100.0 / 255.0)
|
||||
if not self._node.turn_on(val=brightness):
|
||||
_LOGGER.debug("Unable to turn on light")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user