11"""Library to handle connection with Switchbot."""
22from __future__ import annotations
33
4- from .device import REQ_HEADER , SwitchbotDevice
4+ from .device import REQ_HEADER , SwitchbotDeviceOverrideStateDuringConnection
55
66# Plug Mini keys
77PLUG_ON_KEY = f"{ REQ_HEADER } 50010180"
88PLUG_OFF_KEY = f"{ REQ_HEADER } 50010100"
99
1010
11- class SwitchbotPlugMini (SwitchbotDevice ):
11+ class SwitchbotPlugMini (SwitchbotDeviceOverrideStateDuringConnection ):
1212 """Representation of a Switchbot plug mini."""
1313
1414 async def update (self , interface : int | None = None ) -> None :
@@ -18,12 +18,18 @@ async def update(self, interface: int | None = None) -> None:
1818 async def turn_on (self ) -> bool :
1919 """Turn device on."""
2020 result = await self ._send_command (PLUG_ON_KEY )
21- return self ._check_command_result (result , 1 , {0x80 })
21+ ret = self ._check_command_result (result , 1 , {0x80 })
22+ self ._override_adv_data = {"isOn" : True }
23+ self ._fire_callbacks ()
24+ return ret
2225
2326 async def turn_off (self ) -> bool :
2427 """Turn device off."""
2528 result = await self ._send_command (PLUG_OFF_KEY )
26- return self ._check_command_result (result , 1 , {0x00 })
29+ ret = self ._check_command_result (result , 1 , {0x80 })
30+ self ._override_adv_data = {"isOn" : False }
31+ self ._fire_callbacks ()
32+ return ret
2733
2834 def is_on (self ) -> bool | None :
2935 """Return switch state from cache."""
0 commit comments