Skip to content

Commit

Permalink
Defer the first heartbeat by HEARTBEAT_INTERVAL seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurker00 committed Jul 18, 2024
1 parent a34e316 commit d2bf8ce
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions custom_components/localtuya/core/pytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,6 @@ def disconnected(self, exc=""):
class TuyaProtocol(asyncio.Protocol, ContextualLogger):
"""Implementation of the Tuya protocol."""

HEARTBEAT_SKIP = 5

def __init__(
self,
dev_id: str,
Expand Down Expand Up @@ -925,9 +923,8 @@ async def heartbeat_loop():
self.debug("Started heartbeat loop")
while True:
try:
# if self.last_command_sent > self.HEARTBEAT_SKIP:
await self.heartbeat()
await asyncio.sleep(HEARTBEAT_INTERVAL)
await self.heartbeat()
except asyncio.CancelledError:
self.debug("Stopped heartbeat loop")
raise
Expand Down

0 comments on commit d2bf8ce

Please sign in to comment.