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

  • Topic Author
  • 6 hours ago, lux said:

    @jgab 

    Ok, it seems to be the same QA functions as on the HC3. 

     

    You see that math.maxinteger on the HCL  is 

    2147483647

    on the HC3 math.maxinteger is 

    9223372036854775807

    os.time() these days are ~

    1668672244

    So the problem is that when we do arithmetic on time we sometimes created (temporary) values larger than HCL math.maxinteger which gets truncated and create bugs. If one would be extremely careful one could probably find all these and make sure the math doesn't break, but in ER4 it's too much.

     

    Also, recently some people tried to create a millisecond timestamp by adding os.clock to os.time (for export to some database) and of course that didn't work on the HCL either...

     

    I guess choosing 32bit ints were to try to save some space on the HCL, but I wonder if breaking the QA compatibility between HC3 and HCL was worth it...

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

    @jgab Thank you ! This will take too much time and effort. I think it is reasonable to choose HC3,HC3_L only add devices is a good idear!
     2022/11/18 01:40 it's new ext: But It can't  kill(apa1)

    rule("lamps1={23,24,25,26}"
    rule("keyfob:central =>  post(#keyfob{value=keyfob:central.keyAttribute++keyfob:central.keyId})")
     
    rule("#keyfob{value='Pressed1'} =>  post(#foo1) ")
    rule("#keyfob{value='Pressed2'} =>  post(#foo2) ")
    rule("#keyfob{value='Pressed3'} =>  kill(apa1)")
    rule("#keyfob{value='Pressed4'} =>  kill(apa2)")
    time = 1
    apa1 = rule("#foo1 =>  for _,light in ipairs(lamps1) do if light:isOn then hub.call(light, 'turnOff') end end")
    apa2 = rule("#foo2 => for _,light in ipairs(lamps1) do if light:isOff then hub.call(light, 'turnOn') end end")
    Thank you!
     
    2022/11/18 2:25
    platform:hc3l    i user wait() now it's ok!
    rule("lamps1={23,24,25,26}"
     --电梯厅test
    rule("keyfob:central =>  post(#keyfob{value=keyfob:central.keyAttribute++keyfob:central.keyId})")
     
    rule("#keyfob{value='Pressed1'} =>  post(#foo1) ")
    rule("#keyfob{value='Pressed2'} =>  post(#foo2) ")
    rule("#keyfob{value='Pressed3'} =>  kill(apa1)")
    rule("#keyfob{value='Pressed4'} =>  kill(apa2)")
     
    apa1 = rule([[#foo1 => for _,light in ipairs(lamps1) do if light:isOn then wait(00:00:02) ; hub.call(light, 'turnOff'end end ]])
    apa2 = rule([[#foo2 => for _,light in ipairs(lamps1) do if light:isOff then wait(00:00:02) ;hub.call(light, 'turnOn'end end ]])

     
    Edited by lux
    Link to comment
    Share on other sites

    Hi guys , i need your help

    i have rules turning cabinet lamp when cabinet door is open

    Please login or register to see this code.

    i created another  roles for this lamp when all lights are off and there is a movement on stairs then the lamp should be on for a minute?

    Please login or register to see this code.

    those roles was moved from HC2 ER3 to HC3 ER4 , and the result of it is blinking lamp, tuning on and off in a loop when there is a movement on stairs , how to solve it ? 

    thnx

     

    Link to comment
    Share on other sites

  • Topic Author
  • I pushed v0.91.

     

    It has a better 'kill' instruction that I have played around with and think is pretty useful....

    What the instruction does is that it stops/kills a rule that is in wait state. It also cancels all posts that has be done and not yet been delivered.

    Ex.

    rule("#foo => log('A'); wait(4); log('B')")

    This will log A and wait 4s and log B.

    If we do 

    rule("post(#foo); wait(1); post(#foo)")

    we will run the rule twice in "parallel" causing the output

    A

    A

    B

    B

    What if we wanted the first invokation of the rule be cancelled when we invoke it the second time?

    The kill instruction will "reset" the rule for us, terminating the rule if it is in a wait state and also cancel all posts that has not been delivered.

    rule("#foo => kill(); log('A'); wait(4); log('B')")

    This will log A and wait 4s and log B.

    If we do 

    rule("post(#foo); wait(1); post(#foo)")

    we will now get

    A

    A

    B

    The first invokation of the rule is cancelled when the second is triggered. It will log the first A but then terminate.

     

    kill can take an argument, being the rule it wants to kill.

    a = rule("#foo => log('A'); wait(5); log('B')")

    rule("post(#foo); wait(1); kill(a)")

    It's a bit trickier to use this version, but sometimes it can be useful.

     

    It simplifies some rules

    rule("sensor:breached => kill(); lamp:on; wait(00:05); lamp:off")

    This rule will turn on a lamp when sensor is breached, and wait 5min and then turn off the lamp

    If the sensor is breached again, the rule will be invoked and kill any previous version of the rule waiting it's 5min,

    effectively restart the 5min period before turning off the lamp.

     

    The same with a post also works

    rule("sensor:breached => kill(); lamp:on; post(#lampOff,00:05)")

    rule("#lampOff => lamp:off")

     

     

     

    • Like 1
    Link to comment
    Share on other sites

    Jan, what am  I doing wrong?

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    @jgabGreat .I will continue to test and use it for the project with 'kill' .

    platform:HC3/HC3L
    eventrun file :downlodad The newest file on github.com
    eventrun version:
    EventRunner4 v0.9 N/A
    updatetime:2022/11/18  15:28

    when i test on "ZeroBrane Studio Lua IDE" ,rule work no problem!
    when i upload to HC3/HC3L ,other rule no problem,but <post()> looks like not run!

    Please login or register to see this code.

    Please login or register to see this image.

    /applications/core/interface/file/attachment.php?id=50935&key=6069dd35957707759e74e7216901926e" />

    debug:

    Please login or register to see this attachment.

    Edited by lux
    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, Sjakie said:

    Jan, what am  I doing wrong?

    Please login or register to see this code.

     

    It's my bug.

    I'll upload a fix tonight.

    If you want to patch it go into the EventRunner file in QA and change line 383

      self.dateTest = fibaro.utils.dateTest

    to

      self.dateTest = fibaro.dateTest

     

    5 hours ago, lux said:

    @jgabGreat .I will continue to test and use it for the project with 'kill' .

    platform:HC3/HC3L
    eventrun file :downlodad The newest file on github.com
    eventrun version:
    EventRunner4 v0.9 N/A
    updatetime:2022/11/18  15:28

    when i test on "ZeroBrane Studio Lua IDE" ,rule work no problem!
    when i upload to HC3/HC3L ,other rule no problem,but <post()> looks like not run!

    Please login or register to see this code.

    Please login or register to see this link.

    debug:

    Please login or register to see this attachment.

    I will check it tonight, when I'm back and have access to my HC3.

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, lux said:

    @杰加布 Ok !Thank you !

    Actually, I just uploaded 0.92 with the bug fix.

    I had managed to introduce a bug in 'post' that was only visible on the HC3 - hope to have fixed it now.

    The wday fix is also there. 

    • Like 1
    Link to comment
    Share on other sites

    28 minutes ago, jgab said:

    Actually, I just uploaded 0.92 with the bug fix.

    I had managed to introduce a bug in 'post' that was only visible on the HC3 - hope to have fixed it now.

    The wday fix is also there. 

    Now it (kill())work ok:)

    I will continue to follow up ! Thank you!
    As you said, it's easy to use
    @jgab

    Edited by lux
    Link to comment
    Share on other sites

  • Topic Author
  • 28 minutes ago, lux said:

    Now it (kill())work ok:)

    I will continue to follow up ! Thank you!
    As you said, it's easy to use
    @jgab

    Yes, I'm not sure 'kill' is a good name - maybe 'reset' ?

    Link to comment
    Share on other sites

    15 minutes ago, jgab said:

    Yes, I'm not sure 'kill' is a good name - maybe 'reset' ?

    How about “cover” ?Kill looks easy to understand ! Use the name you want !

    Edited by lux
    Link to comment
    Share on other sites

    Jan I need your advice for:

    $Energie_Counter_Week_( is an exciting GV value 01-53)

    Please login or register to see this code.

     

    How to do to fill in value for n automatically? 

    Thanks in advance!

    Edited by Sjakie
    Link to comment
    Share on other sites

  • Topic Author
  • Run it every midnight

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • On 11/17/2022 at 5:05 PM, domin12 said:

    Hi guys , i need your help

    i have rules turning cabinet lamp when cabinet door is open

    Please login or register to see this code.

    i created another  roles for this lamp when all lights are off and there is a movement on stairs then the lamp should be on for a minute?

    Please login or register to see this code.

    those roles was moved from HC2 ER3 to HC3 ER4 , and the result of it is blinking lamp, tuning on and off in a loop when there is a movement on stairs , how to solve it ? 

    thnx

     

    Without exactly understanding what is the problem I would recommend to move some of the device tests to the right side of "=>"

    All devices on the left hand side of the "=>" will trigger the rule if they change state. Often that is what we want but it may cause unintended effects too.

    In this case the cabinet lamp going on/off will trigger all rules.

    What if you do?

    Please login or register to see this code.

    Please login or register to see this code.

    Does it improve?

    Link to comment
    Share on other sites

    i think ther  is a problem whit the timers  This has workt before 

     

    ---- Tänder inte belysningen om det är mer än 18 lux 
    rule([[$Rum2_Dorr=='Open' & Rorelse_Rum2:breached & Lux_rum2:lux > 18 & $Rum2_auto_Tak=='Automatisk' & $Styrning=='On' => 
    log('Variabel Tak är Close Rum2 '); $Rum2_Dorr='Close';
    wait(00:00:03); log('Cassandra är nu Hemma'); $Cassandra='Hemma'
    log('Tänder inte belysningen i Rum2 Lux värdet är %s',Lux_rum2:lux)');
    ]])
     
     
    error 
    [2022-11-20] [15:06:11] [ERROR] [QUICKAPP936]: in Rule:240[$Rum2_Dorr=='Open' & Rorelse_Rum2:safe & $Rum2_auto_Tak=='Automatisk' & $Styrning=='On' => ...]: ./include/EventRunner.lua:1781: ./include/EventRunner.lua:1143: attempt to index a nil value (field 'timers')
    Link to comment
    Share on other sites

  • Topic Author
  • I’ll have a look at it…

    Link to comment
    Share on other sites

  • Topic Author
  • 48 minutes ago, Sjakie said:

    I just had the same error and I found one of the triggers was zero!

    What do you mean with zero?

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