Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when seting Device timedout make sure to read the correspoding unit #1750

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions Modules/domoticzAbstractLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,12 @@ def domo_read_TimedOut( self, Devices, DeviceId_ ):
if DOMOTICZ_EXTENDED_API and DeviceId_ in Devices:
return Devices[ DeviceId_].TimedOut

# Legacy
# Legacy, return the TimedOut flag of 1st unit
return next( ( 1 for x in Devices if Devices[x].DeviceID == DeviceId_ and Devices[x].TimedOut ), 0, )


def domo_read_legacy_TimedOut( self, Devices, DeviceId_, UnitId_ ):
return Devices[ UnitId_ ].TimedOut

def domo_read_LastUpdate(self, Devices, DeviceId_, Unit_):
self.log.logging("AbstractDz", "Debug", f"domo_read_LastUpdate: DeviceID: {DeviceId_} Unit {Unit_}")

Expand Down Expand Up @@ -699,27 +701,30 @@ def timeout_widget_api(self, Devices, DeviceId_, timeout_value):
for unit in list(Devices):
if Devices[ unit ].DeviceID == DeviceId_:
timeout_legacy_device_unit_api(self, Devices, DeviceId_, unit, timeout_value)


def timeout_legacy_device_unit_api(self, Devices, DeviceId_, Unit_, timeout_value):
""" TimedOut one Device widget """

self.log.logging("AbstractDz", "Debug", f"timeout_legacy_device_unit_api: {DeviceId_} {Unit_} {timeout_value}")
if _is_meter_widget( self, Devices, DeviceId_, Unit_):
return

_nValue, _sValue = domo_read_nValue_sValue(self, Devices, DeviceId_, Unit_)
_TimedOut = domo_read_TimedOut( self, Devices, DeviceId_, )

_TimedOut = domo_read_legacy_TimedOut( self, Devices, DeviceId_, Unit_ )
_Name = domo_read_Name( self, Devices, DeviceId_, Unit_, )

self.log.logging("Widget", "Debug", "timeout_legacy_device_unit_api unit %s -> %s from %s:%s %s" % (
Devices[Unit_].Name, bool(timeout_value), _nValue, _sValue, Devices[Unit_].TimedOut))

if _TimedOut != timeout_value:
# Update is required
if timeout_value == 1 and self.pluginconf.pluginConf["deviceOffWhenTimeOut"]:
_switch_off_widget_due_to_timedout(self, Devices, DeviceId_, Unit_, _nValue, _sValue,)
else:
domo_update_api(self, Devices, DeviceId_, Unit_, _nValue, _sValue, TimedOut=timeout_value)
_Name, bool(timeout_value), _nValue, _sValue, bool(_TimedOut)))

if _TimedOut == timeout_value:
return

# Update is required
if timeout_value == 1 and self.pluginconf.pluginConf["deviceOffWhenTimeOut"]:
_switch_off_widget_due_to_timedout(self, Devices, DeviceId_, Unit_, _nValue, _sValue,)
else:
domo_update_api(self, Devices, DeviceId_, Unit_, _nValue, _sValue, TimedOut=timeout_value)


def update_battery_api(self, Devices, DeviceId, battery_level):
Expand Down
Loading