Only one sensor activate the script

Moderator: leecollings

Post Reply
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Only one sensor activate the script

Post by marigo »

I have a script with two motion sensors to turn on the lights. But only one motion sensor (MotionSensor) will actually triggers the script. The "MotionSensor voor" does nothing in this script.

Maybe someone can explain?

Code: Select all

lux = tonumber(otherdevices_svalues['Lichtsensor voor'])
date = os.date("*t")

commandArray = {}

if ((date.hour >= 7 and date.hour <= 23) and
        (devicechanged['MotionSensor'] == 'On' or
        devicechanged['MotionSensor voor'] == 'On')) and
        (otherdevices['Control-Lights'] == 'Off' and
        lux <= 5) then
        commandArray['Group:Schakel-alle-lampen'] = 'On'

elseif (lux >= 14 and
        otherdevices['Control-Lights'] == 'On' and
        date.hour >= 7 and date.hour <= 23) then
        commandArray['Group:Schakel-alle-lampen'] = 'Off'

end
return commandArray
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: Only one sensor activate the script

Post by emme »

name labels are case sensitive....
Are you sure they're written correctly?

and more...
Devicechanged trigger the script after ANY device changes its state... could ibe that during the test you trigger first the MotionSensor and then the MotionSensor voor?
in this case the script will trigger twice :P
The most dangerous phrase in any language is:
"We always done this way"
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Only one sensor activate the script

Post by marigo »

The name labels are correct.

I have changed the first statement

Code: Select all

if ((date.hour >= 7 and date.hour <= 23) and
        (devicechanged['MotionSensor'] == 'On' or
        devicechanged['MotionSensor voor'] == 'On'))
into

Code: Select all

if (date.hour >= 7 and date.hour <= 23) and
        (devicechanged['MotionSensor'] == 'On' or
        devicechanged['MotionSensor voor'] == 'On')
And it look likes it's working now. I can trigger one of the sensors and lights will go on.
Now there are two separate statements instead of one.

Still can't explain, it should work also with one statement.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest