dannybloe wrote: Thursday 22 February 2018 12:43
Check the docs: devices = { 'SensorMasterBedroom' = { 'at nighttime' } }
It is working but not the way how i expected. When sensor turn on it wait for when the time change 1 minute then it turn on the lights.
When sensor goes of it wait again to turn off the lights
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave,Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
I can say that, given the current state of how everything works, this is technically impossible. When the device gets an update it immediately triggers the event system and dzVents will check if the current time is matching the 'at nighttime' rule. If that's the case then the event script is called immediately. There is no code in dzVents that can put the event on hold until the start of the minute. As a matter of fact, I just tested it. So.. having said that I can only conclude that the event is only raised every minute. Perhaps your sensor only reports to Domoticz every minute or your trigger rules in your script are not correct.
Btw, the rule above should be like (with the square brackets) but your probably already knew that:
local Version = '18.02.22'
local SensorMasterBedroom = 529
local MasterBedroom = 7
local SwitchGoodnight = 65
return {
active = true,
on = {
devices = {[SensorMasterBedroom] = { 'at nighttime' }},
},
logging = {marker = 'SLAAPKAMER Sensor ' ..Version..'......'},
execute = function(domoticz, device)
if
domoticz.devices(SensorMasterBedroom).active and
domoticz.devices(SwitchGoodnight).state == 'Off'
then
domoticz.devices(MasterBedroom).dimTo(100)
domoticz.devices(MasterBedroom).dimTo(100)
domoticz.devices(MasterBedroom).setKelvin(5000)
elseif
domoticz.devices(SensorMasterBedroom).toggleSwitch() and
domoticz.devices(MasterBedroom).active and
domoticz.devices(SwitchGoodnight).state == 'Off'
then
domoticz.devices(MasterBedroom).dimTo(1)
domoticz.devices(MasterBedroom).switchOff().afterSec(1)
end
end
}
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave,Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
local Version = '18.02.22'
local SensorMasterBedroom = 529
local MasterBedroom = 7
local SwitchGoodnight = 65
return {
on = {
devices = {[SensorMasterBedroom] = { 'at nighttime' }},
},
logging = {marker = 'SLAAPKAMER Sensor ' ..Version..'......'},
execute = function(domoticz, sensor)
local goodnightSwitch = domoticz.devices(SwitchGoodnight)
local light = domoticz.devices(MasterBedroom)
if (sensor.active and not goodnightSwitch.active) then
light.dimTo(100)
light.setKelvin(5000)
elseif (light.active and not goodnightSwitch.active) then
light.dimTo(1)
light.switchOff().afterSec(1)
end
end
}
You had a 'domoticz.devices(SensorMasterBedroom).toggleSwitch()' in your elseif statement and that is not correct as the function toggleSwitch() doesn't return anything (nil basically so your elseif will always fail).
Untested of course
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
local Version = '18.02.22'
local SensorMasterBedroom = 529
local MasterBedroom = 7
local SwitchGoodnight = 65
return {
on = {
devices = {[SensorMasterBedroom] = { 'at nighttime' }},
},
logging = {marker = 'SLAAPKAMER Sensor ' ..Version..'......'},
execute = function(domoticz, sensor)
local goodnightSwitch = domoticz.devices(SwitchGoodnight)
local light = domoticz.devices(MasterBedroom)
if (sensor.active and not goodnightSwitch.active) then
light.dimTo(100)
light.setKelvin(5000)
elseif (light.active and not goodnightSwitch.active) then
light.dimTo(1)
light.switchOff().afterSec(1)
end
end
}
You had a 'domoticz.devices(SensorMasterBedroom).toggleSwitch()' in your elseif statement and that is not correct as the function toggleSwitch() doesn't return anything (nil basically so your elseif will always fail).
Untested of course
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave,Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php