Hi,
Can someone help me with a script for turning on my central ventilator.
If light is on (idx 138) for 3 minutes then turn on ventilator (idx 140) for 5 minutes.
Thanks!
Script for ventilator
Moderator: leecollings
-
- Posts: 215
- Joined: Thursday 12 October 2017 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Dev
- Location: the Netherlands
- Contact:
Re: Script for ventilator
Hi Labtec,
I control my central ventilator based on humidity, which I presume is what you really want in the end (I did not want the blower to start running when just brushing my teeth....). I have a humidity sensor in the bath room, compare that to the humidity in the living room and on a delta between the 2 switch on the blower (when using humidity you really need some comparison value, I started with absolute humidity levels for the bathroom but that drove me crazy because it would start running in the middle of the night which my wife did not appreciate....)
I know this is not an exact answer to your question, but below is what I made, don't know if you can use it......
Setup:
- nest thermo in the living room
- Everspring ST814 in the bathroom (robbshop, dutch webshop
- a Fibaro FGS222 2 realy switch that I mounted in the manual control switch of the blower, which is located in the kitchen (the blower is named WTW here)
I created a LUA for this:
I process the RequestWTW value further on the determine of it needs to be switched on. It is a 3 level ventilator, level 1 is the normal level, level 2 I do not use for the humidity control
I control my central ventilator based on humidity, which I presume is what you really want in the end (I did not want the blower to start running when just brushing my teeth....). I have a humidity sensor in the bath room, compare that to the humidity in the living room and on a delta between the 2 switch on the blower (when using humidity you really need some comparison value, I started with absolute humidity levels for the bathroom but that drove me crazy because it would start running in the middle of the night which my wife did not appreciate....)
I know this is not an exact answer to your question, but below is what I made, don't know if you can use it......
Setup:
- nest thermo in the living room
- Everspring ST814 in the bathroom (robbshop, dutch webshop
- a Fibaro FGS222 2 realy switch that I mounted in the manual control switch of the blower, which is located in the kitchen (the blower is named WTW here)
I created a LUA for this:
Code: Select all
----------------------------------------------------------------------------------------------------------
-- Script parameters
----------------------------------------------------------------------------------------------------------
Debug = "NO" -- Turn debugging on ("YES") or off ("NO")
RequestWTW = uservariables["WtwStandReq"] -- Requested WTW stand (pre-load with current)
----------------------------------------------------------------------------------------------------------
-- Script functions
----------------------------------------------------------------------------------------------------------
commandArray = {}
time = os.date("*t")
-- determine switch on/off for WTW due humidity sensor
for deviceName,deviceValue in pairs(devicechanged) do
if (deviceName=='Temp en vocht badkamer_Humidity') then
sBadTemp, sBadHumidity = otherdevices_svalues['Temp en vocht badkamer']:match("([^;]+);([^;]+)")
if Debug=="YES" then
print("event on '"..deviceName.."', value '"..tostring(deviceValue).."'");
end
--determine setpoint
sNestTemp, sNestHumidity = otherdevices_svalues['Nest Temp en Vocht']:match("([^;]+);([^;]+)")
if Debug=="YES" then
print("Nest, temp '" ..tostring(sNestTemp).."' humidity '"..tostring(sNestHumidity).."'")
end
sLevelOn = math.min(math.max(sNestHumidity + 25, 40), 80)
commandArray["Variable:WtwAanLevel"] = tostring(sLevelOn)
sLevelOff = sLevelOn - 10
commandArray["Variable:WtwUitLevel"] = tostring(sLevelOff)
print("setpoints, on '" ..tostring(sLevelOn).."' off '"..tostring(sLevelOff).."'")
if (deviceValue >= sLevelOn) then
--print("humidity high enough to turn on WTW");
commandArray['WTW Aan request'] = 'Off' -- request can be reset
if (otherdevices['WTW stand 3'] == 'Off') then
print("WTW goes On, '"..deviceName.."', value '"..tostring(deviceValue).."'");
RequestWTW = 3
end
end
if (deviceValue <= sLevelOff and otherdevices['WTW stand 3'] == 'On') then
print("WTW goes Off, '"..deviceName.."', value '"..tostring(deviceValue).."'");
RequestWTW = 1
commandArray['Wtw blokkeer'] = 'Off' -- request can be reset
end
end
end
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Script for ventilator
See below for a dzVents script that should do what you describe. (just assuming it is for the toilet. If it is for the bathroom you are better of with the script JanJaap posted)
If you are not yet familiar with dzvents then please look at the 10 lines using dzVents with Domoticz for an intro to dzVents and howto get this script active in domoticz.
Code: Select all
-- Delayed ventilator
local callback = "threeMinutesPast"
return {
on = {
devices = { 138 }, -- Light
httpResponses = { callback }
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "delayed Ventilator"
},
execute = function(dz, item)
local light = dz.devices(138)
local ventilator = dz.devices(140)
local function delayedURL(delay)
local logString = "/json.htm?type=command¶m=addlogmessage&message=" .. dz.utils.urlEncode("Check if light " .. light.name .. " is still On.")
local url= dz.settings['Domoticz url'] .. logString
dz.openURL({
url = url,
method = "GET",
callback = callback
}).afterSec(delay)
end
if item.isDevice and item.active then
delayedURL(180)
elseif light.active then
ventilator.switchOn().forSec(300)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Google [Bot] and 1 guest