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
}