Skip to content

Commit

Permalink
Remove local power updates for SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 21, 2024
1 parent 846cc16 commit cefd14c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions custom_components/sonoff/core/ewelink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,9 @@ def update_device(self, device: XDevice):

# SPM-4Relay - four channels, separate update for each channel
elif uiid == 130:
if self.can_local(device):
asyncio.create_task(self.update_spm_pow(device, False))
# https://github.com/AlexxIT/SonoffLAN/issues/1366
if self.can_cloud(device):
asyncio.create_task(self.update_spm_pow(device, True))
asyncio.create_task(self.update_spm_pow(device))

# checks if device still available via LAN
if "local_ts" not in device or device["local_ts"] > time.time():
Expand All @@ -353,16 +352,12 @@ def update_device(self, device: XDevice):
if self.local.online:
asyncio.create_task(self.check_offline(device))

async def update_spm_pow(self, device: XDevice, cloud_mode: bool):
async def update_spm_pow(self, device: XDevice):
for i in range(4):
if i > 0:
await asyncio.sleep(5)
params = {"uiActive": {"outlet": i, "time": 60}}
if cloud_mode:
await self.cloud.send(device, params, timeout=0)
else:
params["subDevId"] = device["deviceid"]
await self.local.send(device["parent"], params, command="statistics")
await self.cloud.send(device, params, timeout=0)

def can_cloud(self, device: XDevice) -> bool:
if not self.cloud.online:
Expand Down

0 comments on commit cefd14c

Please sign in to comment.