Use on_level when turning an Insteon dimmer on (#62321)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Mark Zachmann 2021-12-21 04:37:29 -05:00 committed by GitHub
parent 7fb79b363a
commit 64e3383b72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -75,7 +75,10 @@ class InsteonEntity(Entity):
@property
def extra_state_attributes(self):
"""Provide attributes for display on device card."""
return {"insteon_address": self.address, "insteon_group": self.group}
return {
"insteon_address": self.address,
"insteon_group": self.group,
}
@property
def device_info(self) -> DeviceInfo:
@ -148,6 +151,13 @@ class InsteonEntity(Entity):
"""Print the device ALDB to the log file."""
print_aldb_to_log(self._insteon_device.aldb)
def get_device_property(self, name: str):
"""Get a single Insteon device property value (raw)."""
value = None
if (prop := self._insteon_device.properties.get(name)) is not None:
value = prop.value if prop.new_value is None else prop.new_value
return value
def _get_label(self):
"""Get the device label for grouped devices."""
label = ""

View file

@ -1,5 +1,7 @@
"""Support for Insteon lights via PowerLinc Modem."""
from pyinsteon.extended_property import ON_LEVEL
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
DOMAIN as LIGHT_DOMAIN,
@ -53,6 +55,9 @@ class InsteonDimmerEntity(InsteonEntity, LightEntity):
"""Turn light on."""
if ATTR_BRIGHTNESS in kwargs:
brightness = int(kwargs[ATTR_BRIGHTNESS])
else:
brightness = self.get_device_property(ON_LEVEL)
if brightness is not None:
await self._insteon_device.async_on(
on_level=brightness, group=self._insteon_device_group.group
)