mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Fix RFLink restore state (#20588)
* some minor tests refactor * unused import * async/await refactor * Correct tests failures * Restore state bug added call to super().async_added_to_hass() * Show brightness attribute if device supports it * Fix light/test_rflink Dimmable devices defaults to 255 brightness * delete super().device_state_attributes call
This commit is contained in:
parent
5f7f7777a0
commit
13421b326b
@ -185,6 +185,14 @@ class DimmableRflinkLight(SwitchableRflinkDevice, Light):
|
|||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the device state attributes."""
|
||||||
|
attr = {}
|
||||||
|
if self._brightness is not None:
|
||||||
|
attr[ATTR_BRIGHTNESS] = self._brightness
|
||||||
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
@ -239,6 +247,14 @@ class HybridRflinkLight(SwitchableRflinkDevice, Light):
|
|||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the device state attributes."""
|
||||||
|
attr = {}
|
||||||
|
if self._brightness is not None:
|
||||||
|
attr[ATTR_BRIGHTNESS] = self._brightness
|
||||||
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
|
@ -345,6 +345,7 @@ class RflinkDevice(Entity):
|
|||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Register update callback."""
|
"""Register update callback."""
|
||||||
|
await super().async_added_to_hass()
|
||||||
# Remove temporary bogus entity_id if added
|
# Remove temporary bogus entity_id if added
|
||||||
tmp_entity = TMP_ENTITY.format(self._device_id)
|
tmp_entity = TMP_ENTITY.format(self._device_id)
|
||||||
if tmp_entity in self.hass.data[DATA_ENTITY_LOOKUP][
|
if tmp_entity in self.hass.data[DATA_ENTITY_LOOKUP][
|
||||||
|
@ -632,7 +632,7 @@ async def test_restore_state(hass, monkeypatch):
|
|||||||
state = hass.states.get(DOMAIN + '.l4')
|
state = hass.states.get(DOMAIN + '.l4')
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert not state.attributes.get(ATTR_BRIGHTNESS)
|
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||||
assert state.attributes['assumed_state']
|
assert state.attributes['assumed_state']
|
||||||
|
|
||||||
# test coverage for dimmable light
|
# test coverage for dimmable light
|
||||||
|
Loading…
x
Reference in New Issue
Block a user