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


Recommended Posts

Posted (edited)
21 minutes ago, Neo Andersson said:

 

 

Please login or register to see this code.

 

Please login or register to see this code.

 

 

@Neo AnderssonJust for inspiration

I set the HTTab from a Scene - and when run, its added to a global variable,

   

           ....

                Motion      = {1122},
                },
        guidelight = {
                Windows     = {35, 1002},
                Doors       = {33, 1000},
                alarm       = {155,1182},
                },
        }


fibaro.setGlobalVariable("HTab",json.encode(HTab))
fibaro.debug(tag,json.encode(HTab))$

 

And read it in main like this.


    local HT = json.decode((fibaro.getGlobalVariable("HTab")))

    er.defvars(HT)
    er.reverseMapDef(HT)

I also have a rule - detecting if the global var has been updated

Please login or register to see this code.

 

so every time my scene is updated and saved, Eventtunner, restarts with the new variables

 

 

21 minutes ago, Neo Andersson said:

 

 

Edited by ChristianSogaard
Typo
Posted
22 minutes ago, Neo Andersson said:

 

 

Please login or register to see this code.

 

Please login or register to see this code.

 

 

 

Jan, i also noticed a bit strange starting time. In ER4, that is still running on my customers's systems, when I made a change and saved the ER4, in debug window i could see immediatelly all the setup stuff, and definitions debugged.

In ER5 after a save, I see the orange bar immediatelly, but after that it takes around 6 second while i see the first rule definitions debugged.

  • Topic Author
  • Posted
    1 hour ago, Neo Andersson said:

    Jan, i also noticed a bit strange starting time. In ER4, that is still running on my customers's systems, when I made a change and saved the ER4, in debug window i could see immediatelly all the setup stuff, and definitions debugged.

    In ER5 after a save, I see the orange bar immediatelly, but after that it takes around 6 second while i see the first rule definitions debugged.

    Yes, there is some unoptimised code that calls api.get("/devices") twice at startup - If you have many devices it can take some time - but 6s is long are you doing other http/api calls in your setup?. (it will be optimised in next version and will read devices on-demand instead)
    Is 6s also the time reported in the second orange bar?, "Rules setup time - reported under ER<ID> tag in console ? (it's a bug, should be under user tag like the first bar)

    Posted

    Hi, I am trying to use a s2 input from a Heatit zm dimmer: 

    Please login or register to see this link.

     

    When I use a Dimmer 2 with scene id 20 it works greath.

     

    But as I see in when using it in scenes it is diffrent from the Dimmer 2:

    {
          id = 1648,
          isTrigger = true,
          operator = "==",
          property = "centralSceneEvent",
          type = "device",
          value = {
            keyAttribute = "Released",
            keyId = 2                    --Heatit Dimmer
          }
        }, {
          id = 36,
          isTrigger = true,
          operator = "==",
          property = "sceneActivationEvent",
          type = "device",
          value = 20         --Dimmer 2
        } },
      operator = "any"
    }

     

    rule("dimmer2S2:scene == 20 => PirHeatit:on")
     rule("dimmer2S2:scene == 21 => PirHeatit:off")

    This rule work with dimmer 2.

     

    But I cant figure out how to use the Released and key id 2 in a rule? 

    any suggestions? :D 

     

     

     

     

     

     

  • Topic Author
  • Posted (edited)
    8 hours ago, Brors94 said:

    Hi, I am trying to use a s2 input from a Heatit zm dimmer: 

    Please login or register to see this link.

     

    When I use a Dimmer 2 with scene id 20 it works greath.

     

    But as I see in when using it in scenes it is diffrent from the Dimmer 2:

    {
          id = 1648,
          isTrigger = true,
          operator = "==",
          property = "centralSceneEvent",
          type = "device",
          value = {
            keyAttribute = "Released",
            keyId = 2                    --Heatit Dimmer
          }
        }, {
          id = 36,
          isTrigger = true,
          operator = "==",
          property = "sceneActivationEvent",
          type = "device",
          value = 20         --Dimmer 2
        } },
      operator = "any"
    }

     

    rule("dimmer2S2:scene == 20 => PirHeatit:on")
     rule("dimmer2S2:scene == 21 => PirHeatit:off")

    This rule work with dimmer 2.

     

    But I cant figure out how to use the Released and key id 2 in a rule? 

    any suggestions? :D 

     

    Please login or register to see this code.

     

    See this post

     

    Edited by jgab
    • Thanks 1
  • Topic Author
  • Posted

    v0.35 pushed - bug fixes and some optimisations...

    Posted

    Jan how to write?

    Please login or register to see this code.

     

    Posted
    10 hours ago, jgab said:

    Yes, there is some unoptimised code that calls api.get("/devices") twice at startup - If you have many devices it can take some time - but 6s is long are you doing other http/api calls in your setup?. (it will be optimised in next version and will read devices on-demand instead)
    Is 6s also the time reported in the second orange bar?, "Rules setup time - reported under ER<ID> tag in console ? (it's a bug, should be under user tag like the first bar)

    No, in the second orange bar it shows very fast..0.38ms, however, the second orange bar appears after 6 sec. It doesn't bother me, i just want to help you to find any hiding bugs or wathever..

    BTW, regarding my previous problems about HT table not accessable as an argument...After several tests i can confirm. Whatever i do, wherever i define my custome function, if i want to send HT table as an argument to my custom function it will be always nil. On the other hand, if i use HT table direclty inside my custome function, then it works.

     

    Please login or register to see this code.

     

    Posted
    20 hours ago, ChristianSogaard said:

    This EV5 Alarm rule works perf.

    Please login or register to see this code.

    My old EV4 rule was a little optimised compared with one above, it could tell what sensor in what room that was breached. And i could send that as a message the the Phone or to SONOS speaker.

    I tried migrating the message part, but its not triviel to me, how to do in EV5?

     

    Please login or register to see this code.

     

    Jan - would it be possible that you convert this rule for me?  - i have 3-4 rules like this. And when converted, i can decomission EV4 - and run full on EV5..

  • Topic Author
  • Posted
    14 minutes ago, Neo Andersson said:

    No, in the second orange bar it shows very fast..0.38ms, however, the second orange bar appears after 6 sec. It doesn't bother me, i just want to help you to find any hiding bugs or wathever..

    BTW, regarding my previous problems about HT table not accessable as an argument...After several tests i can confirm. Whatever i do, wherever i define my custome function, if i want to send HT table as an argument to my custom function it will be always nil. On the other hand, if i use HT table direclty inside my custome function, then it works.

     

    Please login or register to see this code.

     

    The time reported is os.clock(), which is the cpu time used.

    This means that 6.0 - 0.38ms is spent hanging in api calls (you don't do any fibaro.sleep() do you?).

    Have you tried v0.35 where I removed the api.get("/devices") at startup that probably takes some time if there are a lot of devices...?

    Posted
    1 minute ago, jgab said:

    This means that 6.0 - 0.38ms is spent hanging in api calls (you don't do any fibaro.sleep() do you?).

    Have you tried v0.35 where I removed the api.get("/devices") at startup that probably takes some time if there are a lot of devices...?

    No i dont do any sleep / i didn't even know that sleep function still exists :-)

    No i haven't tried 0.35. will try today

  • Topic Author
  • Posted (edited)
    1 hour ago, ChristianSogaard said:

    Jan - would it be possible that you convert this rule for me?  - i have 3-4 rules like this. And when converted, i can decomission EV4 - and run full on EV5..

     

    Try this

    Please login or register to see this code.

    We ignore the partition id's and just collect all breached devices in the table 'devs'.

    We then iterate overt he deviceIds and create info about them (id, name, room) 

    and lastly we concatenate it all together.

    Now it just logs (warning) the message 'msg' - you can send the string as a msg to a user also.

    Note, that you may need to change the html break to a "\n" character for it to break in a push message.

     

    It needs v0.35 because I added table.append() to that version.

    Edited by jgab
    • Thanks 1
  • Topic Author
  • Posted (edited)
    2 hours ago, Sjakie said:

    Jan how to write?

    Please login or register to see this code.

     

     

    Please login or register to see this code.

    If summer_daytime is not a triggerVar you can  do

    Please login or register to see this code.

    If summer_daytime is a triggerVar you can't assign it a value on the left side of the '=>', but you can use a temp and do

    Please login or register to see this code.

    The reason why we still want the interval sunrine+00:30..sunset-00:30 on the left side is that we want the rule to trigger on those intervals.

     

    Don't forget to add .start() so it is set at startup/restart.

    Edited by jgab
    Posted (edited)
    3 hours ago, jgab said:

     

    Try this

    Please login or register to see this code.

    Now it just logs (warning) the message 'msg' - you can send the string as a msg to a user also.

     

    It needs v0.35 because I added table.append() to that version.

    Thank you Jan 

    Almost there :-)

    I need to filter out doublets - in below case there is 3 alarm zones -  and i get messages from both Partition 1+2  because they have overlapping sensors.

     

      

    Please login or register to see this code.

    image.png.c3c2f6bbbc1ce0945239fdaf850075d2.png

    Please login or register to see this attachment.

    Edited by ChristianSogaard
    Typo
    Posted (edited)

    @ChristianSogaardsplit in alarmzone X in your case 1,2,3 than automaticaly you get only that partition

     

    Please login or register to see this code.

    How to pass the year?

    Edited by Sjakie
    Posted

    Jan, hello

    Is there any change in ||>> pattern?

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)
    1 hour ago, Neo Andersson said:

    Jan, hello

    Is there any change in ||>> pattern?

     

    Please login or register to see this code.

     

    ||>> is a chained if-then-elseif, so it looks for the first condition that is true and skips the rest. if senzor1:breached then it will skip all the other tests, and do the log after ;;

     

    You want to so something like?

    Please login or register to see this code.

     

    Alt. (and much faster)

    Please login or register to see this code.

     

    Edited by jgab
    Posted (edited)
    38 minutes ago, jgab said:

    Please login or register to see this code.

    Jan we tried this, as i wrote you. This doesnt work. Throws error.

     

    Parser: missing first argument for ; ||

    Edited by Neo Andersson
    Posted (edited)

    Jan, please, i am struggling like a day with  getting a linebreak into a push message text.

    This never works

     

    Please login or register to see this code.

     

    This always prints out \n as a regual string.



    But  this works

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)
    2 hours ago, Neo Andersson said:

    Jan, please, i am struggling like a day with  getting a linebreak into a push message text.

    This never works

     

    Please login or register to see this code.

     

    This always prints out \n as a regual string.



    But  this works

     

    Please login or register to see this code.

     

     

    pushed v0.36

     

    Ok, the ';;' was a bug - I thought I fixed that weeks ago but somehow it was reverted to the old code... Now it should work.

     

    The newline I can't see whats' wrong. Strange that it works in rule("....=> text1 ++ '\n' ++ text2") but not the with the simplePush...

    I will try to look into it...

    Edited by jgab

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