Hy All,
I had a blocky script that checked a dusk sensor and a presence detector to turn on the scene.
Unfortunately the dusk sensor broke and I've bought an Fibaro Multi sensor.
So now I would like to make a script that checks the lux, is there is motion, and also the presence detector.
Something like this:
If lux is smaller than 50 lux and there is motion detected or presence dector is active than turn on scene.
I can make this in blocky, but every time the lux is updated the scene wil be triggered even if it is already on.
Can anybody help me to make a script that doesn't trigger every time?
Guido
Trigger scene with multiple conditions [Solved]
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Trigger scene with multiple conditions
Can you try this and reply with your findings?
Code: Select all
return
{
on =
{
devices =
{
'motion sensor', -- change to names of sensors
'presence sensor',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR if all OK
marker = 'scene trigger'
},
data =
{
onTime =
{
initial = 0 ,
},
},
execute = function(dz, item)
local lux = dz.devices('lux sensor').lux -- Change to name of sensor
local myScene = dz.scenes('my scene') -- Change to name of scene
local sceneTime = myScene.lastUpdate.dDate
dz.log(item.name .. ' state is: ' .. item.state .. ' (active = '.. tostring(item.active) .. ')',dz.LOG_DEBUG )
dz.log('sceneTime is: ' .. sceneTime .. '; onTime = ' .. dz.data.onTime ,dz.LOG_DEBUG )
if item.active and lux < 50 and sceneTime > dz.data.onTime then
myScene.switchOn()
dz.data.onTime = dz.time.dDate
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 13
- Joined: Monday 11 December 2017 20:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Trigger scene with multiple conditions
The only thing I see in the log is this.
Code: Select all
2020-05-04 15:50:29.319 (Zwave+) Lux (Woonkamer Lux)
2020-05-04 15:50:29.402 Status: dzVents: Debug: Dumping domoticz data to /home/pi/domoticz/scripts/dzVents/domoticzData.lua
2020-05-04 15:50:29.447 Status: dzVents: Debug: Processing device-adapter for Woonkamer Lux: Lux device adapter
2020-05-04 15:50:29.447 Status: dzVents: Debug: dzVents version: 3.0.2
2020-05-04 15:50:29.447 Status: dzVents: Debug: Event triggers:
2020-05-04 15:50:29.447 Status: dzVents: Debug: - Device: Woonkamer Lux
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Trigger scene with multiple conditions
Probably because the script does not trigger on Lux but only on motion and presence sensor.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 13
- Joined: Monday 11 December 2017 20:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Trigger scene with multiple conditions
Yes you're right.
changed it tot the lux sensor and I got this
changed it tot the lux sensor and I got this
Code: Select all
2020-05-04 16:00:01.096 Status: dzVents: Debug: - Device: Woonkamer Lux
2020-05-04 16:00:01.155 Status: dzVents: Info: Handling events for: "Woonkamer Lux", value: "1584"
2020-05-04 16:00:01.155 Status: dzVents: Info: scene trigger: ------ Start internal script: Script #2: Device: "Woonkamer Lux (Zwave+)", Index: 118
2020-05-04 16:00:01.157 Status: dzVents: Debug: scene trigger: Processing device-adapter for Thuis: Scene device adapter
2020-05-04 16:00:01.157 Status: dzVents: Debug: scene trigger: Woonkamer Lux state is: 1584 (active = false)
2020-05-04 16:00:01.157 Status: dzVents: Debug: scene trigger: sceneTime is: 1588599092; onTime = 0
2020-05-04 16:00:01.158 Status: dzVents: Info: scene trigger: ------ Finished Script #2
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Trigger scene with multiple conditions
Maybe I misunderstood but I thought your requirement was that it would not trigger on lux changes but only on on motion / presence and that the action was depending on Lux value.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 13
- Joined: Monday 11 December 2017 20:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Trigger scene with multiple conditions
Yes that is correct. I changed the wrong device. I wil change the presence state an check again.
-
- Posts: 13
- Joined: Monday 11 December 2017 20:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Trigger scene with multiple conditions [Solved]
It works! Thank you!
Code: Select all
2020-05-04 16:26:50.071 Status: dzVents: Info: Handling events for: "Guido", value: "Off"
2020-05-04 16:26:50.071 Status: dzVents: Info: scene trigger: ------ Start internal script: Script #2: Device: "Guido (Presence detection)", Index: 78
2020-05-04 16:26:50.073 Status: dzVents: Debug: scene trigger: Processing device-adapter for Woonkamer Lux: Lux device adapter
2020-05-04 16:26:50.073 Status: dzVents: Debug: scene trigger: Processing device-adapter for Thuis: Scene device adapter
2020-05-04 16:26:50.073 Status: dzVents: Debug: scene trigger: Guido state is: Off (active = false)
2020-05-04 16:26:50.073 Status: dzVents: Debug: scene trigger: sceneTime is: 1588599092; onTime = 0
2020-05-04 16:26:50.074 Status: dzVents: Info: scene trigger: ------ Finished Script #2
Who is online
Users browsing this forum: No registered users and 0 guests