Problem with 'UpdateDevice'

Moderator: leecollings

Post Reply
User avatar
Pupz
Posts: 9
Joined: Sunday 29 November 2015 22:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Problem with 'UpdateDevice'

Post by Pupz »

I am trying to update the status of a switch when the associated device (lamp) has been switched over by another actuator.
This is my script:

Code: Select all

-- control Lantern with LanternSwitch
if devicechanged['LanternSwitch'] == 'On' then commandArray['Lantern'] = 'On'
elseif devicechanged['LanternSwitch'] == 'Off' then commandArray['Lantern'] = 'Off'
end
-- update LanternSwitch status if Lantern has been switched over
if devicechanged['Lantern'] == 'On' then commandArray['UpdateDevice'] = tostring(otherdevices_idx['LanternSwitch']) .. '|1|On'
elseif devicechanged['Lantern'] == 'Off' then commandArray['UpdateDevice'] = tostring(otherdevices_idx['LanternSwitch']) .. '|0|Off'
end
The first part of the code works fine on its own, but adding the 'update' code introduces an infinite loop of firing commands, leaving switch and device deaf to any user intervention.

What am I doing wrong?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest