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

On 7/28/2022 at 8:00 PM, ChristianSogaard said:

 

Hi Jan...

 

We are using COH at home - but only for mapping/controlling HUE lights from 

Please login or register to see this link.

 and using EV4 for the mapping.

No need at all for any GUI from our site.

 

I only use the Yubii app to set the house Alarm

Hi @jgab

 

I am really looking forward to COH2 - and understand you are waiting for Philips to enhanced the API 

 

Will the new COH2 also use children per HUE Device ?

If yes - would it be possible to choose to create the children in Hidden mode?

My reason for this request is when using voice assistants like Google and Alexa - i am getting the devices double in the assistants, because i also have the voice assistant connected to HUE direct.

Hidden devices are not synced to Fibaro Cloud - and would make it easier to use voice assistants connected to both Fibaro and HUE at the same time.

 

 

 

Link to comment
Share on other sites

  • Topic Author
  • 12 minutes ago, ChristianSogaard said:

    Hi @jgab

     

    I am really looking forward to COH2 - and understand you are waiting for Philips to enhanced the API 

     

    Will the new COH2 also use children per HUE Device ?

    If yes - would it be possible to choose to create the children in Hidden mode?

    My reason for this request is when using voice assistants like Google and Alexa - i am getting the devices double in the assistants, because i also have the voice assistant connected to HUE direct.

    Hidden devices are not synced to Fibaro Cloud - and would make it easier to use voice assistants connected to both Fibaro and HUE at the same time.

     

    So the version I'm going to release doesn't create any child devices at all.

    It's going to be a "companion QA" that sends hue state changes to other listening QAs, and that you can send hue commands to.

    It's primarily for use by ER where hue devices will be integrated to look like regular devices for the rules.

    However, it could also be used by someone that wants to make a hue child devices QA...

    Just now, jgab said:

     

    So the version I'm going to release doesn't create any child devices at all.

    It's going to be a "companion QA" that sends hue state changes to other listening QAs, and that you can send hue commands to.

    It's primarily for use by ER where hue devices will be integrated to look like regular devices for the rules.

    However, it could also be used by someone that wants to make a hue child devices QA...

    So I think what I have could be released, features could evolve over time, but I'm leaving for the beach for a week and will be back coding Aug.9....

    Link to comment
    Share on other sites

    13 minutes ago, jgab said:

     

    So the version I'm going to release doesn't create any child devices at all.

    It's going to be a "companion QA" that sends hue state changes to other listening QAs, and that you can send hue commands to.

    It's primarily for use by ER where hue devices will be integrated to look like regular devices for the rules.

    However, it could also be used by someone that wants to make a hue child devices QA...

    That really works for me - i dont need the GUI or childs.

    This is just what i need... "sends hue state changes to other listening QAs, and that you can send hue commands to."

     

    I am really looking forward to this :-)

     

    is curious how the addressing/communicating to the HUE devices are when there are no children - i have around 80 - so the naming is important for me

    Perhaps an extra file the the QA with the whole mapping ? - or what is you idea?

    Edited by ChristianSogaard
    P
    Link to comment
    Share on other sites

  • Topic Author
  • Well, the basic is that your QA defines a function

    Please login or register to see this code.

    and that function will be called with the uid of the Hue device and the events.

    The event could be {on=true} or {color={xy={x=..,y=...}} or {motion = false} etc.

    The call an action you do 

    Please login or register to see this code.

    There will also be some helper functions to retrieve properties of a Hue device.

     

    The HueConnector QA does the work of keeping all the services together under the device concept.

    Ex. a Hue motion sensor that had lux and temp would previously be split up into 3 Childs for motion, lux, and temp.

    Now all the events come for the motion device.

    So, there are 3 resources that can receive events. Devices, Rooms and Zones.

    They all have unique uids

    You the need to provide some mapping from name to uid. 

    To use the Hue device name may not always be safe as resources can have the same name (but always different uids)

     

    When the HueConnector QA starts it will log a table with all devices/rooms/resources/scenes

    Ex.
     

    Please login or register to see this code.

    and that table could then be copied included in your code.

    Ex. it would be easy to traverse this table and build another map from name->uid that can be used in your code.

    This is probably how it will work in ER.

    In this example one can also comment out devices/resources that are of no interest.

    The name here is the Hue name but one could allow for a user to add another name to the table and it will be used instead. I need to think about that.

     

     

     
    • Like 1
    Link to comment
    Share on other sites

    4 minutes ago, jgab said:

    Well, the basic is that your QA defines a function

    Please login or register to see this code.

    and that function will be called with the uid of the Hue device and the events.

    The event could be {on=true} or {color={xy={x=..,y=...}} or {motion = false} etc.

    The call an action you do 

    Please login or register to see this code.

    There will also be some helper functions to retrieve properties of a Hue device.

     

    The HueConnector QA does the work of keeping all the services together under the device concept.

    Ex. a Hue motion sensor that had lux and temp would previously be split up into 3 Childs for motion, lux, and temp.

    Now all the events come for the motion device.

    So, there are 3 resources that can receive events. Devices, Rooms and Zones.

    They all have unique uids

    You the need to provide some mapping from name to uid. 

    To use the Hue device name may not always be safe as resources can have the same name (but always different uids)

     

    When the HueConnector QA starts it will log a table with all devices/rooms/resources/scenes

    Ex.
     

    Please login or register to see this code.

    and that table could then be copied included in your code.

    Ex. it would be easy to traverse this table and build another map from name->uid that can be used in your code.

    This is probably how it will work in ER.

    In this example one can also comment out devices/resources that are of no interest.

    The name here is the Hue name but one could allow for a user to add another name to the table and it will be used instead. I need to think about that.

     

     

     

     

    Thank you Jan, seems pretty simple.

    Would it be possible to extract the room name from HUE into the HueDeviceTable ?

    I have bad naming convention for this structure - eg i have several HUE lamps called ceiling - but with the room/zone combined it give sense.

    if the HueDeviceTable also had the room/zone i would not need an additional mapping

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 21 minutes ago, ChristianSogaard said:

     

    Thank you Jan, seems pretty simple.

    Would it be possible to extract the room name from HUE into the HueDeviceTable ?

    I have bad naming convention for this structure - eg i have several HUE lamps called ceiling - but with the room/zone combined it give sense.

    if the HueDeviceTable also had the room/zone i would not need an additional mapping

     

     

    That’s a good idea!

    • Thanks 1
    Link to comment
    Share on other sites

    7 hours ago, jgab said:

    That’s a good idea!

     

    Thank you... 

    Any idea for ETA when we can start test? and would you put it in the QAUpdater?

    I could use a few examples for EV4 - you already mentioned some great use cases yourself with the motion device.

    But i guess its for the Matrix

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 10 hours ago, ChristianSogaard said:

    Any idea for ETA when we can start test? and would you put it in the QAUpdater?

    Week starting Aug 8 when I'm back from vacation

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    • 2 weeks later...

    I would like to ask for some help I have some tuya devices I want to connect it via API I have API from IOT tuya 

    Please login or register to see this code.

    on tuya it give 

    Please login or register to see this code.

    but when I put it in CMD it give me but it work to on and off

    Please login or register to see this code.

    How to call this in QA because I am still learning Lua

    Link to comment
    Share on other sites

    On 8/10/2022 at 1:49 PM, ABDULLAH258 said:

    I would like to ask for some help I have some tuya devices I want to connect it via API I have API from IOT tuya 

    Please login or register to see this code.

    on tuya it give 

    Please login or register to see this code.

    but when I put it in CMD it give me but it work to on and off

    Please login or register to see this code.

    How to call this in QA because I am still learning Lua

    I try in it and write this code but I am not sure what is wrong 

    Please login or register to see this code.

    it give me error in console 

    Please login or register to see this code.

    can any one help me with this. 

    Link to comment
    Share on other sites

    Hi @jgab

     

    I am trying to make my first Quickapp but it keeps crashing with the message:

     

    Please login or register to see this code.

     

    The intention is to retrieve my Wan IP address and put it in a label.

    Any idea what is going wrong?

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

    with ':'

    Link to comment
    Share on other sites

    hi @jgab

    Thanks I just looked over it the whole time.

     

    It works now. Do wonder how I can arrange for the call in the Quickapp to read the IP address to be executed, say, every hour?
    Now it is executed once right?

    Edited by RobLu
    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hi @jgab

     

    Thanks for the update!

    I now activate the function using the TurnOn method. But how can I cancel this setInterval with the TurnOff method?

     

    Still learning....

    Link to comment
    Share on other sites

    Jan, what am I doing wrong?

    Please login or register to see this code.

    hal_Voor.Halvoor is excisting device in HT

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

    hal_Voor.Halvoor:off turns off a device and return true. pairs(...) need a table to loop over.

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, RobLu said:

    Hi @jgab

     

    Thanks for the update!

    I now activate the function using the TurnOn method. But how can I cancel this setInterval with the TurnOff method?

     

    Still learning....

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