Page 1 of 1
Need assistance for script Mechanical Ventilation
Posted: Thursday 10 October 2019 15:56
by Marcjeok
Hi all,
I need some assistance again I'm afraid
I'm trying to write a dzvents script to control my Mechanical Ventilation (MV). Here for I have two humidity sensors (Philio Technology Corp PH-PAT02-B.eu Multisensor 2in1+). In my current blockly script I can easily compare to the humidity percentage. But with dzvents I get this when I ask to presents its state to the log:
dzVents: Info: 18.8;95;3
In this example, the 95 is the humidity percentage and that's the one I want to use. Then I want to compare it with my other one en let's say that if the bathroom is more then 5% higher, I want to raise the MV.
So my questions are:
1. How can I strip the the dzvents log to only the middle value (in this case 95)?
2. How can I compare with the +5 value?
Thanks again in advance
Not sure if it's needed, but this is the script I have made so far. It's not complete (not by a long shot) en not tested yet
Code: Select all
--[[
SCRIPT DESCRIPTION:
This script turns controls the mechanical ventilation level depending on noise, moister and presence.
DEVICES USED:
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
Idx 84 = Aanwezigheid
Idx 128 = Mechanische ventilatie stand 2
Idx 129 = Mechanische ventilatie stand 3
Idx 144 = Mechanische ventilatie - stand 3 toegestaan
Idx 175 = Badkamer - TempHum
Idx 169 = SK - TempHum
INFO CREATING SCRIPT:
dzVents: Info: 18.8;95;3 <-- output domoticz.log(domoticz.devices(175).state) / 18.8;95;3 = 18.8 graden;95 procent
domoticz.log(domoticz.devices(175).humidity.state) <-- no result in log
if (domoticz.devices(175) > '25%') then
domoticz.log(domoticz.devices(175).state) <-- no entry in log
]]--
--SET USER INPUT VARIABLES:
local IDQST2 = 54 --only allowd to use in script controlling MV directly
local IDQST3 = 55 --only allowd to use in script controlling MV directly
local DELAY = 10 --set delay in seconds to switch to another ventilation level (safe minimum = 10)
local IDMV2 = 128
local IDMV3 = 129
local IDSILENCE = 144
local IDPR = 84
local IDBATHH = 175
local IDBEDH = 169
local STARTNOISE = 'at 07:00'
local ENDNOISE = 'at 19:15'
return {
active = true,
on = {
devices = {
IDMV2,
IDMV3,
IDSILENCE,
IDPRES,
IDBATHH,
IDBEDH,
},
timer = {
STARTNOISE,
ENDNOISE,
},
},
execute = function(domoticz, triggeredItem, info)
--SET VARIABLES:
local MVDIRECT2 = domoticz.devices(IDQST2) --only allowd to use in script controlling MV directly
local MVDIRECT3 = domoticz.devices(IDQST3) --only allowd to use in script controlling MV directly
local MVLEVEL2 = domoticz.devices(IDMV2)
local MVLEVEL3 = domoticz.devices(IDMV3)
local MVSILENCE = domoticz.devices(IDSILENCE)
local PRESENCE = domoticz.devices(IDPR)
local BATHHUMIDITY = domoticz.devices(IDBATHH)
local BEDHUMIDITY = domoticz.devices(IDBEDH)
-- EXECUTE SCRIPT
if (triggeredItem.id == IDSILENCE) and (MVSILENCE == "On") and (MVLEVEL3.state == "On") then
domoticz.log('MV: Too much noise, lower the mechanical ventilation to level 2')
MVLEVEL2.switchOn()
elseif (triggeredItem.id == IDPR) and (PRESENCE == "On") and (MVLEVEL2 == "Off") and (MVLEVEL3 == "Off") then
domoticz.log('MV: There is presence, bring in the fresh air')
MVLEVEL2.switchOn()
elseif (triggeredItem.id == STARTNOISE) and (MVSILENCE == "Off") then
domoticz.log('MV: Noise is allowed')
MVSILENCE.switchOn()
elseif (triggeredItem.id == ENDNOISE) and (MVSILENCE == "On") then
domoticz.log('MV: Noise is not allowed anymore')
MVSILENCE.switchOff()
end
-- EXECUTE SCRIPT CONTROLLING MV DIRECTLY (DO NOT CHANGE) <-- this part has been tested
if (triggeredItem.id == IDMV2) and (MVLEVEL2.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 2 with a '..DELAY..' seconds delay')
if (MVLEVEL3.state == "On") then MVLEVEL3.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT2.switchOn().afterSec(DELAY)
elseif (triggeredItem.id == IDMV3) and (MVLEVEL3.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 3 with a '..DELAY..' seconds delay')
if (MVLEVEL2.state == "On") then MVLEVEL2.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT3.switchOn().afterSec(DELAY)
elseif (MVLEVEL2.state == "Off") and (MVLEVEL3.state == "Off") then
if (MVDIRECT2.state == "On") or (MVDIRECT3.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 1')
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
end
end
end
}
Re: Need assistance for script Mechanical Ventilation [Solved]
Posted: Thursday 10 October 2019 18:37
by waaren
Marcjeok wrote: ↑Thursday 10 October 2019 15:56
1. How can I strip the the dzvents log to only the middle value (in this case 95)?
2. How can I compare with the +5 value?
Can you have a look at this and try ?
Code: Select all
--[[
SCRIPT DESCRIPTION:
This script turns controls the mechanical ventilation level depending on noise, moister and presence.
DEVICES USED:
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
Idx 84 = Aanwezigheid
Idx 128 = Mechanische ventilatie stand 2
Idx 129 = Mechanische ventilatie stand 3
Idx 144 = Mechanische ventilatie - stand 3 toegestaan
Idx 175 = Badkamer - TempHum
Idx 169 = SK - TempHum
INFO CREATING SCRIPT:
dzVents: Info: 18.8;95;3 <-- output domoticz.log(domoticz.devices(175).state) / 18.8;95;3 = 18.8 graden;95 procent
domoticz.log(domoticz.devices(175).humidity.state) <-- no result in log
if (domoticz.devices(175) > '25%') then
domoticz.log(domoticz.devices(175).state) <-- no entry in log
]]--
--SET USER INPUT VARIABLES:
local IDQST2 = 54 --only allowd to use in script controlling MV directly
local IDQST3 = 55 --only allowd to use in script controlling MV directly
local DELAY = 10 --set delay in seconds to switch to another ventilation level (safe minimum = 10)
local IDMV2 = 128
local IDMV3 = 129
local IDSILENCE = 144
local IDPR = 84
local IDBATHH = 175
local IDBEDH = 169
local STARTNOISE = 'at 07:00'
local ENDNOISE = 'at 19:15'
return {
active = true,
on = {
devices = {
IDMV2,
IDMV3,
IDSILENCE,
IDPRES,
IDBATHH,
IDBEDH,
},
timer = {
STARTNOISE,
ENDNOISE,
},
},
execute = function(domoticz, triggeredItem, info)
--SET VARIABLES:
local MVDIRECT2 = domoticz.devices(IDQST2) --only allowd to use in script controlling MV directly
local MVDIRECT3 = domoticz.devices(IDQST3) --only allowd to use in script controlling MV directly
local MVLEVEL2 = domoticz.devices(IDMV2)
local MVLEVEL3 = domoticz.devices(IDMV3)
local MVSILENCE = domoticz.devices(IDSILENCE)
local PRESENCE = domoticz.devices(IDPR)
local BATHHUMIDITY = domoticz.devices(IDBATHH).humidity
local BEDHUMIDITY = domoticz.devices(IDBEDH).humidity
-- EXECUTE SCRIPT
if (triggeredItem.id == IDSILENCE) and (MVSILENCE.state == "On") and (MVLEVEL3.state == "On") then
domoticz.log('MV: Too much noise, lower the mechanical ventilation to level 2')
MVLEVEL2.switchOn()
elseif (triggeredItem.id == IDPR) and (PRESENCE.state == "On") and (MVLEVEL2.state == "Off") and (MVLEVEL3.state == "Off") then
domoticz.log('MV: There is presence, bring in the fresh air')
MVLEVEL2.switchOn()
elseif (triggeredItem.id == STARTNOISE) and (MVSILENCE.state == "Off") then
domoticz.log('MV: Noise is allowed')
MVSILENCE.switchOn()
elseif (triggeredItem.id == ENDNOISE) and (MVSILENCE.state == "On") then
domoticz.log('MV: Noise is not allowed anymore')
MVSILENCE.switchOff()
end
-- Check and compare humidities
if BATHHUMIDITY > ( BEDHUMIDITY + 5 ) then
domoticz.log('MV: Delta humidity > 5 ')
else
domoticz.log('MV: Delta humidity > 5 ')
end
-- EXECUTE SCRIPT CONTROLLING MV DIRECTLY (DO NOT CHANGE) <-- this part has been tested
if (triggeredItem.id == IDMV2) and (MVLEVEL2.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 2 with a '..DELAY..' seconds delay')
if (MVLEVEL3.state == "On") then MVLEVEL3.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT2.switchOn().afterSec(DELAY)
elseif (triggeredItem.id == IDMV3) and (MVLEVEL3.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 3 with a '..DELAY..' seconds delay')
if (MVLEVEL2.state == "On") then MVLEVEL2.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT3.switchOn().afterSec(DELAY)
elseif (MVLEVEL2.state == "Off") and (MVLEVEL3.state == "Off") then
if (MVDIRECT2.state == "On") or (MVDIRECT3.state == "On") then
domoticz.log('MV: Set mechanical ventilation to level 1')
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
end
end
end
}
Re: Need assistance for script Mechanical Ventilation
Posted: Thursday 10 October 2019 19:15
by Marcjeok
Thanks again! It seems to work. I will continue working on this script and will come back here if it's finished or when I need more assistance

.
Re: Need assistance for script Mechanical Ventilation
Posted: Saturday 12 October 2019 15:37
by Marcjeok
My script is still under construction, but it looks already promising
I promised to share my script, so hereby my script so far. I will probably make some more (small) changes in the future and will share it again when it's final.
Code: Select all
--[[
SCRIPT DESCRIPTION:
This script turns controls the mechanical ventilation level depending on humidity, noise, presence and time.
The MV level will be set to level 1, 2 or 3.
DEVICES USED:
Idx 8 = Weer - Barometer
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
Idx 84 = Aanwezigheid
Idx 128 = Mechanische ventilatie stand 2
Idx 129 = Mechanische ventilatie stand 3
Idx 144 = Mechanische ventilatie - stand 3 toegestaan
Idx 169 = SK - TempHum
Idx 175 = Badkamer - TempHum
]]--
--SET USER INPUT VARIABLES:
local IDQST2 = 54 --only allowd to use in script controlling MV directly
local IDQST3 = 55 --only allowd to use in script controlling MV directly
local DELAY = 10 --set delay in seconds to switch to another ventilation level (safe minimum = 10)
local IDMV2 = 128
local IDMV3 = 129
local IDSILENCE = 144
local IDPR = 84
local IDBATHH = 175
local IDBEDH = 169
local IDOUTDOOR = 8
local STARTNOISE = 'at 07:00'
local ENDNOISE = 'at 19:15'
local DIFFERENCE = 7 --allowed difference between bathroom and bedroom
local LOGGINGON = "Yes" -- turn logging on or off (values: On = "Yes", Off = "No")
return {
active = true,
on = {
devices = {
IDMV2,
IDMV3,
IDSILENCE,
IDPRES,
IDBATHH,
IDBEDH,
},
timer = {
STARTNOISE,
ENDNOISE,
},
},
execute = function(domoticz, triggeredItem, info)
--SET VARIABLES:
local MVDIRECT2 = domoticz.devices(IDQST2) --only allowd to use in script controlling MV directly
local MVDIRECT3 = domoticz.devices(IDQST3) --only allowd to use in script controlling MV directly
local MVLEVEL2 = domoticz.devices(IDMV2)
local MVLEVEL3 = domoticz.devices(IDMV3)
local MVSILENCE = domoticz.devices(IDSILENCE)
local PRESENCE = domoticz.devices(IDPR)
local BATHHUMIDITY = domoticz.devices(IDBATHH).humidity
local BEDHUMIDITY = domoticz.devices(IDBEDH).humidity
local OUTDOORHUMIDITY = domoticz.devices(IDOUTDOOR).humidity
local LOGGING = "\n++++++++++++++++++++\n".."SCRIPT MECHANICAL VENTILATION:".."\n...................."
-- EXECUTE SCRIPT: SET MV LEVEL (CHECK AND COMPARE HUMIDITIES)
LOGGING = LOGGING .."\n".."SET LEVEL:"
LOGGING = LOGGING .."\n".."MV-status: Bathroom: "..BATHHUMIDITY.." vs. Bedroom: "..BEDHUMIDITY.." (Outside: "..OUTDOORHUMIDITY..")"
if BATHHUMIDITY > (BEDHUMIDITY + DIFFERENCE) then
LOGGING = LOGGING .."\n".."MV-program: Humidity in bathroom is too high"
if (MVSILENCE.state == 'On') and (MVLEVEL3.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-changelevel: Noise OK, change MV to level 3"
MVLEVEL3.switchOn()
elseif (MVSILENCE.state == 'Off') and (MVLEVEL2.state == 'Off') then
MVLEVEL2.switchOn()
LOGGING = LOGGING .."\n".."MV-changelevel: No noise, change MV to level 2"
else
LOGGING = LOGGING .."\n".."No action needed"
end
else
LOGGING = LOGGING .."\n".."MV-program: Humidity in bathroom is normal"
if (PRESENCE.state == 'On') then
LOGGING = LOGGING .."\n".."MV-subprogram: Presence: Yes "
if domoticz.time.matchesRule('at 06:15-23:30') then
LOGGING = LOGGING .." -- Day time active:"
if (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 2"
MVLEVEL2.switchOn()
elseif (MVLEVEL2.state == 'Off') and (MVLEVEL3.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 1 to level 2"
MVLEVEL2.switchOn()
else
LOGGING = LOGGING .."\n".."No action needed"
end
else
LOGGING = LOGGING .." --Night time active"
if (MVLEVEL2.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 2 to level 1"
MVLEVEL2.switchOff()
elseif (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 1"
MVLEVEL3.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed"
end
end
elseif (PRESENCE.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-subprogram: Presence: No"
if (MVLEVEL2.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 2 to level 1"
MVLEVEL2.switchOff()
elseif (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 1"
MVLEVEL3.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed"
end
end
end
-- EXECUTE SCRIPT: TURN MVSILENCE ON/OFF
LOGGING = LOGGING .."\n".."\n".."SET MVSILENCE:"
if domoticz.time.matchesRule(STARTNOISE) and (MVSILENCE.state == 'Off') then
LOGGING = LOGGING .."\n".."Noise is allowed from now "..STARTNOISE
MVSILENCE.switchOn()
elseif domoticz.time.matchesRule(ENDNOISE) and (MVSILENCE.state == 'On') then
LOGGING = LOGGING .."\n".."Noise is not allowed anymore from now "..ENDNOISE
MVSILENCE.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed"
end
-- EXECUTE SCRIPT: CONTROLLING MV DIRECTLY (DO NOT CHANGE) <-- this part has been tested
LOGGING = LOGGING .."\n".."\n".."SET MV DIRECTLY:"
if (triggeredItem.id == IDMV2) and (MVLEVEL2.state == "On") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 2 with a "..DELAY.."seconds delay"
if (MVLEVEL3.state == "On") then MVLEVEL3.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT2.switchOn().afterSec(DELAY)
elseif (triggeredItem.id == IDMV3) and (MVLEVEL3.state == "On") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 3 with a "..DELAY.."seconds delay"
if (MVLEVEL2.state == "On") then MVLEVEL2.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT3.switchOn().afterSec(DELAY)
elseif (MVLEVEL2.state == "Off") and (MVLEVEL3.state == "Off") then
if (MVDIRECT2.state == "On") or (MVDIRECT3.state == "On") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 1"
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
end
else
LOGGING = LOGGING .."\n".."No action needed"
end
LOGGING = LOGGING .."\n++++++++++++++++++++"
--LOGGING:
if (LOGGINGON == "Yes") then
domoticz.log(LOGGING)
end
end
}
Re: Need assistance for script Mechanical Ventilation
Posted: Saturday 12 October 2019 21:33
by Joep123
What kind of devices are:
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
?
Re: Need assistance for script Mechanical Ventilation
Posted: Sunday 13 October 2019 12:25
by Marcjeok
Joep123 wrote: ↑Saturday 12 October 2019 21:33
What kind of devices are:
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
It's one device (double light switch):
Qubino (Goap) ZMNHBDx Flush 2 Relays+
This device has been attached to my Duco MV (DucoBox Silent).
Re: Need assistance for script Mechanical Ventilation
Posted: Thursday 17 October 2019 7:21
by Marcjeok
As promised, hereby my final script. I've made several small changes and fixed a bug.
Code: Select all
--[[
SCRIPT DESCRIPTION:
This script turns controls the mechanical ventilation level depending on humidity, noise, presence and time.
The MV level will be set to level 1, 2 or 3.
DEVICES USED:
Idx 8 = Weer - Barometer
Idx 54 = MV-Q1-ST2
Idx 55 = MV-Q2-ST3
Idx 84 = Aanwezigheid
Idx 128 = Mechanische ventilatie stand 2
Idx 129 = Mechanische ventilatie stand 3
Idx 144 = Mechanische ventilatie - stand 3 toegestaan
Idx 169 = SK - TempHum
Idx 175 = Badkamer - TempHum
]]--
--SET USER INPUT VARIABLES:
local IDQST2 = 54 --only allowd to use in script controlling MV directly
local IDQST3 = 55 --only allowd to use in script controlling MV directly
local DELAY = 10 --set delay in seconds to switch to another ventilation level (safe minimum = 10)
local IDMV2 = 128
local IDMV3 = 129
local IDSILENCE = 144
local IDPR = 84
local IDBATHH = 175
local IDBEDH = 169
local IDOUTDOOR = 8
local STARTNOISE = 'at 06:55'
local ENDNOISE = 'at 19:15'
local DIFFERENCE = 7 --allowed difference between bathroom and bedroom
local LOGGINGON = "Yes" -- turn logging on or off (values: On = "Yes", Off = "No")
return {
active = true,
on = {
devices = {
IDMV2,
IDMV3,
IDSILENCE,
IDPR,
IDBATHH,
IDBEDH,
},
timer = {
STARTNOISE,
ENDNOISE,
},
},
execute = function(domoticz, triggeredItem, info)
--SET VARIABLES:
local MVDIRECT2 = domoticz.devices(IDQST2) --only allowd to use in script controlling MV directly
local MVDIRECT3 = domoticz.devices(IDQST3) --only allowd to use in script controlling MV directly
local MVLEVEL2 = domoticz.devices(IDMV2)
local MVLEVEL3 = domoticz.devices(IDMV3)
local MVSILENCE = domoticz.devices(IDSILENCE)
local PRESENCE = domoticz.devices(IDPR)
local BATHHUMIDITY = domoticz.devices(IDBATHH).humidity
local BEDHUMIDITY = domoticz.devices(IDBEDH).humidity
local OUTDOORHUMIDITY = domoticz.devices(IDOUTDOOR).humidity
local LOGGING = "\n++++++++++++++++++++\n".."SCRIPT MECHANICAL VENTILATION:".."\n...................."
-- EXECUTE SCRIPT: SET MV LEVEL (CHECK AND COMPARE HUMIDITIES)
LOGGING = LOGGING .."\n".."SET LEVEL:"
LOGGING = LOGGING .."\n".."MV-status: Bathroom: "..BATHHUMIDITY.." vs. Bedroom: "..BEDHUMIDITY.." (Outside: "..OUTDOORHUMIDITY..")"
LOGGING = LOGGING .."\n".."Allowed difference: "..DIFFERENCE
if BATHHUMIDITY > (BEDHUMIDITY + DIFFERENCE) then
LOGGING = LOGGING .."\n".."MV-program: Humidity bathroom too high"
if (MVSILENCE.state == 'On') and (MVLEVEL3.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-changelevel: Noise OK, change MV to level 3"
MVLEVEL3.switchOn()
elseif (MVSILENCE.state == 'Off') and (MVLEVEL2.state == 'Off') then
MVLEVEL2.switchOn()
LOGGING = LOGGING .."\n".."MV-changelevel: No noise allowed, change MV to level 2"
else
LOGGING = LOGGING .."\n".."No action needed ".." (MV-lvl 2 = "..MVLEVEL2.state..", MV-lvl 3 = "..MVLEVEL3.state..")"
end
else
LOGGING = LOGGING .."\n".."MV-program: Humidity bathroom normal"
if (PRESENCE.state == 'On') then
LOGGING = LOGGING .."\n".."MV-subprogram: Presence: Yes "
if domoticz.time.matchesRule('at 06:15-23:30') then
LOGGING = LOGGING .." -- Day time active:"
if (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 2"
MVLEVEL2.switchOn()
elseif (MVLEVEL2.state == 'Off') and (MVLEVEL3.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 1 to level 2"
MVLEVEL2.switchOn()
else
LOGGING = LOGGING .."\n".."No action needed".." (MV-lvl 2 = "..MVLEVEL2.state..", MV-lvl 3 = "..MVLEVEL3.state..")"
end
else
LOGGING = LOGGING .." --Night time active"
if (MVLEVEL2.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 2 to level 1"
MVLEVEL2.switchOff()
elseif (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 1"
MVLEVEL3.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed".." (MV-lvl 2 = "..MVLEVEL2.state..", MV-lvl 3 = "..MVLEVEL3.state..")"
end
end
elseif (PRESENCE.state == 'Off') then
LOGGING = LOGGING .."\n".."MV-subprogram: Presence: No"
if (MVLEVEL2.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 2 to level 1"
MVLEVEL2.switchOff()
elseif (MVLEVEL3.state == 'On') then
LOGGING = LOGGING .."\n".."MV-changelevel: Change MV from level 3 to level 1"
MVLEVEL3.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed".." (MV-lvl 2 = "..MVLEVEL2.state..", MV-lvl 3 = "..MVLEVEL3.state..")"
end
end
end
-- EXECUTE SCRIPT: TURN MVSILENCE ON/OFF
LOGGING = LOGGING .."\n".."\n".."SET MVSILENCE:"
if domoticz.time.matchesRule(STARTNOISE) and (MVSILENCE.state == 'Off') then
LOGGING = LOGGING .."\n".."Noise is allowed from now "..STARTNOISE
MVSILENCE.switchOn()
elseif domoticz.time.matchesRule(ENDNOISE) and (MVSILENCE.state == 'On') then
LOGGING = LOGGING .."\n".."No Noise allowed anymore "..ENDNOISE
MVSILENCE.switchOff()
else
LOGGING = LOGGING .."\n".."No action needed".." (noise allowed = "..MVSILENCE.state..")"
end
-- EXECUTE SCRIPT: CONTROLLING MV DIRECTLY (DO NOT CHANGE) <-- this part has been tested
LOGGING = LOGGING .."\n".."\n".."SET MV DIRECTLY:"
if (triggeredItem.id == IDMV2) and (MVLEVEL2.state == "On") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 2 with a "..DELAY.." seconds delay"
if (MVLEVEL3.state == "On") then MVLEVEL3.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT2.switchOn().afterSec(DELAY)
elseif (triggeredItem.id == IDMV3) and (MVLEVEL3.state == "On") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 3 with a "..DELAY.." seconds delay"
if (MVLEVEL2.state == "On") then MVLEVEL2.switchOff() end
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
MVDIRECT3.switchOn().afterSec(DELAY)
elseif (MVLEVEL2.state == "Off") and (MVLEVEL3.state == "Off") then
LOGGING = LOGGING .."\n".."MV-directly: Change to level 1"
if (MVDIRECT2.state == "On") or (MVDIRECT3.state == "On") then
MVDIRECT2.switchOff()
MVDIRECT3.switchOff()
end
else
LOGGING = LOGGING .."\n".."No action needed"
end
LOGGING = LOGGING .."\n++++++++++++++++++++"
--LOGGING:
if (LOGGINGON == "Yes") then
domoticz.log(LOGGING)
end
end
}
Re: Need assistance for script Mechanical Ventilation
Posted: Thursday 17 October 2019 8:41
by freijn
Without looking at your script.... Are you aware there is a Bathroom script already ?
I am running it for over a year now and love it. It handles all situations and changes pretty well.
Frank
Re: Need assistance for script Mechanical Ventilation
Posted: Thursday 17 October 2019 9:06
by Marcjeok
freijn wrote: ↑Thursday 17 October 2019 8:41
Without looking at your script.... Are you aware there is a Bathroom script already ?
I am running it for over a year now and love it. It handles all situations and changes pretty well.
Frank
I've seen multiple bathroom scripts, but the scripts I've seen didn't completely fulfil my personal needs. That's why I made my own. Because I needed some help with making this script (I'm a noob at scripting

), I think it's useful for others if they can see the question and a working end result. At least I like to see working end results, so I can borrow commands that works. So for everybody who likes that as much as I do, I share my final script. It's not intended to be an example or that sort of things, because other people can do that a lot better then me, because they are really good in scripting (heads off to them

).
Re: Need assistance for script Mechanical Ventilation
Posted: Thursday 17 October 2019 15:24
by freijn
Ok Marc, understood.
What I do love in my script is the ability to adapt when the next shower is going to happen in the "cooldown" period of the previous shower.
i.e. there is some time between the showers and huminity has not come to the starting level. The next shower starts and huminity goes up again.
The script takes the first starting value as a target and not the value at the start of the second shower. ( Me like

)