Page 1 of 1

Multiple actions on activation of script.

Posted: Tuesday 19 May 2020 10:01
by f14driver
Hello,

Maybe some one here can help me with a ( I hope) simple question but I can't seem to find the solution for it.

I have a presence script that is activating the alarm as soon as the mobile phone is out of wifi reach with my local network.

Code: Select all

commandArray = {}
 if (devicechanged['Phonename'] == 'Off')  then
    print('AlarmPanel Arm Away')
    commandArray['Domoticz Security Panel']='Arm Away'
  end
 if (devicechanged['Phonename'] == 'On')  then
    print('AlarmPanel Disarming')
    commandArray['Domoticz Security Panel']='Disarm'
end
return commandArray
I want to include two actions prior to activating the alarm, resetting the motion sensor group and the closing of all doors as soon as the script is triggered.
Both devices are grouped into groups so I can reset the devices all at once.
When I include the two groups into the script nothing happens so I guess the error is between the chair and the monitor ;)

Underneath the modification I made that does't work;

Code: Select all

commandArray = {}
 if (devicechanged['Phonename'] == 'Off')  then
    print('AlarmPanel Arm Away')
    commandArray['Bewgingsmelders uit']='Off'
    commandArray['Deuren dicht']='Off'
    commandArray['Domoticz Security Panel']='Arm Away'
  end
 if (devicechanged['Phonename'] == 'On')  then
    print('AlarmPanel Disarming')
    commandArray['Domoticz Security Panel']='Disarm'
end
return commandArray
Could some of you shed a light on the error I seem to be making in order to get these to group automaticly reset when I leave the house ?
Many tanks in advance.

Re: Multiple actions on activation of script.

Posted: Tuesday 19 May 2020 10:23
by waaren
f14driver wrote: Tuesday 19 May 2020 10:01 Maybe some one here can help me with a ( I hope) simple question but I can't seem to find the solution for it.
I want to include two actions prior to activating the alarm, resetting the motion sensor group and the closing of all doors as soon as the script is triggered.
Both devices are grouped into groups so I can reset the devices all at once.
You need to tell domoticz that the command is for a Group and not for a device

Code: Select all

commandArray = {}
if (devicechanged['Phonename'] == 'Off')  then
    print('AlarmPanel Arm Away')
    commandArray['Group:Bewegingsmelders uit'] = 'Off' -- was there also a typo in the name of the group?
    commandArray['Group:Deuren dicht'] = 'Off'
    commandArray['Domoticz Security Panel']='Arm Away'
elseif (devicechanged['Phonename'] == 'On')  then
    print('AlarmPanel Disarming')
    commandArray['Domoticz Security Panel'] = 'Disarm'
end

return commandArray

Re: Multiple actions on activation of script.

Posted: Tuesday 19 May 2020 10:34
by f14driver
Thanks Waaren,

That works like a charm.
I just couldn't find the error but you made it very simple to fix.

And yes there was a type in one line indeed.