Humidistat script

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

Moderator: leecollings

Post Reply
AlleyCat
Posts: 22
Joined: Tuesday 07 February 2017 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Humidistat script

Post by AlleyCat »

Hi,
I want to replace the humidistat control on my Furness with a z-wave controlled switch by reading the humidity from my z-wave thermostat and turning a switch "on" if the humidity drops below 45%.

My thermostat is a Honeywell Honeywell Lyric T6 Pro Zwave Plus Thermostat. I get to see the Humidity under the Temperature tab.

The issue I have is how to Index and read the value of the Humidity in a DZvents script?

Also, I'd like to add some logic that the script will detect the mode to be "Heat" and the Fan is on "Auto".
Screen Shot 2019-12-22 at 2.48.39 PM.png
Screen Shot 2019-12-22 at 2.48.39 PM.png (114.22 KiB) Viewed 1025 times
Thank you,
AlleyCat
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Humidistat script

Post by waaren »

AlleyCat wrote: Sunday 22 December 2019 20:53 The issue I have is how to Index and read the value of the Humidity in a DZvents script?
Also, I'd like to add some logic that the script will detect the mode to be "Heat" and the Fan is on "Auto".
Script below is only the basic part. For the other stuff you will have to explain what device types / sub types the thermostat and fan are in the domoticz devices tab.

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            206, -- change to idx number of your temperature / humidity sensor
        },
    },
   
    logging =
    {
        level = domoticz.LOG_DEBUG
    },

    execute = function(dz, item)
        _G.logMarker =  _G.moduleLabel
        
        local switch = dz.devices(204) -- change to idx number of your switch
        
        dz.log('Device ' .. item.name .. '; temp ' .. item.temperature .. '° C, humidity: ' .. item.humidity ..'%' , dz.LOG_DEBUG)
        
        if item.humidity < 45 then
            switch.switchOn().checkFirst()
        elseif item.humidity > 50 then
            switch.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
AlleyCat
Posts: 22
Joined: Tuesday 07 February 2017 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidistat script

Post by AlleyCat »

Thank you. The basic script works like a charm.

The Idx for the Humidity is 126.

The second test is on device Idx 119, which is the Thermostat mode = "Heat"

This way the humidifier will be off in Cool or Off modes.
Untitled 2.png
Untitled 2.png (290.67 KiB) Viewed 1005 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Humidistat script

Post by waaren »

AlleyCat wrote: Monday 23 December 2019 13:50 The second test is on device Idx 119, which is the Thermostat mode = "Heat"
Small problem that I cannot create this Thermostat mode device type as virtual device on my system. So you will have to show me the complete output of the script below (> 100 lines per dump() so probably need to log to a logfile) also the output of line below from your webbrowser might be helpful.

Code: Select all

<domoticz ip:domoticz_port>/json.htm?type=devices&rid=119

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            126, -- change to idx number of your temperature / humidity sensor
        },
    },
   
    logging =
    {
        level = domoticz.LOG_DEBUG
    },

    execute = function(dz, item)
        _G.logMarker =  _G.moduleLabel
        
        local switch = dz.devices(204) -- change to idx number of your switch
        
        dz.log('Device ' .. item.name .. '; temp ' .. item.temperature .. '° C, humidity: ' .. item.humidity ..'%' , dz.LOG_DEBUG)
        
        if item.humidity < 45 then
            switch.switchOn().checkFirst()
        elseif item.humidity > 50 then
            switch.switchOff().checkFirst()
        end
        
        dz.devices(120).dump()
        dz.devices(119).dump()
        
    end
}   
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
AlleyCat
Posts: 22
Joined: Tuesday 07 February 2017 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidistat script

Post by AlleyCat »

Here is the browser output:
Spoiler: show
{
"ActTime" : 1577131512,
"AstrTwilightEnd" : "18:31",
"AstrTwilightStart" : "06:06",
"CivTwilightEnd" : "17:20",
"CivTwilightStart" : "07:17",
"DayLength" : "08:58",
"NautTwilightEnd" : "17:56",
"NautTwilightStart" : "06:41",
"ServerTime" : "2019-12-23 15:05:12",
"SunAtSouth" : "12:18",
"Sunrise" : "07:49",
"Sunset" : "16:47",
"app_version" : "4.10717",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 95,
"CustomImage" : 0,
"Data" : "Heat",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 2,
"HardwareName" : "Z-Wave Gen-5",
"HardwareType" : "OpenZWave USB",
"HardwareTypeVal" : 21,
"HaveTimeout" : true,
"ID" : "00001001",
"LastUpdate" : "2019-12-22 15:24:03",
"Mode" : 1,
"Modes" : "0;Off;1;Heat;2;Cool;3;Heat Econ;4;Cool Econ;",
"Name" : "Thermostat Mode",
"Notifications" : "false",
"PlanID" : "4",
"PlanIDs" : [ 4 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Thermostat Mode",
"Timers" : "false",
"Type" : "General",
"TypeImg" : "mode",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "119"
}
],
"status" : "OK",
"title" : "Devices"
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Humidistat script

Post by waaren »

AlleyCat wrote: Monday 23 December 2019 21:08 Here is the browser output:
Stil kind of guessing without having the dumps but maybe this will do it. If not then I really need to see the logs with the dumps

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            126, -- change to idx number of your temperature / humidity sensor
            119,
        },
    },
   
    logging =
    {
        level = domoticz.LOG_DEBUG
    },

    execute = function(dz, item)
        _G.logMarker =  _G.moduleLabel
         
        local thermostat = dz.devices(119) -- Change to actual id's
        local temperatureHumidity = dz.devices(126)
        local switch = dz.devices(204)
        
        dz.log('Device ' .. temperatureHumidity.name .. '; temp: ' .. temperatureHumidity.temperature .. '° C, humidity: ' .. temperatureHumidity.humidity ..'%' , dz.LOG_DEBUG)
        dz.log('Device ' .. thermostat.name .. '; state: ' .. thermostat.state , dz.LOG_DEBUG)
        
        if temperatureHumidity.humidity < 45 then
            switch.switchOn().checkFirst()
        elseif temperatureHumidity.humidity > 50 or thermostat.rawData[1] == 'Cool' or thermostat.rawData[1] == 'Off' then
            switch.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
AlleyCat
Posts: 22
Joined: Tuesday 07 February 2017 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidistat script

Post by AlleyCat »

Sorry for the delay in posting the log. Please find the log below.

I want to activate the water shut-off valve only when the heating is on. Is there a way to test if the Heating is on?

Here are suggestions for a workaround in case we can't return if the Heating is on.

1) Is the Fan on? When the Thermostat Fan mode is set to Auto, the fan will work only if the Heating is on.
2) Perhaps we can test if the Temperature in the house is below the Thermostat settings.

Thank you very much.
Spoiler: show

Code: Select all

2019-12-23 18:11:29.682 OpenZWave: Value_Added: Node: 16 (0x10), CommandClass: THERMOSTAT FAN STATE, Label: Fan State, Instance: 1
2019-12-23 18:11:29.682 Status: OpenZWave: Unhandled class: 0x45 (THERMOSTAT FAN STATE), NodeID: 16 (0x10), Index: 0, Instance: 1
2019-12-23 18:11:30.270 OpenZWave: Value_Added: Node: 16 (0x10), CommandClass: THERMOSTAT OPERATING STATE, Label: Operating State, Instance: 1
2019-12-23 18:11:30.270 Status: OpenZWave: Unhandled class: 0x42 (THERMOSTAT OPERATING STATE), NodeID: 16 (0x10), Index: 0, Instance: 1
2019-12-23 18:13:30.950 (Z-Wave Gen-5) Temp + Humidity (Temp. Humidity)
2019-12-23 18:13:31.036 Status: dzVents: > isdst: false
2019-12-23 18:13:31.037 Status: dzVents: > wday: 2
2019-12-23 18:13:31.037 Status: dzVents: > minutesAgo: 1609
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAfterSunrise()
2019-12-23 18:13:31.037 Status: dzVents: > daysAgo: 1
2019-12-23 18:13:31.037 Status: dzVents: > ruleMatchesTimeRange()
2019-12-23 18:13:31.037 Status: dzVents: > milliseconds: 0
2019-12-23 18:13:31.037 Status: dzVents: > millisecondsAgo: 96568954
2019-12-23 18:13:31.037 Status: dzVents: > matchesRule()
2019-12-23 18:13:31.037 Status: dzVents: > ruleMatchesMinuteSpecification()
2019-12-23 18:13:31.037 Status: dzVents: > seconds: 3
2019-12-23 18:13:31.037 Status: dzVents: > week: 51
2019-12-23 18:13:31.037 Status: dzVents: > year: 2019
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAtCivilTwilightStart()
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAfterCivilTwilightStart()
2019-12-23 18:13:31.037 Status: dzVents: > milliSeconds: 0
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAtSunset()
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAtDayTime()
2019-12-23 18:13:31.037 Status: dzVents: > minutes: 24
2019-12-23 18:13:31.037 Status: dzVents: > min: 24
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsInWeek()
2019-12-23 18:13:31.037 Status: dzVents: > isUTC: false
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsOnDay()
2019-12-23 18:13:31.037 Status: dzVents: > secondsAgo: 96568
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsAtCivilNight()
2019-12-23 18:13:31.037 Status: dzVents: > dDate: 1577046243
2019-12-23 18:13:31.037 Status: dzVents: > rawDate: 2019-12-22
2019-12-23 18:13:31.037 Status: dzVents: > ruleIsBeforeSunset()
2019-12-23 18:13:31.037 Status: dzVents: > yday: 356
2019-12-23 18:13:31.037 Status: dzVents: > hour: 15
2019-12-23 18:13:31.037 Status: dzVents: > dayAbbrOfWeek: sun
2019-12-23 18:13:31.037 Status: dzVents: > ruleMatchesTime()
2019-12-23 18:13:31.037 Status: dzVents: > utils:
2019-12-23 18:13:31.037 Status: dzVents: > stringSplit()
2019-12-23 18:13:31.037 Status: dzVents: > rgbToHSB()
2019-12-23 18:13:31.037 Status: dzVents: > LOG_DEBUG: 4
2019-12-23 18:13:31.037 Status: dzVents: > LOG_FORCE: 0.5
2019-12-23 18:13:31.037 Status: dzVents: > fromJSON()
2019-12-23 18:13:31.037 Status: dzVents: > LOG_INFO: 3
2019-12-23 18:13:31.037 Status: dzVents: > fileExists()
2019-12-23 18:13:31.037 Status: dzVents: > hsbToRGB()
2019-12-23 18:13:31.037 Status: dzVents: > log()
2019-12-23 18:13:31.037 Status: dzVents: > DZVERSION: 2.4.19
2019-12-23 18:13:31.037 Status: dzVents: > LOG_ERROR: 1
2019-12-23 18:13:31.037 Status: dzVents: > urlDecode()
2019-12-23 18:13:31.038 Status: dzVents: > urlEncode()
2019-12-23 18:13:31.038 Status: dzVents: > dumpTable()
2019-12-23 18:13:31.038 Status: dzVents: > osExecute()
2019-12-23 18:13:31.038 Status: dzVents: > LOG_MODULE_EXEC_INFO: 2
2019-12-23 18:13:31.038 Status: dzVents: > toJSON()
2019-12-23 18:13:31.038 Status: dzVents: > print()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAfterCivilTwilightEnd()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsBeforeSunrise()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAtSunrise()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsBeforeCivilTwilightEnd()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAtCivilTwilightEnd()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsBeforeCivilTwilightStart()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAtNight()
2019-12-23 18:13:31.038 Status: dzVents: > msAgo: 96568954
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsOnDate()
2019-12-23 18:13:31.038 Status: dzVents: > isToday: false
2019-12-23 18:13:31.038 Status: dzVents: > month: 12
2019-12-23 18:13:31.038 Status: dzVents: > rawTime: 15:24:03
2019-12-23 18:13:31.038 Status: dzVents: > wday: 1
2019-12-23 18:13:31.038 Status: dzVents: > sec: 3
2019-12-23 18:13:31.038 Status: dzVents: > getISO()
2019-12-23 18:13:31.038 Status: dzVents: > compare()
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAtCivilDayTime()
2019-12-23 18:13:31.038 Status: dzVents: > secondsSinceMidnight: 55443
2019-12-23 18:13:31.038 Status: dzVents: > ruleMatchesBetweenRange()
2019-12-23 18:13:31.038 Status: dzVents: > raw: 2019-12-22 15:24:03
2019-12-23 18:13:31.038 Status: dzVents: > ruleIsAfterSunset()
2019-12-23 18:13:31.038 Status: dzVents: > isdst: false
2019-12-23 18:13:31.038 Status: dzVents: > hoursAgo: 26
2019-12-23 18:13:31.038 Status: dzVents: > switchType: On/Off
2019-12-23 18:13:31.038 Status: dzVents: > setVolume()
2019-12-23 18:13:31.038 Status: dzVents: > dump()
2019-12-23 18:13:31.038 Status: dzVents: > setValues()
2019-12-23 18:13:31.038 Status: dzVents: > updateSetPoint()
2019-12-23 18:13:31.038 Status: dzVents: > batteryLevel: 95
2019-12-23 18:13:31.038 Status: dzVents: > deviceSubType: Thermostat Mode
2019-12-23 18:13:31.038 Status: dzVents: > hardwareName: Z-Wave Gen-5
2019-12-23 18:13:31.038 Status: dzVents: > switchOff()
2019-12-23 18:13:31.038 Status: dzVents: > updateRain()
2019-12-23 18:13:31.038 Status: dzVents: > changed: false
2019-12-23 18:13:31.038 Status: dzVents: > updateAlertSensor()
2019-12-23 18:13:31.039 Status: dzVents: > updateGas()
2019-12-23 18:13:31.039 Status: dzVents: > updateCustomSensor()
2019-12-23 18:13:31.039 Status: dzVents: > id: 119
2019-12-23 18:13:31.039 Status: dzVents: > isTimer: false
2019-12-23 18:13:31.039 Status: dzVents: > isScene: false
2019-12-23 18:13:31.039 Status: dzVents: > isDevice: true
2019-12-23 18:13:31.039 Status: dzVents: > kodiSetVolume()
2019-12-23 18:13:31.039 Status: dzVents: > isGroup: false
2019-12-23 18:13:31.039 Status: dzVents: > description:
2019-12-23 18:13:31.039 Status: dzVents: > updateTempHum()
2019-12-23 18:13:31.039 Status: dzVents: > setIcon()
2019-12-23 18:13:31.039 Status: dzVents: > idx: 119
2019-12-23 18:13:31.039 Status: dzVents: > updateAirQuality()
2019-12-23 18:13:31.039 Status: dzVents: Info: ------ Finished Script #1
AlleyCat
Posts: 22
Joined: Tuesday 07 February 2017 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidistat script

Post by AlleyCat »

Hi,
I want to add to the switch.switchOn().checkFirst() additional command to switch the fan mode to "1" = "On Low".

According to the the dump log, there are the following fan modes:
modes: 0;Auto Low;1;On Low;6;Circulat

How can I set the fan mode to 1 "On Low"?

Thanks,

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

Re: Humidistat script

Post by waaren »

AlleyCat wrote: Thursday 26 December 2019 22:35 Hi,
I want to add to the switch.switchOn().checkFirst() additional command to switch the fan mode to "1" = "On Low".

According to the the dump log, there are the following fan modes:
modes: 0;Auto Low;1;On Low;6;Circulat

How can I set the fan mode to 1 "On Low"?

Thanks,

AlleyCat
I have send you a DM on Tuesday 24 December 2019 at 7:19
Please have a look and reply there . Thx
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

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