Code: Select all
return {
active = true,
-- active = false,
on = {
devices = { 'PIR Slaapkamer Sensor', 'PIR Slaapkamer Lux' }
-- devices = { ['PIR Slaapkamer Sensor'] = { 'at 10:00-22:00' } }
},
execute = function(dz, device)
local debug = true
-- local debug = false
local lux = dz.devices("PIR Slaapkamer Lux").lux
if debug then
print(device.name .. ' = ' .. device.state .. " - Lux = " .. lux)
end
if device.state == "On" then
if lux < 5 then
dz.devices("Bedlampen").cancelQueuedCommands()
dz.devices("Bedlampen").switchOn().checkFirst()
end
else
dz.devices("Bedlampen").cancelQueuedCommands()
dz.devices("Bedlampen").switchOff().checkFirst().afterMin(5)
end
end
}
Outside the trigger hours I switch on bedroom lights either by Google commands or a Zigbee wallswitch.
The device is a https://www.zigbee2mqtt.io/devices/RTCG ... -rtcgq11lm
Which only sends the lux value when the motion triggers the device.
The problem is that first the motion triggers the script and second the lux triggers the script.
My problem is solved when it always is first the lux value is updated, because the motion triggers uses at midday the 'old' lux value (below 5 lux) of hours before.
I know it is not a REAL problem, but still it bugs me.
The zigbee output is just 1 line with all the values. Below the ON and OFF
Code: Select all
info 2021-02-17 10:11:45: MQTT publish: topic 'zigbee2mqtt/SlaapkamerPIR', payload '{"battery":91,"illuminance":177,"illuminance_lux":177,"last_seen":"2021-02-17T10:11:45+01:00","linkquality":33,"occupancy":true,"temperature":30,"voltage":2985}'
info 2021-02-17 10:13:15: MQTT publish: topic 'zigbee2mqtt/SlaapkamerPIR', payload '{"battery":91,"illuminance":177,"illuminance_lux":177,"last_seen":"2021-02-17T10:11:45+01:00","linkquality":33,"occupancy":false,"temperature":30,"voltage":2985}'