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



jgab

Recommended Posts

Hi guys.
I have such a rule and it works. The first rule turns on the boiler when the condition is that the temperature in the room is lower than on the radiator. The second condition switches off the boiler if it is warmer in all rooms than is required on the radiators. The hysteresis is set to one degree.

 

How could the writing of these rules be simplified?

 

 rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Kancel_hlavica_:heatingThermostatSetpoint > (_Kancel_Temperature:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v KANCELÁRII sú:Teplo v izbe=%s %s %s',_Kancel_Temperature:value,'Teplo požadované=',_Kancel_hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_WC_dielna_Hlavice_:heatingThermostatSetpoint > (_WC_dielna_Temperature:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty vo WC DIELNA sú:Teplo v izbe=%s %s %s',_WC_dielna_Temperature:value,'Teplo požadované=',_WC_dielna_Hlavice_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Dielna_hlavica_:heatingThermostatSetpoint > (_Dielna_Hlavica_Temp:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v DIELNI sú:Teplo v izbe=%s %s %s',_Dielna_Hlavica_Temp:value,'Teplo požadované=',_Dielna_hlavica_:heatingThermostatSetpoint)") 
    rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Detska_Hlavica1_:heatingThermostatSetpoint > (_Detska_Hlavica1_Temp_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v RIKO 1 sú:Teplo v izbe=%s %s %s',_Detska_Hlavica1_Temp_:value,'Teplo požadované=',_Detska_Hlavica1_:heatingThermostatSetpoint)") 
    rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Detska_Hlavica2_:heatingThermostatSetpoint > (_Detska_Hlavica2_Temp_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v RIKO 2 sú:Teplo v izbe=%s %s %s',_Detska_Hlavica2_Temp_:value,'Teplo požadované=',_Detska_Hlavica2_:heatingThermostatSetpoint)") 
    rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Obyvak_Hlavica_:heatingThermostatSetpoint > (_Obyvak_Temperature:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v OBYVACKE sú:Teplo v izbe=%s %s %s',_Obyvak_Temperature:value,'Teplo požadované=',_Obyvak_Hlavica_:heatingThermostatSetpoint)")
     rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Mala_obyv_Hlavica_:heatingThermostatSetpoint > (_Mala_obyv_Temp:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v MALEJ OBYVACKE sú:Teplo v izbe=%s %s %s',_Mala_obyv_Temp:value,'Teplo požadované=',_Mala_obyv_Hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Obyvak_chodba_Hlavica_:heatingThermostatSetpoint > (_Obyvak_chodba_Temperature:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v OBYVAK CHODBA sú:Teplo v izbe=%s %s %s',_Obyvak_chodba_Temperature:value,'Teplo požadované=',_Obyvak_chodba_Hlavica_:heatingThermostatSetpoint)")
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Kuchyna_Hlavice_:heatingThermostatSetpoint > (_Kuchyna_Temp_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v KUCHYNI sú:Teplo v izbe=%s %s %s',_Kuchyna_Temp_:value,'Teplo požadované=',_Kuchyna_Hlavice_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Sasi_Hlavica_:heatingThermostatSetpoint > (_Sasi_Temp_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v HOSTOVSKEJ sú:Teplo v izbe=%s %s %s',_Sasi_Temp_:value,'Teplo požadované=',_Sasi_Hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_Spalna_hlavica_:heatingThermostatSetpoint > (_Spalna_Temp_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v SPALNI sú:Teplo v izbe=%s %s %s',_Spalna_Temp_:value,'Teplo požadované=',_Spalna_hlavica_:heatingThermostatSetpoint)") 
 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_D_Obyvak_Hlavica_:heatingThermostatSetpoint > (_D_Obyvak_Temp:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v D.OBYVAK sú:Teplo v izbe=%s %s %s',_D_Obyvak_Temp:value,'Teplo požadované=',_D_Obyvak_Hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_D_Kuchyna_hlavica_:heatingThermostatSetpoint > (_D_Kuchyna_Temp:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v D.KUCHYNA sú:Teplo v izbe=%s %s %s',_D_Kuchyna_Temp:value,'Teplo požadované=',_D_Kuchyna_hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_D_Spalna_Hlavica_:heatingThermostatSetpoint > (_D_Spalna_Hlavica_Tem_:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v D.SPALNI sú:Teplo v izbe=%s %s %s',_D_Spalna_Hlavica_Tem_:value,'Teplo požadované=',_D_Spalna_Hlavica_:heatingThermostatSetpoint)") 
  rule("@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) & (_D_Lili_Hlavica_:heatingThermostatSetpoint > (_D_Lili_Temp:value)) => _Kotol_:on; log('Zapínam kotol ********************Teploty v KANCELÁRII sú:Teplo v izbe=%s %s %s',_D_Lili_Temp:value,'Teplo požadované=',_D_Lili_Hlavica_:heatingThermostatSetpoint)") 
 
 rule("@@00:02:00 & (_Kancel_hlavica_:heatingThermostatSetpoint+1 <= (_Kancel_Temperature:value)) & (_WC_dielna_Hlavice_:heatingThermostatSetpoint+1 <= (_WC_dielna_Temperature:value)) & (_Dielna_hlavica_:heatingThermostatSetpoint+1 <= (_Dielna_Hlavica_Temp:value)) & (_Detska_Hlavica1_:heatingThermostatSetpoint+1 <= (_Detska_Hlavica1_Temp_:value)) & (_Detska_Hlavica2_:heatingThermostatSetpoint+1 <= (_Detska_Hlavica2_Temp_:value)) & (_Obyvak_Hlavica_:heatingThermostatSetpoint+1 <= (_Obyvak_Temperature:value)) & (_Mala_obyv_Hlavica_:heatingThermostatSetpoint+1 <= (_Mala_obyv_Temp:value)) & (_Obyvak_chodba_Hlavica_:heatingThermostatSetpoint+1 <= (_Obyvak_chodba_Temperature:value)) & (_Kuchyna_Hlavice_:heatingThermostatSetpoint+1 <= (_Kuchyna_Temp_:value)) & (_Sasi_Hlavica_:heatingThermostatSetpoint+1 <= (_Sasi_Temp_:value)) & (_Spalna_hlavica_:heatingThermostatSetpoint+1 <= (_Spalna_Temp_:value)) & (_D_Obyvak_Hlavica_:heatingThermostatSetpoint+1 <= (_D_Obyvak_Temp:value)) & (_D_Kuchyna_hlavica_:heatingThermostatSetpoint+1 <= (_D_Kuchyna_Temp:value)) & (_D_Spalna_Hlavica_:heatingThermostatSetpoint+1 <= (_D_Spalna_Hlavica_Tem_:value)) & (_D_Lili_Hlavica_:heatingThermostatSetpoint+1 <= (_D_Lili_Temp:value)) => _Kotol_:off; log('Vypínam kotol ********************Teploty sú podla požiadaviek')")

 

Link to comment
Share on other sites

  • Topic Author
  • Maybe like this? 

    The logic is the same but we use the repeating patterns for the rules to condense it.

    It is a bit easier if you need to add or remove a sensor as they are all in the first table.

    I assume here that the name of the sensors are Lua variables as I put them in the Sensors table - if they come from somewhere else you need to adjust the code.

    Note that Lua variables used inside rules need to be global Lua variables ('Sensors' and 'H').

     

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    Hi.
    Thanks for the code.

    After chance, it gives me this error.

     

     

    [19.12.2021] [09:01:50] [DEBUG] [QUICKAPP441]: --------------------------------------------- Running  ---------------------------------------------[19.12.2021] [09:01:51] [DEBUG] [QUICKAPP441]: [true]>>'Rule:53[@@00:05:00 & (sum(PriemerTempVonku:temp)/size(PriemerTempVonku) <= 12) => post(#...]'[19.12.2021] [09:01:51] [DEBUG] [QUICKAPP441]: [true]>>'Rule:55[@@00:02:00 => post(#hysCheck{i=size(Sensors)})]'[19.12.2021] [09:01:51] [DEBUG] [QUICKAPP441]: [{"type":"tempCheck"}]>>'Rule:54[#tempCheck => ...]'[19.12.2021] [09:01:51] [ERROR] [QUICKAPP441]: in Rule:54[#tempCheck => ...]: {"msg":"Error executing instruction:'["%prop",1,"heatingThermostatSetpoint"]'","ERR":true,"err":"./include/EventRunner.lua:1799: bad deviceID 'nil' for '%prop' '1?'","src":"Rule:54[#tempCheck => ...]"}[19.12.2021] [09:01:51] [DEBUG] [QUICKAPP441]: [{"type":"hysCheck","i":"$i>0"}]>>'Rule:56[#hysCheck{i='$i>0'} =>...]'[19.12.2021] [09:01:51] [ERROR] [QUICKAPP441]: in Rule:56[#hysCheck{i='$i>0'} =>...]: {"msg":"Error executing instruction:'["%prop",1,"heatingThermostatSetpoint"]'","ERR":true,"err":"./include/EventRunner.lua:1799: bad deviceID 'nil' for '%prop' '1?'","src":"Rule:56[#hysCheck{i='$i>0'} =>...]"}

    Link to comment
    Share on other sites

  • Topic Author
  • There is some device name that is nil

    Add this after the Sensors = { ... declaration (pure Lua)

    to check the table.

     

    for i,t in pairs(Sensors) do

      if t[1]==nil then quickApp:warning("Row "..i.." t[1]==nil") end 

      if t[2]==nil then quickApp:warning("Row "..i.." t[2]==nil") end 

      if t[3]==nil then quickApp:warning("Row "..i.." t[3]==nil") end

    end

    Link to comment
    Share on other sites

    Hello,

    Until now, I used my QA to operate a Yamaha receiver, but found a better version on the French forum. I used the following rule to turn the device on / off:

     

    rule ([[swiatlopilotsalon: central.keyId == 2 & swiatlopilotsalon: central.keyAttribute == 'Pressed3' => salonhamaha: toggle
    ]])

     

    Unfortunately, it doesn't work with the new QA. I made it into:

     

    rule ([[swiatlopilotsalon: central.keyId == 2 & swiatlopilotsalon: central.keyAttribute == 'Pressed3' =>
        || salonyamaha: isOff >> salonyamaha: on
        || salonyamaha: isOn >> salonyamaha: off

     

    But I have this error:

    [19.12.2021] [15:17:38] [ERROR] [QUICKAPP453]: in Rule:8[swiatlopilotsalon:central.keyId==2 & swiatlopilotsalon:central.keyAttribute=='Pressed3' => ...]: ./include/EventRunner.lua:1949: ./include/EventRunner.lua:1467: attempt to compare number with nil

     

    Can you help me construct a new rule?

    Below are the functions that the new QA supports:

    • Dans le code LUA d'un QuickApp ou d'une Scène, utiliser la fonction fibaro.call() avec l'une des syntaxes suivantes :
      • fibaro.call(123, "turnOn")                      -- Power ON
      • fibaro.call(123, "turnOff")                     -- Power OFF
      • fibaro.call(123, "play")                        -- Lecture
      • fibaro.call(123, "pause")                       -- Pause
      • fibaro.call(123, "stop")                        -- Stop
      • fibaro.call(123, "prev")                        -- Précédent
      • fibaro.call(123, "next")                        -- Suivant
      • fibaro.call(123, "setVolume", 100)              -- Règle le volume audio au niveau spécifié (en pourcents : 0 à 100)
      • fibaro.call(123, "setVolume", "up")             -- Diminue le volume audio d'un pourcent
      • fibaro.call(123, "setVolume", "down")           -- Augmente le volume audio d'un pourcent
      • fibaro.call(123, "setMute", true)               -- Audio en sourdine
      • fibaro.call(123, "setMute", false)              -- Audio normal
      • fibaro.call(123, "setInput", "bluetooth")       -- Sélectionne une source (et allume automatiquement l'appareil si celui-ci est éteint)
      • fibaro.call(123, "setSoundProgram", "enhanced") -- Sélectionne un mode traitement audio DSP (si l'ampli le supporte)
      • fibaro.call(123, "setDialogueLevel", 1)         -- Sélectionne le niveau des voix (si l'ampli le supporte)
      • fibaro.call(123, "setSleep", 60)                -- Programme l'extinction automatique (en minutes : 0, 30, 60, 90, 120)
      • fibaro.call(123, "setDimmer", 2)                -- Règle le niveau d'intensité des LED (si l'appareil le supporte)
      • fibaro.call(123, "recallPreset",                -- Rappelle un favori préenregistré
    • Les propriétés suivantes peuvent être lues dans le JSON du module :
      • power           : boolean : true|false              -- Statut d'alimentation de l'appareil

      • state           : string  : ""|"play|"pause"|"stop" -- Statut du lecteur

      • volume          : integer : 0-100                   -- Volume audio

      • mute            : boolean : true|false              -- Silencieux audio

      • dead            : boolean : true|false              -- Appareil connecté/déconnecté du réseau

      • model           : string : "XXX"                    -- Référence de l'appareil

      • userDescription : string : "XXX"                    -- Pièce (zone) de l'appareil telle que paramétrée dans l'application mobile

    Link to comment
    Share on other sites

  • Topic Author
  • You could try

    Please login or register to see this code.

     

    • Thanks 1
    Link to comment
    Share on other sites

    Guest kallecux

    Now i can send a GET like this:

     

    http://Admin:[email protected]/api/customEvents/DoorbirdKlingeln/publish

     

    and can react in ER4 like this:

     

    rule("#custom-event{name='DoorbirdKlingeln'} => log('Es hat geklingelt')")

    Link to comment
    Share on other sites

    Jan, question:

    Is it possible to get a acurate sunset according longitude and latitude?

    Now I use a fixed correction for each month but it seems not acurate enough

    Thanks in advance,

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • 16 hours ago, Sjakie said:

    Jan, question:

    Is it possible to get a acurate sunset according longitude and latitude?

    Now I use a fixed correction for each month but it seems not acurate enough

    Thanks in advance,

    //Sjakie

    The calculation is the "standard" algorithm. The one the HC3 uses and the one I use in ER4 are very similar (I get the same values). It's also the same as @10der have posted in the past.

    So, when is it not accurate? and what values do you compare to?

    It does require that you have set the lat/long of your HC3 correctly as it uses that for calculations..

     

    • Like 1
    Link to comment
    Share on other sites

    Hi @jgab,

    I'm sorry if this has been asked before, but I now have looked through approx 500 posts i think and haven't found it yet..

    Is there a possibility to implement some kind of Presence simulation with EV4?

     

    I have tried using 10der's

    Please login or register to see this link.

    , but this conflicts with the rules in EV4 and therefor one QA turns on the lights and the other QA turns it off, resulting in flashing lights.. :-)

     

    What is the best/easiest way to make this work?

     

    Link to comment
    Share on other sites

    Jan, location is set in HC3. That I didt know, I am doing a correction by month.

    Okay I know its difficult itsnot always same % clouds either each day so I had the impression the time sunset is more a general calculated one.

    thanks for explanation,

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • On 12/26/2021 at 1:40 PM, Ace02 said:

    Hi @jgab,

    I'm sorry if this has been asked before, but I now have looked through approx 500 posts i think and haven't found it yet..

    Is there a possibility to implement some kind of Presence simulation with EV4?

     

    I have tried using 10der's

    Please login or register to see this link.

    , but this conflicts with the rules in EV4 and therefor one QA turns on the lights and the other QA turns it off, resulting in flashing lights.. :-)

     

    What is the best/easiest way to make this work?

     

     

    Well, it's difficult to have a separate presence QA/Scene as it easily conflicts with other automation rules. 

    It's possible to solve it in different ways using ER4 but one mechanism that is helpful is the SECTION directive.

    Please login or register to see this code.

     

    When setting fibaro.EM.SECTION to a string, that string will be used to label all rules defined afterwards. If set to nil it will not label rules.

     

    We cam then enable/disable rules  with the enable(<string>,<boolean>) command


     

    Please login or register to see this code.

     

    The first string is the section name, the second boolean if 'true' will  automatically disable all other labelled rules - so it works as a toggle. If 'false'  is  provided it will just enable/disable the section and leave the other labelled rules as is.

     

    We also start the rules in disabled state so that we can enable the right set of rules when we startup.

     

    This means that we can have our main rules  that toggle lights under a 'Home' section and the presence rules under a 'Away' section. We can do it even better by having a rules that trigger on profile changes and enables the right section.

    Please login or register to see this code.

     

    I have a set of rules that turns on/off lights automatically depending on time of day. I usually let these rules run as usual when we are away.

    There could also be a light that one wants to turn on/off Moree often when away and then just create a special rule for that light under the "Away" section.

    ex.

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

    HUE MAIN is saying HUE bridge starting ans it staus on that for hours max 85%

     

    [29.12.2021] [19:27:19] [DEBUG] [QA_HUE_MAIN_233]: [L] UpdateHue - temporary stopped bridge update: HagsenLights

    [29.12.2021] [19:27:24] [DEBUG] [QA_HUE_MAIN_233]: [L] UpdateHue - temporary stopped bridge update: HagsenLights

    [29.12.2021] [19:27:29] [DEBUG] [QA_HUE_MAIN_233]: [L] UpdateHue - temporary stopped bridge update: HagsenLights

    [29.12.2021] [19:27:34] [DEBUG] [QA_HUE_MAIN_233]: [L] UpdateHue - temporary stopped bridge update: HagsenLights

    Link to comment
    Share on other sites

    Jan,
    I am still obsessed by count the number off people in a room.

    This picture looks nice but should it work?
    Please if yes correct if I made some mistakes.
    Pir used to detect "n" person in room.
    Not the problem if you dont move the light will switch off.

    The number off persons in the apartment I like to do with Netatmo camera who has face recognition.

    Please login or register to see this code.

    Please add your valueable comment

    //Sjakie

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • You can't use '+1' etc. in that way. The way to write increments of GVs in rules would be

     

    Please login or register to see this code.

     

    However, I don't think this would work. Counting people entering rooms is *very* difficult.

    Much easier to just use some kind of 'no presence' detection for x minutes before turning off lights.

    Link to comment
    Share on other sites

    Jan, thanks. It was a idea to see if  this could be done. If possible my problem bathroom shoiuld be solved.

    No presence I dont use for living because I dont find it relaxed if light goes out if I read a book. I know I can set time longer but than the effect is gone. Perhaps I can try to add an extra pir.

    Thanks again,

    //Sjakie

     

     

    Link to comment
    Share on other sites

    Hi and thanks for a great script.

     

    I´m trying to make some rules like

     

    time =00:05:00

    rule("Motion:breached => Dimmer:on")
    rule("trueFor("..time..",Motion:safe) =>  Dimmer:off")
     
    but then i would like to overide the time to 30 min if lights was turned on manually and keep beieng postponed when breached and after the last 30 min has passed it shold revert back to 5min is this possible can i somehow use this with some timer or something.
     
    Thanks in advance. 

     

     

    Link to comment
    Share on other sites

    1 hour ago, Sjakie said:

    Jan, thanks. It was a idea to see if  this could be done. If possible my problem bathroom shoiuld be solved.

    No presence I dont use for living because I dont find it relaxed if light goes out if I read a book. I know I can set time longer but than the effect is gone. Perhaps I can try to add an extra pir.

    Thanks again,

    //Sjakie

     

     

    For presence counting you need 2 motion sensors, 1 outside the front door and one inside. If sensor2 triggers after sensor1 someone has entered the room, and if sensor 1 triggers after sensor2 someone has left the room. In LUA you can reproduce this well.

    Link to comment
    Share on other sites

    Jan, 

    I know perhaps it doest work but I read about person count with IR and that gave the following idea.

    One big room 3 PIr's, room devided into 3 parts.

    Pir1 kitchen

    pirA border

    pir3 living room

    Pir A is a barrier of 20-50 cm between both rooms.

    All 3 pir's doest overlap

    Please login or register to see this code.

    Can there be a kind of cascade or is this idea also not fail safe?

    Please your comment

    //Sjakie

    Link to comment
    Share on other sites

    @jgab

    sometimes I have error in ER4 (usually my or Fibaro mistake :) ) and I also have another QA that in case of any error send me message. ER4 doesn't generate "standard" error (event) so I can't catch it via my QA for errros.

    Is it possible to generate same event as "standard" error in QA or create new ER event that will be possible to use in ER ?

     

    Edited by petrkl12
    Link to comment
    Share on other sites

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...