Page 1 of 1

Chimney valve

Posted: Tuesday 21 September 2021 0:47
by jacobsentertainment
Hi all,

I'm trying to activate the valve in my chimney based on several states. two switch states have to be off and the temperature needs to be below 20°
I tried the following but I'm not getting any results or faults, what's going wrong?

Code: Select all

return
{
    on =
    {
        devices = {
            181, 180, 65, 64 
    }
},
    execute = function(domoticz, device)
        
        local Tempsensor = domoticz.devices(64)
		local Switch1 = domoticz.devices(180)
		local Switch2 = domoticz.devices(65)
		local Switch3 = domoticz.devices(181)
		local Temp = Tempsensor.temperature
		
        if  Switch3.state == 'off' and Switch2 == 'off' and Temp <= 20  then 
            Switch1.switchOn()
        end
    end
}

Re: Chimney valve

Posted: Tuesday 21 September 2021 1:00
by waltervl
Device states are case sensitive so instead of "off" use "Off".
See the device data page in the event editor (first tab) for your actual values.

Re: Chimney valve

Posted: Tuesday 21 September 2021 1:14
by jacobsentertainment
waltervl wrote: Tuesday 21 September 2021 1:00 Device states are case sensitive so instead of "off" use "Off".
See the device data page in the event editor (first tab) for your actual values.
Tried the uppercase and lowercase won't change any, still no results.

Device page, learned something today, didn't know this page.

Re: Chimney valve

Posted: Tuesday 21 September 2021 1:39
by waltervl
And you forgot the .state for Switch2

Re: Chimney valve

Posted: Tuesday 21 September 2021 2:02
by jacobsentertainment
I didn't see that, thanks it works now :mrgreen:

Re: Chimney valve

Posted: Tuesday 21 September 2021 7:39
by rrozema
To completely avoid the upper and lower case issues in the values, use device.active instead. active is a Boolean that will be true when the device.state is 'On' (or 'Open' or > 0% or ...) and false when the the device is 'Off' (or 'Closed' or 0% or ...).

Re: Chimney valve

Posted: Tuesday 21 September 2021 11:21
by jacobsentertainment
rrozema wrote: Tuesday 21 September 2021 7:39 To completely avoid the upper and lower case issues in the values, use device.active instead. active is a Boolean that will be true when the device.state is 'On' (or 'Open' or > 0% or ...) and false when the the device is 'Off' (or 'Closed' or 0% or ...).
Ill give that a try to, I'm not an software engineer so I have to find out by doing things and see results and go from there. Give me an engine or some other mechanical challenge and I'm the man :lol: But thanks for the tip!