Page 1 of 1
Use device status in Timers to switch device
Posted: Wednesday 06 June 2018 21:32
by pjotr
A made a lux meter and want to switch on a switch (light) or a group of devices. I can make a blocky script or al LUA script but i lose overview when using scripts. Is it a good suggestion when i could use a condition with value of a device in the Timers option to switch on or of a device when the value reached a given value ?
Now i can only select a condition related with time such as sunset etc.
Re: Use device status in Timers to switch device
Posted: Tuesday 19 June 2018 11:01
by rrozema
I like the idea but I think it would be hard to implement, given that there are so many different types of sensors, each having their own peculiarities.
What you want is not very hard to do though using a dzVents script. Here's an example:
Code: Select all
local LUX_LEVEL = 5
local LUX_DEVICE_NAME = 'Hal: Lux'
local SWITCH_DEVICE_NAME = 'Tuin: Buitenlamp'
return {
on = {
devices = {
LUX_DEVICE_NAME
}
},
data = {
Last = { initial = 0 }
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
local switch = domoticz.devices(SWITCH_DEVICE_NAME)
if device.Lux < LUX_LEVEL and not domoticz.data.Last < LUX_LEVEL then
switch.switchOn()
elseif device.Lux >= LUX_LEVEL and not domoticz.data.Last >= LUX_LEVEL then
switch.switchOff()
end
domoticz.data.Last = device.Lux
end
}
Just replace domoticz.devices('<name>') by domoticz.groups('<name>') if you want to switch a group instead of a single device.