Centralize bond update state logic (#38093)

* Refactor bond integration to centralize update state logic in single superclass

* Refactor bond integration to centralize update state logic in single superclass
This commit is contained in:
Eugene Prystupa authored and GitHub committed 2020-07-23 04:15:27 +02:00
1 parent 3480fb6996
commit a756d1e637
5 files changed
+31 -30

No files matched your search

+3 -5
View File
@@ -39,6 +39,9 @@ class BondSwitch(BondEntity, SwitchEntity):
self._power: Optional[bool] = None
def _apply_state(self, state: dict):
self._power = state.get("power")
@property
def is_on(self) -> bool:
"""Return True if power is on."""
@@ -51,8 +54,3 @@ class BondSwitch(BondEntity, SwitchEntity):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
await self._hub.bond.action(self._device.device_id, Action.turn_off())
async def async_update(self):
"""Fetch assumed state of the device from the hub using API."""
state: dict = await self._hub.bond.device_state(self._device.device_id)
self._power = state.get("power")