Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Scene that checks temperature and humidity


Question

Posted

Hi!

 

I was wondering if someone could help me out with a scene that checks, maybe 4 times a day, if the absolute humidity outdoors is lower than indoors and if so to switch on a wall plug that powers a fan and then switch off again after an hour? I have a netatmo device outside and inside added to my HC2.

 

If working out the absolute humidity based on temp and relative humidity is complicated, I could try a scene that powers on the fan if temp and relative humidity is lower outside than inside.

 

Any help would be most appreciated as I have no LUA skills. Have used block scenes quite a bit though.

 

Thanks!

16 answers to this question

Recommended Posts

  • 0
Posted

Look here for ideas and algoritme:

 

 

  • 0
  • Inquirer
  • Posted
    On 3/5/2021 at 5:08 PM, SmartHomeEddy said:

    Look here for ideas and algoritme:

     

     

    Thanks for your reply! Its probably more advanced than I need and since my level of LUA-knowledge is next to nothing, I would need to start of with something a lot simpler, like (I don't know proper syntax, sorry :) ):

     

    if between 13:00 and 19:00, then run every 2 hours

     

    if absolute humidity outside < absolute humidity inside, then

     

    switch on wall plug, then

    switch off wall plug after 60 minutes.

     

    I've used block scenes quite a bit, but since I can't compare values from two devices (like the indoor and outdoor temperature and humidity values) and certainly can't convert temperature and relative humidity into absolute humidity, it won't work.

     

     

    • 0
    Posted

    So you already have devices that measures absolute humidity?

    • 0
  • Inquirer
  • Posted
    1 hour ago, SmartHomeEddy said:

    So you already have devices that measures absolute humidity?

    I have the Netatmo weather station added to my HC2, so I get the temp and relative humidity outside and inside.

    • 0
    Posted

    To compare humidity levels, you need absolute humidity, not relative humidity. Temperature plays a big part. 

    • Like 1
    • 0
  • Inquirer
  • Posted
    22 minutes ago, SmartHomeEddy said:

    To compare humidity levels, you need absolute humidity, not relative humidity. Temperature plays a big part. 

    Yes, I know. That's why I thought it could be done by using temp and RH to get approx absolute humidity and then compare those for outside and inside.

    • 0
    Posted

    I only have a setup for the HC3, not the HC2.

     

    I think you need a VD to generate the absolute humidity (with the algoritme in the other post). And then a script (or VD) to compare the values and turn on the wall plug. 

    • 0
    Posted

    @Ole

     

    Have you looked at the script in the other post?

     

    On 8/28/2020 at 12:52 PM, muhmuh said:

    I found a HC2 Script from kapitano1 (https://forum.siio.de/t/lua-taupunktlueftung-im-keller/5206)

     

     

    This one:

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted
    6 hours ago, SmartHomeEddy said:

    @Ole

     

    Have you looked at the script in the other post?

     

     

     

    This one:

     

    Please login or register to see this code.

     

    Hi! Thanks for sticking with me! :) I had just googled my way to a absolute humidity formula, but haven't gotten any further than that, so far. This looks great though! I will have a look at it today and let you know how I get on. Thanks again.

    • 0
    Posted

    Goodluck

     

    The formula is there. If you replace the device ID's (in fibaro:getValue) with yours, you will have a working scene. If you don't have air pressure, you can replace is with the average air pressure 1013 (inside and outside will always be almost the same). 

     

    After that, you can change the action after the value check. 

    • 0
  • Inquirer
  • Posted (edited)
    22 hours ago, SmartHomeEddy said:

    Goodluck

     

    The formula is there. If you replace the device ID's (in fibaro:getValue) with yours, you will have a working scene. If you don't have air pressure, you can replace is with the average air pressure 1013 (inside and outside will always be almost the same). 

     

    After that, you can change the action after the value check. 

    It works like a charm! I added the action that starts the fan and stops it after 60 minutes. Now I only need to ad the code that runs the script every two hours between 13:00 and 19:00 without breaking it :)

    Edited by Ole
    • 0
    Posted

    I'm not that into HC2, I think something like this in the top top the code?

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    Hi! (I apologise for my total lack of LUA know-how and I have created the time trigger using block scenes and changed to lua.)

     

    Can someone help me find out why this code doesn't run at the set intervals 13:00, 15:00, 17:00 and 19:00? If I run the code manually it works.

     

    Thanks!

     

    --[[
    %% autostart
    %% properties
    %% weather
    %% events
    %% globals
    --]]

    local sourceTrigger = fibaro:getSourceTrigger();
    function tempFunc()
    local currentDate = os.date("*t");
    local startSource = fibaro:getSourceTrigger();
    if (
     ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "13:00")  or  ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "15:00")  or  ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "17:00")  or  ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "19:00") )
    )
    then
    end

    setTimeout(tempFunc, 60*1000)
    end
    if (sourceTrigger["type"] == "autostart") then
    tempFunc()
    else
    end

    local currentDate = os.date("*t");
    local startSource = fibaro:getSourceTrigger();
    if (
    startSource["type"] == "other"
    )
    then
    end

    local date       = os.date("%d.%m.%Y %H:%M:%S", os.time())
    local message

    local EXP      = tonumber("2.71828182845904523536028747135266249775724709369995")
    local pressure = fibaro:getValue(735, "value") -- Lufttrykk
    local tempOut  = fibaro:getValue(761, "value") -- Temperatur Ute
    local humidOut = fibaro:getValue(762, "value") -- Luftfuktighet Ute

    local tempIn   = fibaro:getValue(764, "value") -- Temperatur Loft
    local humidIn  = fibaro:getValue(765, "value") -- Luftfuktighet Loft

    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    -- DEBUG
    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    -- Grundfunktion: Debug("red", "Nachrichtentext")
    Debug = function(color, message)
      if (debuging) then
        fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
      end
    end

    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    -- Value Outside
    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    local I1 = tonumber(tempOut)  -- Temperatur (in °C)
    local I2 = tonumber(humidOut) -- Relativ Luftfuktighet (in %)
    local I3 = tonumber(pressure) -- Lufttrykk (in Millibar)

          message = " - " ..date .. " Temperatur ute " ..tempOut .. "°C Relativ luftfuktighet ute " ..humidOut.. "%"
          fibaro:debug(message)

    local humidOutAbs = 0.622 * I2/100 * (1.01325 * 10^(5.426651 - 2005.1 / (I1 + 273.15) + 0.00013869 * ((I1 + 273.15) * (I1 + 273.15) - 293700) / (I1 + 273.15) * (10^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - I1)^1.25))) + (((I1 + 273.15) / 647.3) - 0.422) * (0.577 - ((I1 + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) * 0.00980665) / (I3/1000 - I2/100 * (1.01325 * 10^(5.426651 - 2005.1 / (I1 + 273.15) + 0.00013869 * ((I1 + 273.15) * (I1 + 273.15) - 293700) / (I1 + 273.15) * (10^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - I1)^1.25))) + (((I1 + 273.15) / 647.3) - 0.422) * (0.577 - ((I1 + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) * 0.00980665)) * I3/1000 * 100000000 / ((I1 + 273.15) * 287.1)
          message = " - " ..date .. " Absolutt luftfuktighet ute " ..humidOutAbs.. "g/m³"
          fibaro:debug(message)

    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    -- Value Inside
    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    local I1 = tonumber(tempIn)  -- Temperatur (in °C)
    local I2 = tonumber(humidIn) -- Relativ Luftfuktighet (in %)

          message = " - " ..date .. " Temperatur inne " ..tempIn .. "°C Relativ luftfuktighet inne " ..humidIn.. "%"
          fibaro:debug(message)

    local humidInAbs = 0.622 * I2/100 * (1.01325 * 10^(5.426651 - 2005.1 / (I1 + 273.15) + 0.00013869 * ((I1 + 273.15) * (I1 + 273.15) - 293700) / (I1 + 273.15) * (10^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - I1)^1.25))) + (((I1 + 273.15) / 647.3) - 0.422) * (0.577 - ((I1 + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) * 0.00980665) / (I3/1000 - I2/100 * (1.01325 * 10^(5.426651 - 2005.1 / (I1 + 273.15) + 0.00013869 * ((I1 + 273.15) * (I1 + 273.15) - 293700) / (I1 + 273.15) * (10^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - I1)^1.25))) + (((I1 + 273.15) / 647.3) - 0.422) * (0.577 - ((I1 + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((I1 + 273.15) * (I1 + 273.15) - 293700) * ((I1 + 273.15) * (I1 + 273.15) - 293700)) * 0.00980665)) * I3/1000 * 100000000 / ((I1 + 273.15) * 287.1)
          message = " - " ..date .. " Absolutt luftfuktighet inne " ..humidInAbs.. "g/m³"
          fibaro:debug(message)

    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    -- Check Values
    -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if (humidInAbs > humidOutAbs) then
        fibaro:call(713, "turnOn");
        setTimeout(function()
            fibaro:call(713, "turnOff");
        end, 3600000)
    end

    • 0
    Posted

    in your code you could loose the weekday question, because the if statement has all the days of the week, 1 to 7. And the if doesn’t, because after “then” there is a “end”. So no action between then and end
     

    Look here for ideas:

     

    for example:

     

    Please login or register to see this code.


    or something with >= 

     

    (btw my script runs 24h a day. If the absolute humidity in the bathroom is 2 grams/m3 higher then the absolute humidity in my livingroom, set fan to level 2. And if it is 3 grams/m3 higher turn fan to level 3. I see no reason to check on fixed times.)
     

     

     

    • 0
  • Inquirer
  • Posted
    18 hours ago, SmartHomeEddy said:

    in your code you could loose the weekday question, because the if statement has all the days of the week, 1 to 7. And the if doesn’t, because after “then” there is a “end”. So no action between then and end
     

    Look here for ideas:

     

    for example:

     

    Please login or register to see this code.


    or something with >= 

     

    (btw my script runs 24h a day. If the absolute humidity in the bathroom is 2 grams/m3 higher then the absolute humidity in my livingroom, set fan to level 2. And if it is 3 grams/m3 higher turn fan to level 3. I see no reason to check on fixed times.)
     

     

     

    Hi! Using Timer seems to work well, thanks. Now to mount the fan and see if it does the job.

     

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...