mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-19 16:59:36 +08:00
set timers to None after cancel
This commit is contained in:
parent
fb46bc6b19
commit
f614181755
@ -308,8 +308,10 @@ class _MIoTLanDevice:
|
|||||||
def on_delete(self) -> None:
|
def on_delete(self) -> None:
|
||||||
if self._ka_timer:
|
if self._ka_timer:
|
||||||
self._ka_timer.cancel()
|
self._ka_timer.cancel()
|
||||||
|
self._ka_timer = None
|
||||||
if self._online_offline_timer:
|
if self._online_offline_timer:
|
||||||
self._online_offline_timer.cancel()
|
self._online_offline_timer.cancel()
|
||||||
|
self._online_offline_timer = None
|
||||||
_LOGGER.debug('miot lan device delete, %s', self.did)
|
_LOGGER.debug('miot lan device delete, %s', self.did)
|
||||||
|
|
||||||
def update_info(self, info: dict) -> None:
|
def update_info(self, info: dict) -> None:
|
||||||
@ -404,6 +406,7 @@ class _MIoTLanDevice:
|
|||||||
self._online_offline_history.pop(0)
|
self._online_offline_history.pop(0)
|
||||||
if self._online_offline_timer:
|
if self._online_offline_timer:
|
||||||
self._online_offline_timer.cancel()
|
self._online_offline_timer.cancel()
|
||||||
|
self._online_offline_timer = None
|
||||||
if not online:
|
if not online:
|
||||||
self.online = False
|
self.online = False
|
||||||
else:
|
else:
|
||||||
@ -1133,6 +1136,7 @@ class MIoTLan:
|
|||||||
for req_data in self._pending_requests.values():
|
for req_data in self._pending_requests.values():
|
||||||
if req_data.timeout:
|
if req_data.timeout:
|
||||||
req_data.timeout.cancel()
|
req_data.timeout.cancel()
|
||||||
|
req_data.timeout = None
|
||||||
self._pending_requests.clear()
|
self._pending_requests.clear()
|
||||||
for timer in self._reply_msg_buffer.values():
|
for timer in self._reply_msg_buffer.values():
|
||||||
timer.cancel()
|
timer.cancel()
|
||||||
@ -1252,6 +1256,7 @@ class MIoTLan:
|
|||||||
if req:
|
if req:
|
||||||
if req.timeout:
|
if req.timeout:
|
||||||
req.timeout.cancel()
|
req.timeout.cancel()
|
||||||
|
req.timeout = None
|
||||||
if req.handler is not None:
|
if req.handler is not None:
|
||||||
self._main_loop.call_soon_threadsafe(
|
self._main_loop.call_soon_threadsafe(
|
||||||
req.handler, msg, req.handler_ctx)
|
req.handler, msg, req.handler_ctx)
|
||||||
@ -1326,6 +1331,7 @@ class MIoTLan:
|
|||||||
def __scan_devices(self) -> None:
|
def __scan_devices(self) -> None:
|
||||||
if self._scan_timer:
|
if self._scan_timer:
|
||||||
self._scan_timer.cancel()
|
self._scan_timer.cancel()
|
||||||
|
self._scan_timer = None
|
||||||
try:
|
try:
|
||||||
# Scan devices
|
# Scan devices
|
||||||
self.ping(if_name=None, target_ip='255.255.255.255')
|
self.ping(if_name=None, target_ip='255.255.255.255')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user