I think the biggest problem in your script is the "else"-part. You have basically told the script to run on each device change and execute one of the two parts of the script. The first part is executed only when the changed device is 'zonnescherm' and it changes to 'On' and the second part (= else) is then run in all other cases (= every time a device changes its state except if it is 'zonnescherm' turning 'On').
So, you need to think in which situation you want to run the second part:
Code: Select all
else
commandArray['auto zonnescherm omhoog']='Inactive'
print ('zonnescherm gaat niet vanzelf omhoog')
end
And come up with proper condition. That said, I don't quite understand how this script relates to "i use it to close my "zonnescherm" 30 minutes befor sunset" - I guess you are you triggering that with a normal device timer? Maybe something like this would work:
Code: Select all
commandArray = {}
if (devicechanged['zonnescherm'] == 'On' and otherdevices['auto omhoog zonnescherm ondergang'] == 'On' and otherdevices['telefoon 1'] == 'Off' and otherdevices['telefoon 2'] == 'Off') then
commandArray['auto zonnescherm omhoog']='Active'
print ('zonnescherm gaat vanzelf omhoog')
elseif devicechanged['zonnescherm'] == 'Off' then
commandArray['auto zonnescherm omhoog']='Inactive'
print ('zonnescherm gaat niet vanzelf omhoog')
end
return commandArray
...but you might need to define it even more strictly than this - depending when you want it to run
