Use device status in Timers to switch device

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
Post Reply
pjotr
Posts: 4
Joined: Sunday 21 February 2016 19:00
Target OS: Raspberry Pi
Domoticz version: latest
Location: Zuid Holland
Contact:

Use device status in Timers to switch device

Post by pjotr » Wednesday 06 June 2018 21:32

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.

rrozema
Posts: 107
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Re: Use device status in Timers to switch device

Post by rrozema » Tuesday 19 June 2018 11:01

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest