Utility to set limit for humidity  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Utility to set limit for humidity

Post by ulfh2018 »

I have been using SetPiont to define values for temperature, but now I need an interactive way to set max and min values for humidity, that is being able to input these values (as integers) from the dashboard. I could possibly use SetPoint, and extract the values, but it seems odd to display SetPoint in degrees, when it is a number for the humidity.

Is there any way I can make this happen?

Best regards

Ulf
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Utility to set limit for humidity

Post by waaren »

ulfh2018 wrote: Friday 08 May 2020 18:15 I need an interactive way to set max and min values for humidity.
If you only need a limited number of steps you could use two selectors. (one for max and one for min value)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Re: Utility to set limit for humidity

Post by ulfh2018 »

Might be a solution. Didn’t even know that one existed! Thanks a lot! I’ll give it a try tomorrow :D
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Re: Utility to set limit for humidity

Post by ulfh2018 »

Hi Waaren.
Yes, that's a good starting point.

What I need now is:

1. getting a selected value from two selectors, one for max and one for min. This will be integers
2. defining the two values as persistent variables (so they can survive a reboot)
3. access the two variables from dzVents, take action if they are changed, using checkFirst()

Tried to look at some examples. In node-red I would have stored the varibles in a database, but I understand Domoticz has an internal database(?) but how do I access it?

I have tried to create a global_data.lua in the script directory:

return {
helpers = {},
data = {
MaxHum = { initial = 80 },
MinHum = { initial = 60 }
}
}

From dzvent I try to access use the variables:

if (hum >= (domoticz.globalData.MaxHum)) then -- Turn on fan
domoticz.devices(4).switchOn().checkFirst() -- Turn on fan
elseif (hum <= (domoticz.globalData.MinHum)) then -- turn off fan
domoticz.devices(4).switchOff().checkFirst()

Gives me an error:

attempt to compare nil with number

And then, off course, I need to upgrade MaxHum and MinHum from the Selector Switch.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Utility to set limit for humidity

Post by waaren »

ulfh2018 wrote: Saturday 09 May 2020 7:08 What I need now is:

1. getting a selected value from two selectors, one for max and one for min. This will be integers
2. defining the two values as persistent variables (so they can survive a reboot)
3. access the two variables from dzVents, take action if they are changed, using checkFirst()
I think you over complicate it.
This will also do the job without persistent vars and will survive a boot.

Code: Select all

return 
{
	on = 
	{
	    timer = 
	    { 
	        'every minute',
	    },
	},

	logging = 
	{
	    level = domoticz.LOG_DEBUG,    
	},
	
	execute = function(dz)
	    local humidity = dz.devices('humSensor').humidity
	    local maxHumidity = tonumber(dz.devices('max Humidity').levelName) or 100  -- the or parts are for cases that the levelname is not numeric
	    local minHumidity = tonumber(dz.devices('min Humidity').levelName) or 0 
	    local fan = dz.devices(4)
	    
	    if humidity >= maxHumidity then  
            fan.switchOn().checkFirst() 
        elseif humidity <= minHumidity then
            fan.switchOff().checkFirst() 
        end    
	end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Re: Utility to set limit for humidity  [Solved]

Post by ulfh2018 »

Dear Waaren

First I have one question: Do you ever sleep? :D

Thank you so much - that was a life savior!

Why do things complicated, when it can be done simple and elegant!

My main problem is, as it comes with a few other members, lack of experiense. I try to check google and the forum, but I have to admit that most of the stuff I find there is too complicated. This one, by the way, was easy to understand, but I would not have been able to dig it out my self in a million years.

Have a lovely day - I'll have a pint of beer at the varanda to celebrate you and your work!!!!!

How do I report this as solved???

All the best from

Ulf
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest