@@ -705,7 +705,7 @@ async def set_relay(self, state: bool) -> bool:
705705
706706 if self ._relay_lock .state :
707707 _LOGGER .debug ("Relay switch blocked, relay is locked" )
708- return not state
708+ return self . _relay_state . state
709709
710710 _LOGGER .debug ("Switching relay to %s" , state )
711711 request = CircleRelaySwitchRequest (self ._send , self ._mac_in_bytes , state )
@@ -758,7 +758,7 @@ async def _relay_load_from_cache(self) -> bool:
758758 cached_relay_lock ,
759759 )
760760 relay_lock = cached_relay_lock == "True"
761- await self ._relay_update_lock (relay_lock )
761+ await self ._relay_update_lock (relay_lock , load_from_cache = True )
762762 else :
763763 # Set to initial state False when not present in cache
764764 await self ._relay_update_lock (False )
@@ -787,7 +787,7 @@ async def _relay_update_state(
787787 _LOGGER .debug ("Saving relay state update to cache for %s" , self ._mac_in_str )
788788 await self .save_cache ()
789789
790- async def _relay_update_lock (self , state : bool ) -> None :
790+ async def _relay_update_lock (self , state : bool , load_from_cache = False ) -> None :
791791 """Process relay lock update."""
792792 state_update = False
793793 if state :
@@ -804,8 +804,9 @@ async def _relay_update_lock(self, state: bool) -> None:
804804 await self .publish_feature_update_to_subscribers (
805805 NodeFeature .RELAY_LOCK , self ._relay_lock
806806 )
807- _LOGGER .debug ("Saving relay lock state update to cachefor %s" , self ._mac_in_str )
808- await self .save_cache ()
807+ if not load_from_cache :
808+ _LOGGER .debug ("Saving relay lock state update to cache for %s" , self ._mac_in_str )
809+ await self .save_cache ()
809810
810811 async def clock_synchronize (self ) -> bool :
811812 """Synchronize clock. Returns true if successful."""
0 commit comments