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

@jgabJan what is this error? The code is working for me at home, but not on customers system. He has version 0.8 too

 

Please login or register to see this attachment.

 

 

--************************************************************************************************************
    --                                              CHILD DEVICE DEFINITIONS
    --************************************************************************************************************
 
    -- CHILD DEVICE DEFINITION
    rule("child('ID1','SHS Zwave list button','com.fibaro.binarySwitch')")
    rule("child('ID2','SHS Zigbee list button','com.fibaro.binarySwitch')")
    rule("child('ID3','SHS Create cloud backup','com.fibaro.binarySwitch')")
    rule("child('ID4','SHS Create local backup','com.fibaro.binarySwitch')")
    
    -- CREATING CHILD DEVICE FOR LISTING ZWAVE DEVICES
    rule("initChildren()")
    --1.
    rule("#UI{id=ID1,action='turnOn'} => ID1_D:updateProperty('value',true)")  -- Map turnOn action
    --2.
    rule("#UI{id=ID1,action='turnOff'} => ID1_D:updateProperty('value',false)"-- Map turnOff action
    --3.
    rule("ID1:isOn => shs.DeviceList('zwave'); wait(00:00:02);ID1_D:updateProperty('value',false) ")
 
    -- CREATING CHILD DEVICE FOR LISTING ZIGBEE DEVICES
    --4.
    rule("#UI{id=ID2,action='turnOn'} => ID2_D:updateProperty('value',true)")  -- Map turnOn action
    --5.
    rule("#UI{id=ID2,action='turnOff'} => ID2_D:updateProperty('value',false)"-- Map turnOff action
    --6.
    rule("ID2:isOn => shs.DeviceList('zigbee'); wait(00:00:02);ID2_D:updateProperty('value',false) ")   
 
    -- CREATING CLOUD BACKUP
    --7.
    rule("#UI{id=ID3,action='turnOn'} => ID3_D:updateProperty('value',true)")  -- Map turnOn action
    --8.
    rule("#UI{id=ID3,action='turnOff'} => ID3_D:updateProperty('value',false)"-- Map turnOff action
    --9.
    rule("ID3:isOn => checkBackupPossibilityAndCreateNew('remote'); wait(00:00:02);ID3_D:updateProperty('value',false) ")   
    
    -- CREATING LOCAL BACKUP
    --10.
    rule("#UI{id=ID4,action='turnOn'} => ID4_D:updateProperty('value',true)")  -- Map turnOn action
    --11.
    rule("#UI{id=ID4,action='turnOff'} => ID4_D:updateProperty('value',false)"-- Map turnOff action
    --12.
    rule("ID4:isOn => checkBackupPossibilityAndCreateNew('local'); wait(00:00:02);ID4_D:updateProperty('value',false) ")   
  • Topic Author
  • Posted
    18 hours ago, Neo Andersson said:

    @jgabJan what is this error? The code is working for me at home, but not on customers system. He has version 0.8 too

     

    Please login or register to see this attachment.

     

    What is the previous error(s) before the "for iterator". The problem seems to be that the children is not created (due to some earlier error) so when ER is looping (for iterator) over the children they don't exists and crash.

    So, the error I see is a follow up error of something that happened earlier in your time line...

  • Topic Author
  • Posted
    19 hours ago, Neo Andersson said:

    Jan, it is working for /backups endpoint, but it doesnt work for others, like the examples below, one for canCreateBackup 

     

    Please login or register to see this code.

    the example above returns empty data. I tried also with some header combinations but no success.

    Please login or register to see this attachment.

     

    Also tried to delete some backups , but no success. In old fashion way, with hardcoded credentials i used to use this for deletion. and its working

     

    Please login or register to see this code.

     

    Yes, you are right - there seems to be something buggy about it. /backups return correct, other returns "" with type html/text... and if called through api.get we get an internal json.decode error...

    Posted
    10 minutes ago, jgab said:

    What is the previous error(s) before the "for iterator". The problem seems to be that the children is not created (due to some earlier error) so when ER is looping (for iterator) over the children they don't exists and crash.

    So, the error I see is a follow up error of something that happened earlier in your time line...

    Upgraded to 0.84 and its working. Will check on it later.

    Posted
    On 12/11/2023 at 10:44 AM, jgab said:

    Well, your (virtual) deviceIds has nothing to do with userIds so you need a mapping table

    Please login or register to see this code.

     

    So, USER(name) is an existing function that returns the HC3 user with the name name. It returns the whole struct, like you get from swagger.

    Then we just retrieve the .id that is the user Id and map it to the virtual device id

    Please login or register to see this code.

    should then work...

     

    Actually, there is a small bug - but it will work in v0.82 coming later this afternoon.

     


     

    hi Jan

    I integrated the PeopleMap and it works in Rules with One person being detected like this,

    Please login or register to see this code.

     

    Having Rule returning more than one person at home - i cant see how to use the table

    I tried wrap it in like this, but no success

    Please login or register to see this code.

  • Topic Author
  • Posted (edited)

    Please login or register to see this code.

    elog is the "extended" log function that has some extra %specifiers, like %l that inserts a list of values without the '[' ']'...

    Edited by jgab
    • Thanks 1
    Posted (edited)
    8 hours ago, jgab said:

    Please login or register to see this code.

    elog is the "extended" log function that has some extra %specifiers, like %l that inserts a list of values without the '[' ']'...

    Got it - Thank you

    I made HouseIsEmpty  a triggerVar.

    used at this rule

    Please login or register to see this code.

    also tried 

    Please login or register to see this code.

    Very similary to the Rule you provided
    rule("@sunset & ask(1861,'Light automation', 'turn on X-mas tree?', 10) => xmastree:on")
     

     

    Rules:
    1:[Rule:1:People:isOff => log('House Is Empty...'); HouseIsEmpty = true --PeopleMap[LastPerson].id:msg=fmt('%s du har som den sidste person forladt hjemmeet',PeopleMap[LastPerson].name)] [enabled]
    2:[Rule:2:HouseIsEmpty & ask(LastPerson,'Vil du aktivere alarm?', 'Tryk yes at aktivere alarm?', 10) => 1:tryArm] [enabled]
     

    I am getting a crash when triggers - it looks that ask(LastPerson,'Vil du aktivere alarm?', 'Tryk yes at aktivere alarm?', 10)  causes the crash?

     

     [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:7:9]>> FALSE #device{id=2120,va.. -> People:isOn => log('People at Home usi..
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:2:5]>> suspended triggered - callback
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:4:13]>> FALSE #TV{HouseIsEmpty=t.. -> People:value:bin:sum == 1 & !HouseIsEm..
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:5:13]>> FALSE #TV{HouseIsEmpty=t.. -> People:value:bin:sum == 1 & HouseIsEmp..
    [17.12.2023] [16:25:38] [TRACE] [ER2059]: [Rule:2:5]>> FALSE #TV{HouseIsEmpty=t.. -> HouseIsEmpty & ask(LastPerson,'Vil du ..
    [17.12.2023] [16:25:38] [ERROR] [QUICKAPP2059]: QuickApp crashed
    [17.12.2023] [16:25:38] [ERROR] [QUICKAPP2059]: Unknown error occurred:
    [17.12.2023] [16:26:04] [DEBUG] [QUICKAPP2059]:
    EventRunner5, deviceId:2059, version:0.84
     

     

     

    Please login or register to see this code.

     

     

    Edited by ChristianSogaard
    Typo
    Posted

    @ChristianSogaard Is there a specific argument why you ask last person to arm the house instead of arming automatically when everybody left?

    Or are you using also Android phones?

     

    Posted
    1 hour ago, Sjakie said:

    @ChristianSogaard Is there a specific argument why you ask last person to arm the house instead of arming automatically when everybody left?

    Or are you using also Android phones?

     

     

    :-) good input @Sjakie 

    No special reason. I think i just like the Option to choose better.

     

    Posted

    Ok thanks. I do if everybody left automatic house will be armed. Problem of human is they forget or got distracted.

    Cheers

    Posted

    Are there issue with timers?

     

    Please login or register to see this code.

    [17.12.2023] [21:51:59] [TRACE] [ER2059]: [Rule:3]>> scheduling daily for 22:53:00
     

    17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> TRUE #UI{cmd="listTimer.. -> #UI{cmd='listTimers'} => listTimers()
    [17.12.2023] [21:52:12] [TRACE] [ER2059]:
    Timers:
    22:50:00 -> @[Rule:2]
    22:53:00 -> @[Rule:3]
    [17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> result [Rule:22:1]

     

    But it dont seems to trigger ?

    Posted

    @jgab something Fibaro?

    Please login or register to see this code.

    2-27 is executed 2-39 is listed here but happily not executed belongs to another part of an || rule.

    Weird it's traced

     

     

     

     

  • Topic Author
  • Posted
    1 hour ago, ChristianSogaard said:

    Are there issue with timers?

     

    Please login or register to see this code.

    [17.12.2023] [21:51:59] [TRACE] [ER2059]: [Rule:3]>> scheduling daily for 22:53:00
     

    17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> TRUE #UI{cmd="listTimer.. -> #UI{cmd='listTimers'} => listTimers()
    [17.12.2023] [21:52:12] [TRACE] [ER2059]:
    Timers:
    22:50:00 -> @[Rule:2]
    22:53:00 -> @[Rule:3]
    [17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> result [Rule:22:1]

     

    But it dont seems to trigger ?

    [17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> result [Rule:22:1]

    Your last log  says 21:52:12 but the rule was for 22:53:00

     

    1 hour ago, Sjakie said:

    @jgab something Fibaro?

    Please login or register to see this code.

    2-27 is executed 2-39 is listed here but happily not executed belongs to another part of an || rule.

    Weird it's traced

     

    You need to give me more info - listing of rules etc.

    • Like 1
    Posted

    Please login or register to see this code.

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted

    You end the rule with

    Please login or register to see this code.

    so the double ';;' ends the ||>> statements and the last statement (log) will always be run.

    • Like 1
    Posted
    9 hours ago, jgab said:

    [17.12.2023] [21:52:12] [TRACE] [ER2059]: [Rule:22:1]>> result [Rule:22:1]

    Your last log  says 21:52:12 but the rule was for 22:53:00

     

     

    You need to give me more info - listing of rules etc.

    That was  embarrassing - too tired or too fast i guess. I am sorry Jan

     

    What about this one

    Im pretty sure i didnt do any typos and tested a lot 

  • Topic Author
  • Posted
    17 hours ago, ChristianSogaard said:

    Got it - Thank you

    I made HouseIsEmpty  a triggerVar.

    used at this rule

    Please login or register to see this code.

    also tried 

    Please login or register to see this code.

    Very similary to the Rule you provided
    rule("@sunset & ask(1861,'Light automation', 'turn on X-mas tree?', 10) => xmastree:on")
     

     

    Rules:
    1:[Rule:1:People:isOff => log('House Is Empty...'); HouseIsEmpty = true --PeopleMap[LastPerson].id:msg=fmt('%s du har som den sidste person forladt hjemmeet',PeopleMap[LastPerson].name)] [enabled]
    2:[Rule:2:HouseIsEmpty & ask(LastPerson,'Vil du aktivere alarm?', 'Tryk yes at aktivere alarm?', 10) => 1:tryArm] [enabled]
     

    I am getting a crash when triggers - it looks that ask(LastPerson,'Vil du aktivere alarm?', 'Tryk yes at aktivere alarm?', 10)  causes the crash?

     

     [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:7:9]>> FALSE #device{id=2120,va.. -> People:isOn => log('People at Home usi..
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:2:5]>> suspended triggered - callback
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:4:13]>> FALSE #TV{HouseIsEmpty=t.. -> People:value:bin:sum == 1 & !HouseIsEm..
    [17.12.2023] [16:25:28] [TRACE] [ER2059]: [Rule:5:13]>> FALSE #TV{HouseIsEmpty=t.. -> People:value:bin:sum == 1 & HouseIsEmp..
    [17.12.2023] [16:25:38] [TRACE] [ER2059]: [Rule:2:5]>> FALSE #TV{HouseIsEmpty=t.. -> HouseIsEmpty & ask(LastPerson,'Vil du ..
    [17.12.2023] [16:25:38] [ERROR] [QUICKAPP2059]: QuickApp crashed
    [17.12.2023] [16:25:38] [ERROR] [QUICKAPP2059]: Unknown error occurred:
    [17.12.2023] [16:26:04] [DEBUG] [QUICKAPP2059]:
    EventRunner5, deviceId:2059, version:0.84
     

     

     

    Please login or register to see this code.

     

     

    Isn't ask(PeopleMap[2120] a table with id and name?

    So you send a table instead of an integer as the first argument of ask? Could make the fibaro api barf...

    I will add a type check to the ask function in next version.

     

    Posted
    1 hour ago, jgab said:

    Isn't ask(PeopleMap[2120] a table with id and name?

    So you send a table instead of an integer as the first argument of ask? Could make the fibaro api barf...

    I will add a type check to the ask function in next version.

     

    i see..

     

    Using 1861 instead of LastPerson - gives me the trigger but also the QA Crash 

    1: tryArm works in other rules (the Pointer show the Error is there, right?).

    Please login or register to see this code.

    Please login or register to see this attachment.

     

    If I want to use LastPerson, then lastPerson need to get the ID from the PeopleMap right?

    Like ... ask(PeopleMap[LastPerson].id

    But this gives me - Runtime: table is 'nil' for array reference

    I guess this because that LastPerson starts with being noting -> var.LastPerson = "" 

    So i tried var.LastPerson = 2120 - the Runtime: table is 'nil' for array reference goes away - one down ;-)

     

    Please login or register to see this code.

    returns 2 for Admin user, when House is empty, that is correct but i need the mobile phone ID associated to the USER, right?.

     

    Jan you do message the iPhone with the user ID - not Phone ID - but it seems i cant do this with Ask - is that right?

    Please login or register to see this code.

     

    Posted

    @jgab Jan how can i learn, what is the error that is shown in UI below?

    It is unsearchable inbetween logs, as it probably happened too long ago so the debug window can not list it.

    Is there a way to determine what caused this error?

     

    Please login or register to see this attachment.

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

    @jgab Jan how can i learn, what is the error that is shown in UI below?

    It is unsearchable inbetween logs, as it probably happened too long ago so the debug window can not list it.

    Is there a way to determine what caused this error?

     

    Please login or register to see this attachment.

    No, if it's "scrolled out of the console" it's lost.

    I could probably come up with a special log buffer for errors so one could list them...

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