Page 1 of 1

How to monitor multiple sensors

Posted: Tuesday 24 January 2017 15:18
by Mikey
I just started to make an alarm system at home. I trigger the sensors like this:

Code: Select all

elseif (globalvariables['Security']) == 'Arm Home' or otherdevices['Dummy Armed Home'] == 'On' then

	if (otherdevices['Bewegungssensor_KE'] == 'On') then 
		commandArray['Sirene_KE'] = 'On FOR 2'
	elseif (devicechanged['Türsensor Büro'] == 'Open') then
	    commandArray['Sirene_KE'] = 'On FOR 2'
	end
My question is, if I have multiple motion and door sensors, how could I make this better. That means, can I make an Array of sensors and if any of these senors has motion, then the sirene goes on? Because if I have to do it with AND statements, the code gets really overloaded when there are multiple sensors.

I hope you understand what I mean.

Thanks for your reply.

Re: How to monitor multiple sensors

Posted: Tuesday 24 January 2017 15:40
by mlamie
There are countless possibilities in Domoticz. I'm using blocky which works flawless. The following wiki page can help you https://www.domoticz.com/wiki/Alarm_Setup

Re: How to monitor multiple sensors

Posted: Wednesday 25 January 2017 15:14
by Mikey
Thanks for your reply. I will check the explanation on wiki

Re: How to monitor multiple sensors

Posted: Wednesday 25 January 2017 15:31
by emme
I use the same prefix name for the same tipology of devices... then I evaluate their state change:

Code: Select all

[...]
local PIR       = 'PIR_'       -- Prefisso per devices Sensori Movimento
local MAG       = 'MAG_'       -- Prefisso per contatti magnetici
[...]

    for devName, devStatus in pairs(devicechanged) do 
        -- TUTTO INSERITO
        if (string.sub(devName,1,4) == PIR or string.sub(devName,1,4) == MAG) and uservariables['Alarm_Generic_Status'] == '0' and SECSTATUS == 'Armed Away' then
        [...]
        
of ourse the devices are named: MAG_Door, MAG_Window, PIR_Living, PIR_kitchen etc etc
ciao
M

Re: How to monitor multiple sensors

Posted: Wednesday 25 January 2017 15:51
by Mikey
Thanks a lot for your reply. But I have one more question:
What exactly is the uservarialbes 'Alarm_Generic_Status'? And how do you change the value of this status

Sorry, I'm pretty new in lua and domoticz.

Re: How to monitor multiple sensors

Posted: Wednesday 25 January 2017 16:17
by emme
as per wiki...
The script just check the devices state and trigger 2 variables: 1 used for alarm, the other for siren...

my logic in handling this define several scenarios by which I choose when to switch on the siren based on an alarm type...

ciao ;)
M

Re: How to monitor multiple sensors

Posted: Thursday 26 January 2017 6:38
by Mikey
Perfect, I will try that. Thanks a lot :D