How to monitor multiple sensors

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Mikey
Posts: 31
Joined: Friday 13 January 2017 7:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to monitor multiple sensors

Post 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.
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: How to monitor multiple sensors

Post 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
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
Mikey
Posts: 31
Joined: Friday 13 January 2017 7:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to monitor multiple sensors

Post by Mikey »

Thanks for your reply. I will check the explanation on wiki
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How to monitor multiple sensors

Post 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
The most dangerous phrase in any language is:
"We always done this way"
Mikey
Posts: 31
Joined: Friday 13 January 2017 7:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to monitor multiple sensors

Post 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.
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How to monitor multiple sensors

Post 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
The most dangerous phrase in any language is:
"We always done this way"
Mikey
Posts: 31
Joined: Friday 13 January 2017 7:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to monitor multiple sensors

Post by Mikey »

Perfect, I will try that. Thanks a lot :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest