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


HC3 QuickApps coding - tips and tricks


jgab

Recommended Posts

  • Topic Author
  • 1 hour ago, michal85pl said:

    changed but still 0%

    Do you get any log on the HC3 that like "multilevel sensor <id> batteryLevel=<x>." ?

    Link to comment
    Share on other sites

    10 godzin temu, jgab napisał:

    Do you get any log on the HC3 that like "multilevel sensor <id> batteryLevel=<x>." ?

    Nope..

     

    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",1],"deviceId":397}
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: binary sensor 8 value=1
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":398}
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: binary sensor 17 value=0
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":400}
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: binary switch 14 value=0
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":399}
    [10.09.2020] [08:23:05] [DEBUG] [QUICKAPP368]: binary sensor 10 value=0
    [10.09.2020] [08:23:25] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":397}
    [10.09.2020] [08:23:25] [DEBUG] [QUICKAPP368]: binary sensor 8 value=0
    [10.09.2020] [08:25:47] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":398}
    [10.09.2020] [08:25:47] [DEBUG] [QUICKAPP368]: binary sensor 17 value=0
    [10.09.2020] [08:25:47] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",122],"deviceId":399}
    [10.09.2020] [08:25:47] [DEBUG] [QUICKAPP368]: binary sensor 10 value=122
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",22.3],"deviceId":401}
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: binary sensor 9 value=22.3
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",1],"deviceId":397}
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: binary sensor 8 value=1
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",0],"deviceId":400}
    [10.09.2020] [08:25:48] [DEBUG] [QUICKAPP368]: binary switch 14 value=0
    [10.09.2020] [08:26:29] [DEBUG] [QUICKAPP368]: onAction: {"actionName":"setProperty","args":["value",22.8],"deviceId":401}
    [10.09.2020] [08:26:29] [DEBUG] [QUICKAPP368]: binary sensor 9 value=22.8

    Link to comment
    Share on other sites

  • Topic Author
  • 55 minutes ago, michal85pl said:

    Nope..

     

    at around line ~320, change

    Please login or register to see this code.

    to

    Please login or register to see this code.

    Here is a new version with the fix. (1,6)

    Please login or register to see this attachment.

    Edited by jgab
    Link to comment
    Share on other sites

    8 godzin temu, jgab napisał:

     

    at around line ~320, change

    Please login or register to see this code.

    to

    Please login or register to see this code.

    Here is a new version with the fix. (1,6)

    Please login or register to see this attachment.

    With new version (all credenetials set):

    [10.09.2020] [17:33:00] [ERROR] [QUICKAPP368]: QuickApp crashed
    [10.09.2020] [17:33:00] [ERROR] [QUICKAPP368]: main.lua:350: Missing credentials. Setup quickVars IP,User,Pwd

     

    I didn't check the old one with changing the above code.

    Link to comment
    Share on other sites

    without this:

    HC2_IP   = self.config["IP"]

    HC2_USER = self.config['User']

    HC2_PWD  = self.config['Pwd']

    assert(HC2_IP and HC2_USER and HC2_PWD,"Missing credentials. Setup quickVars IP,User,Pwd")

     

    QA runs, read battery, but still 0%

     

     

    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary switch 14 value=false
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary switch 14 batteryLevel=94
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/9
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 9 value=24.80
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 9 batteryLevel=100
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/8
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 8 value=false
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 8 batteryLevel=100
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/17
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 17 value=false
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 17 batteryLevel=100
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/10
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 10 value=129.00
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 10 batteryLevel=100

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 14 hours ago, michal85pl said:

    without this:

    HC2_IP   = self.config["IP"]

    HC2_USER = self.config['User']

    HC2_PWD  = self.config['Pwd']

    assert(HC2_IP and HC2_USER and HC2_PWD,"Missing credentials. Setup quickVars IP,User,Pwd")

     

    QA runs, read battery, but still 0%

     

     

    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary switch 14 value=false
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary switch 14 batteryLevel=94
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/9
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 9 value=24.80
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 9 batteryLevel=100
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/8
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 8 value=false
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: binary sensor 8 batteryLevel=100
    [10.09.2020] [17:41:32] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/17
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 17 value=false
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 17 batteryLevel=100
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: Call HC2:http://192.168.20.4/api/devices/10
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 10 value=129.00
    [10.09.2020] [17:41:33] [DEBUG] [QUICKAPP368]: binary sensor 10 batteryLevel=100

     

     

    I moved the credentials to be set in the QA's quickAppVariables tab.

    So it reads the battery - progress! :-)

    however, I still had a bug. Here is a new version.

    Please login or register to see this attachment.

     

    Link to comment
    Share on other sites

    8 godzin temu, jgab napisał:

    I moved the credentials to be set in the QA's quickAppVariables tab.

    So it reads the battery - progress! :-)

    however, I still had a bug. Here is a new version.

    Please login or register to see this attachment.

     

    159588433_Zrzutekranu2020-09-11165819.jpg.8b5d9da0f4f2326004ebc9fcaceebb56.jpg

    Link to comment
    Share on other sites

  • Topic Author
  • 15 hours ago, michal85pl said:

    Please login or register to see this link.

    Is that for all your devices? 

    Do you get a log like "binary switch 146 batteryLevel=60" ?

    When I try I get a 

    Please login or register to see this image.

    /monthly_2020_09/batt.png.ed0a24e063c04e0421d85402a8bb46ac.png" />

    Link to comment
    Share on other sites

    I have also empty batteries on motion sensor, D/W sensor and battery powered rollerSchutters...

    Link to comment
    Share on other sites

    Godzinę temu, jgab napisał:

    Is that for all your devices? 

    Do you get a log like "binary switch 146 batteryLevel=60" ?

    When I try I get a 

    Please login or register to see this link.

    [12.09.2020] [10:08:21] [TRACE] [QUICKAPP415]: Scene ID for HC3Proxy is 1
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/8
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 8 value=false
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 8 batteryLevel=100
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/9
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 9 value=22.20
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 9 batteryLevel=100
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/10
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 10 value=231.00
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 10 batteryLevel=100
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/14
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary switch 14 value=false
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary switch 14 batteryLevel=94
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/17
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 17 value=false
    [12.09.2020] [10:08:21] [DEBUG] [QUICKAPP415]: binary sensor 17 batteryLevel=100

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    Additional suggestion, if You moved credentials to QA's quickAppVariables tab., maybe it would be more convenient to move HC2 scene ID  there too?

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, michal85pl said:

    Additional suggestion, if You moved credentials to QA's quickAppVariables tab., maybe it would be more convenient to move HC2 scene ID  there too?

    Are you running v1.7?

    I attached v1.8 that has a bit improved logging.

    The HC2 scene ID is auto discovered and should not be set in the code.

    All config for the HC2 is via the quickAppVariables now.

    More lengthy configs like the device mapping is unfortunately not very convenient to add via quickAppVariables (there is a quite limited length of the value field)

    Please login or register to see this attachment.

    Edited by jgab
    Link to comment
    Share on other sites

    8 minut temu, jgab napisał:

    Are you running v1.7?

    I attached v1.8 that has a bit improved logging.

    The HC2 scene ID is auto discovered and should not be set in the code.

    All config for the HC2 is via the quickAppVariables now.

    More lengthy configs like the device mapping is unfortunately not very convenient to add via quickAppVariables (there is a quite limited length of the value field)

    Please login or register to see this attachment.

    Still 0% (should i paste anything more than main file code?), does this error mean something?Should it be that after removing child devices a restart of QA is required to reinstall them or is this a bug?

    HC2ID is autodiscovered now :)

     

     

    [12.09.2020] [10:36:53] [ERROR] [QUICKAPP415]: %s - %s
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: QA HC2Proxy - version:1.8 (QA toolbox 0.18)
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: DeviceId..:415
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Type......:com.fibaro.binarySwitch
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Interfaces:["light","quickApp"]
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Room......:228
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Visible...:true
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Created...:Fri Sep 11 23:51:21 2020
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Modified..:Fri Sep 11 23:51:21 2020
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Setup: Event manager (0.2)
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: Setup: Child device manager (0.3)
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: 5 children
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",0],"deviceId":436,"actionName":"setProperty"}
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: binary sensor 17 value=false
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",0],"deviceId":435,"actionName":"setProperty"}
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: binary switch 14 value=false
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",23.3],"deviceId":433,"actionName":"setProperty"}
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: binary sensor 9 value=23.3
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",231],"deviceId":434,"actionName":"setProperty"}
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: binary sensor 10 value=231
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",0],"deviceId":432,"actionName":"setProperty"}
    [12.09.2020] [10:37:00] [DEBUG] [QUICKAPP415]: binary sensor 8 value=false
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/scenes
    [12.09.2020] [10:37:01] [TRACE] [QUICKAPP415]: Scene ID for HC3Proxy is 1
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/8
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 8 value=false
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 8 batteryLevel=100
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/9
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 9 value=23.30
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 9 batteryLevel=100
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/10
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 10 value=231.00
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 10 batteryLevel=100
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/14
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary switch 14 value=false
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary switch 14 batteryLevel=94
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: Call HC2:http://192.168.20.4/api/devices/17
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 17 value=false
    [12.09.2020] [10:37:01] [DEBUG] [QUICKAPP415]: binary sensor 17 batteryLevel=100
    [12.09.2020] [10:37:40] [DEBUG] [QUICKAPP415]: onAction: {"args":["value",1],"deviceId":432,"actionName":"setProperty"}
    [12.09.2020] [10:37:40] [DEBUG] [QUICKAPP415]: binary sensor 8 value=true

     

    Link to comment
    Share on other sites

    I have also correct battery levels reported in the logging, but displayed as 0% :-(

    Please login or register to see this code.

    afbeelding.png.388160d58764e255797eafa61f4ffccf.png 

    Please login or register to see this attachment.

     

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: Call HC2:http://10.0.0.50/api/devices/1173

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: multilevel switch 1173 value=40

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: multilevel switch 1173 batteryLevel=100

     

    Edited by Bodyart
    Link to comment
    Share on other sites

  • Topic Author
  • 51 minutes ago, Bodyart said:

    I have also correct battery levels reported in the logging, but displayed as 0% :-(

     

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: Call HC2:http://10.0.0.50/api/devices/1173

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: multilevel switch 1173 value=40

    [12.09.2020] [11:01:57] [DEBUG] [QUICKAPP802]: multilevel switch 1173 batteryLevel=100

     

     

    This is magic....

    Can you do me a favour, edit your current QA and around line ~280 there is main() defined, add in the beginning:

    Please login or register to see this code.

    where you change the 1374 to the HC3 id of a childDevice that has battery value 0% - and see if it gets updated to 77%

    Edited by jgab
    Link to comment
    Share on other sites

    14 minutes ago, jgab said:

    see if it gets updated to 77%

    Please login or register to see this image.

    /monthly_2020_09/afbeelding.png.b6db377020af8c3456537f4b82958845.png" />

     

    yeapp

     

    I've outremarked that line again but the battery level stays on 77% :-D

    Edited by Bodyart
    Link to comment
    Share on other sites

  • Topic Author
  • 9 minutes ago, Bodyart said:

    Please login or register to see this link.

    yeapp

     

    Ok, one more test. Around line ~150 there is the function (for multilevelSwitch) that updates the battery property and logs the 

    "multilevel switch 1173 batteryLevel=100"

    Please login or register to see this code.

    Could it be that the property value arrives as a string? 

    Can you add a tonumber around the value argument? (and 'or value' in case it's not a number)

    Like 

    Please login or register to see this code.

     
    2 minutes ago, jgab said:

     

    Ok, one more test. Around line ~150 there is the function (for multilevelSwitch) that updates the battery property and logs the 

    "multilevel switch 1173 batteryLevel=100"

    Please login or register to see this code.

    Could it be that the property value arrives as a string? 

    Can you add a tonumber around the value argument? (and 'or value' in case it's not a number)

    Like 

    Please login or register to see this code.

     

     

    I see you use it for rollerShutter - I think we could do a childDevice class that fits better the rollerShutter and makes the buttons working.

    Edited by jgab
    Link to comment
    Share on other sites

    5 minutes ago, jgab said:

    Can you add a tonumber around the value argument? (and 'or value' in case it's not a number)

    Y E S !!!

    That fixed it, happy now :-D

    Probably we need to change the other updateProperty occurencies, because my Motion sensor and D/W sensor also show zero battery.

    Link to comment
    Share on other sites

  • Topic Author
  • 5 minutes ago, Bodyart said:

    Y E S !!!

    That fixed it, happy now :-D

    Probably we need to change the other updateProperty occurencies, because my Motion sensor and D/W sensor also show zero battery.

     

    Ok, here is v1.9 with the fix

    Please login or register to see this attachment.

    • Thanks 2
    Link to comment
    Share on other sites

    I have changed also other occurencies and now having all batteries displayed :-D

     

    Please login or register to see this attachment.

    Edited by Bodyart
    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...