Reduce frequency of pings, disconnect on unload and stop pings when disconnected
This commit is contained in:
parent
b25acad570
commit
59c7dc8033
|
|
@ -435,7 +435,6 @@ def crc(data):
|
|||
|
||||
|
||||
class Message:
|
||||
|
||||
PING_COMMAND = 0x09
|
||||
GET_COMMAND = 0x0A
|
||||
SET_COMMAND = 0x07
|
||||
|
|
@ -708,6 +707,9 @@ class TuyaDevice:
|
|||
_call_async(self.async_set, dps)
|
||||
|
||||
async def _async_ping(self, ping_interval):
|
||||
if not self._connected:
|
||||
return
|
||||
|
||||
self.last_ping = time.time()
|
||||
maybe_self = None if self.version < (3, 3) else self
|
||||
message = Message(Message.PING_COMMAND, sequence=0, encrypt_for=maybe_self)
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class RoboVacEntity(StateVacuumEntity):
|
|||
host=self.ip_address,
|
||||
local_key=self.access_token,
|
||||
timeout=2,
|
||||
ping_interval=10,
|
||||
ping_interval=60,
|
||||
model_code=self.model_code[0:5],
|
||||
)
|
||||
|
||||
|
|
@ -398,3 +398,6 @@ class RoboVacEntity(StateVacuumEntity):
|
|||
await self.vacuum.async_set({"124": base64_str}, None)
|
||||
await asyncio.sleep(1)
|
||||
self.async_update
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
await self.vacuum.async_disconnect()
|
||||
|
|
|
|||
Loading…
Reference in New Issue