Multiple actions on activation of script. Topic is solved

Moderator: leecollings

Post Reply
f14driver
Posts: 18
Joined: Sunday 24 June 2018 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Multiple actions on activation of script.

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Multiple actions on activation of script.

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
f14driver
Posts: 18
Joined: Sunday 24 June 2018 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple actions on activation of script.

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest