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.
Use device status in Timers to switch device
Moderators: leecollings, remb0
-
- Posts: 470
- Joined: Thursday 26 October 2017 13:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Delft
- Contact:
Re: Use device status in Timers to switch device
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:
Just replace domoticz.devices('<name>') by domoticz.groups('<name>') if you want to switch a group instead of a single device.
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
}
Who is online
Users browsing this forum: No registered users and 1 guest