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

Guest kallecux

Hi @Sjakie,

 

i do it in this way to create the global variable:

Please login or register to see this code.

an in ER4 i retrieve the information from the variable in this way:

 

Please login or register to see this code.

so i can access the devices with this syntax:

 

Please login or register to see this code.

Greetings

Link to comment
Share on other sites

10 hours ago, jgab said:

 

Hi, what kind of lights do you have? (If you click on the 'List' button in the main QA)

I only have "Extended color light" and "Dimmable light" (Phillips) and they work for me.

Can you try this version? 

Please login or register to see this attachment.

 

If you have 2 bridges you need to run two QAs. I could probably make a single QA support multiple bridges but I don't think there would be a lot of difference in resource usage. in fact, I think that dividing it up in one per bridge probably makes the QAs a bit more responsive as QAs execute in parallell.

 

hi @jgab,

 

thanks for taking the time to have a look on it :)

 

what kind of lights do you have? (If you click on the 'List' button in the main QA)

I do have about 65 lights of different types:

  • Extended color light 
  • Color temperature light
  • Color light
  • Dimmable light
  • LightGroup

LightGroup being for a whole room and not sure it's part of your querie :)

 

Can you try this version? 

Please login or register to see this attachment.

Sure. I had install the QD, copy the code and replace it in original one.

As a first results 

  • i get a lot of WARNINGS: [QUICKAPP315]: Class for the child device: 554, with type: com.fibaro.philipsHueLight not found. Using base class: QuickAppChild
  • Lights status are not updated ie a light that is on is reported on, a light that is colored in red, is presented in standard yellow...
  • wondering if i shouldn't have remove lights before, it happens that "Removelights options" doesn't work any more
  • as such i reinstall previous code to delete all of them
  • and then reinstall the new provided code to "install light"
  • nothing happen when doing so

 

If you have 2 bridges you need to run two QAs.

simple and effective ;)

i will

 

Thanks for your support again

br

mde

 

Link to comment
Share on other sites

  • Topic Author
  • 3 hours ago, Mateo said:

     

    hi @jgab,

     

    thanks for taking the time to have a look on it :)

     

    what kind of lights do you have? (If you click on the 'List' button in the main QA)

    I do have about 65 lights of different types:

    • Extended color light 
    • Color temperature light
    • Color light
    • Dimmable light
    • LightGroup

    LightGroup being for a whole room and not sure it's part of your querie :)

     

    Can you try this version? 

    Please login or register to see this attachment.

    Sure. I had install the QD, copy the code and replace it in original one.

    As a first results 

    • i get a lot of WARNINGS: [QUICKAPP315]: Class for the child device: 554, with type: com.fibaro.philipsHueLight not found. Using base class: QuickAppChild
    • Lights status are not updated ie a light that is on is reported on, a light that is colored in red, is presented in standard yellow...
    • wondering if i shouldn't have remove lights before, it happens that "Removelights options" doesn't work any more
    • as such i reinstall previous code to delete all of them
    • and then reinstall the new provided code to "install light"
    • nothing happen when doing so

     

    If you have 2 bridges you need to run two QAs.

    simple and effective ;)

    i will

     

    Thanks for your support again

    br

    mde

     

    You can't easily copy and paste the code. The new QA format  (firmware 5.040.37) has a new multi file structure.

    Also the childDevices has a new structure...

    So, you need to install and re-generate the child devices too. I now it's a hassle due to new deviceIDs...

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    You can't easily copy and paste the code. The new QA format  (firmware 5.040.37) has a new multi file structure.

    Also the childDevices has a new structure...

    So, you need to install and re-generate the child devices too. I now it's a hassle due to new deviceIDs...

     

    hey @jgab

    thanks for the advise

    i delete all former QD, reinstall the latest one, change user and ip.

    it installs only 2 lights (one extended color light and one Dimmable light) and it stops.

    When requesting the list, it works :)

     

    thanks for your support

     

     

    Link to comment
    Share on other sites

    attached AES QA, let say beta 1, seems to work but might need optimizations here and there ...

     

    EDIT: optimized, see below

     

    - based on Matthias Hilbig work

     

    Please login or register to see this link.

    Please login or register to see this link.

     

    However i found, that if using the aeslua.encrypt and aeslua.decrypt (that's the example calls used by author), the produced cipher does not match with i got with e.g.

     

    Please login or register to see this link.


    Please login or register to see this link.

     

    The problem seems to be, that aeslua.encrypt and aeslua.decrypt are using pwToKey(password, keyLength) function, which encrypts with cbc the provided password, and use the output for encryption. Of course becasue encrypt and decrypt are using exact same way (pwToKey), the internal validation is ok, but it does not match cipher produced with other tools.

     

    Anyway, one can do it in different way, by calling: 

     

    Please login or register to see this code.

     

    One need to "prepare" the key/data/iv before, but that's described in my example QA. I did tested/validated the ECB CBC 128/256 modes (192 should be ok normally), OFB and CTR are working as well, but for data in not multiple of 16 one need to cut of course the output to length of data. This has been not implemented by Matthias , nor SquidDev, however not big deal if one know it. CFB not tested, feel free to do it^^.

     

    - Additionally i've added some standard paddings, the one originaly used is not common.

    - Added as well some examples (but commented out) of direct call aes.encrypt/decrypt (ECB), 
      just for those of you who wish to unserstand the original examples (not included, check gihub above)

     

    SHA is not included, so if someone need to hash iv, use already existing sha-1 pure lua implementation (that sha-2 pure lua might work on HC3 as well).

     

     

    Updated, see -> 

     

     

     

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

    Is there any way to manage deviceID’s ?  Create a device with a particular deviceID or change an existing deviceID ?

    Or is that just going to break things, the associations, and also the sequential allocation of deviceID’s.

     

    Im looking to create (or reserve) about 250 IDs in the 1000-1250 range, for easier ID mapping. If not possible then a hash table it will have to be.

    Link to comment
    Share on other sites

  • Topic Author
  • 11 minutes ago, xAPPO said:

    Is there any way to manage deviceID’s ?  Create a device with a particular deviceID or change an existing deviceID ?

    Or is that just going to break things, the associations, and also the sequential allocation of deviceID’s.

     

    Im looking to create (or reserve) about 250 IDs in the 1000-1250 range, for easier ID mapping. If not possible then a hash table it will have to be.

    No, IDs are assigned sequentially when devices are created and can not be specified. IDs are not reused either, so if you remove devices you will get "holes" in the numbering.

    Hashtable it be...

    Link to comment
    Share on other sites

  • Topic Author
  • 10 hours ago, Mateo said:

     

    hey @jgab

    thanks for the advise

    i delete all former QD, reinstall the latest one, change user and ip.

    it installs only 2 lights (one extended color light and one Dimmable light) and it stops.

    When requesting the list, it works :)

     

    thanks for your support

     

     

    Sorry, you got my debug version that only install 2 lights.

    You can change line ~820 from

    Please login or register to see this code.

    to

    Please login or register to see this code.

    and it will install all lights,

    Btw. Did it work for the 2 lights that you got installed?

    Link to comment
    Share on other sites

    22 hours ago, kallecux said:

    i do it in this way to create the global variable:


    Hi @kallecux

     

    I tried your HomeTable code, but it stoppes when the device is a user. 

    Please login or register to see this code.

    It can’t get the roomName, the roomID (219) doesn’t exists as a room. All my users except the admin have that roomID. Do I have some corrupt values? 
     

     

    Edited by SmartHomeEddy
    Link to comment
    Share on other sites

    That table works very good for me , I dont have users in at the moment.

    It does not give any error in debug.

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • Maybe it's been noticed in other posts.

    Two extra functions to string that is not standard Lua 5.3

    Please login or register to see this code.

    that is the split function we had on HC2

    Please login or register to see this code.

    that checks is a string starts with prefix.

     

    Btw, another thing. For a long time (I think also on the HC2) we have had the functions

    Please login or register to see this code.

    that doesn't seem to be that useful. Is it an accident that they are left in the Lua context we are given?

     

    Link to comment
    Share on other sites

    another one nice QA, this time UDP broadcast. Other users tested this, without success, so i thought "let's make it possible"

     

     

    Hint: on HC3 there is firewall running, so it blocks any not allowed packets (for now, i think Fibaro will fix that soon?).

    Anyway, one can of course use the only (currently - 5.040.37) allowed port to read the data.

    However, we need to bind the UDPSocket, which is not officially supported.

     

    The solution is attached :) How to use: enter your HC3 IP as local variable, click on button and watch the magic ...

     

     

     

    Please login or register to see this attachment.

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

    11 hours ago, jgab said:

    Sorry, you got my debug version that only install 2 lights.

    You can change line ~820 from

    Please login or register to see this code.

    to

    Please login or register to see this code.

    and it will install all lights,

    Btw. Did it work for the 2 lights that you got installed?

     

    ;) it works with your new line of code :)

    and all lights have been installed

    however status is Off for all of them where a lot are presently running, with different settings.

    Something to do to refresh this status and keep it updated?

     

    thanks again :)

    br

    mde

     

    Link to comment
    Share on other sites

    13 minutes ago, 10der said:

    @tinman what port 

    5061

     

    sip server on HC3, there are some other ports allowed in the ip4tables config, however they already being in use by other services. Sip is using two ports, the 5061 is backup (or actually if 5060 used, or calling,...), so it's important to close the socket (to stop the binding made by the QA socket) after one received the data. The firewall might kill that port dynamically (reboot helps), if you flood it, so the rule is "use, close, wait before re-use".

    • Thanks 1
    Link to comment
    Share on other sites

    3 minutes ago, tinman said:

    sip server on HC3, there are some other ports allowed in the ip4tables config, however they already being in use by other services. Sip is using two ports, the 5061 is backup (or actually if 5060 used, or calling,...), so it's important to close the socket (to stop the binding made by the QA socket) after one received the data. The firewall might kill that port dynamically (reboot helps), if you flood it, so the rule is "use, close, wait before re-use".

    Hmm.

    magic  + hardcoding. nice. I should use always pre-defined port. cool. 

    Fibaro. just. Fibaro.

    Edited by 10der
    Link to comment
    Share on other sites

    XActove have a BUG!

    just fixing

    but actor ok!

     

    Please login or register to see this code.

     

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