mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Switchbot "in memory" state for push mode switch (#58750)
* Add in memory state tracking to Switchbot switch. * Switchbot assumed state * Add in memory state when Bot is in push mode. * Cleanup
This commit is contained in:
parent
0ba45e4db4
commit
6749930736
@ -130,6 +130,8 @@ class SwitchBotBotEntity(SwitchbotEntity, SwitchEntity, RestoreEntity):
|
|||||||
self._last_run_success = bool(
|
self._last_run_success = bool(
|
||||||
await self.hass.async_add_executor_job(self._device.turn_on)
|
await self.hass.async_add_executor_job(self._device.turn_on)
|
||||||
)
|
)
|
||||||
|
if self._last_run_success:
|
||||||
|
self._attr_is_on = True
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn device off."""
|
"""Turn device off."""
|
||||||
@ -139,6 +141,8 @@ class SwitchBotBotEntity(SwitchbotEntity, SwitchEntity, RestoreEntity):
|
|||||||
self._last_run_success = bool(
|
self._last_run_success = bool(
|
||||||
await self.hass.async_add_executor_job(self._device.turn_off)
|
await self.hass.async_add_executor_job(self._device.turn_off)
|
||||||
)
|
)
|
||||||
|
if self._last_run_success:
|
||||||
|
self._attr_is_on = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assumed_state(self) -> bool:
|
def assumed_state(self) -> bool:
|
||||||
@ -150,6 +154,8 @@ class SwitchBotBotEntity(SwitchbotEntity, SwitchEntity, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
|
if not self.data["data"]["switchMode"]:
|
||||||
|
return self._attr_is_on
|
||||||
return self.data["data"]["isOn"]
|
return self.data["data"]["isOn"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user