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 (edited)

Good morning Jan,

I just finished to convert my light QA into HUE V2 therefor I have ER QA and:

     add "To use this there is a small Hue client library that needs to be included in the QA"

    end the  part what starts with loal devices

Color setting done with x,y

 

Some questions:

Can I set or change color if HUE light is off?

Devices are local so I must remove all devices from Home Table?

Must I create  child devices or can I switch on, off change color without the child devices?

Error;

 

fibaro.call(uid,"turnOff"[,transition]) contain a typo fibaro.call(uid,"turnOff",[transition]) in your commands

 

Thanks in advance for your valuable advice!

 

 

 

Edited by Sjakie
error added
  • 3 weeks later...
Posted (edited)

Jan I layed my hand on some HUE lamps and bridge so now I can test your new HUE_Connector.

From HUE_Connector I see the list with devices

If I use in the client QA Fibaro.call I can see a light is switching on, hehe

How to control the Hue lights within ER?

How I create child devices, manually for each lamp?

Please advice

 

REMARK:

If name in HUE-App will be changed you don't get the new name in Hue-connector if click on list button>>only delete QA and reinstall

Edited by Sjakie
remark added
  • Topic Author
  • Posted
    On 11/2/2022 at 2:01 PM, Sjakie said:

    Jan I layed my hand on some HUE lamps and bridge so now I can test your new HUE_Connector.

    From HUE_Connector I see the list with devices

    If I use in the client QA Fibaro.call I can see a light is switching on, hehe

    How to control the Hue lights within ER?

    How I create child devices, manually for each lamp?

    Please advice

     

    REMARK:

    If name in HUE-App will be changed you don't get the new name in Hue-connector if click on list button>>only delete QA and reinstall

    It's a bit on pause as I'm awaiting bug fixes/features in the Hue v2 API.

    • Like 1
    Posted

    Jan, I need end of December operational HUE lights in my appartement.

    How to do:

    1-can I stay on the old version HUE?

    2-or is it just as with my present bridge a forced update?

    3-if 1- is true no problem at all to wait till you are ready

    4-manual operating all lights at home

     

    Please advice

     

  • Topic Author
  • Posted
    2 hours ago, Sjakie said:

    Jan, I need end of December operational HUE lights in my appartement.

    How to do:

    1-can I stay on the old version HUE?

    2-or is it just as with my present bridge a forced update?

    3-if 1- is true no problem at all to wait till you are ready

    4-manual operating all lights at home

     

    Please advice

     

    As I understand it the hub supports both v1 and v2 until v1 is officially removed. So the old Hue QA should work too.

    Posted (edited)

    Ok great thanks for your answer.

    Question (again)

    How I can restart my client QA Hue by ER rule? 

    Please login or register to see this code.

     

    If this is possible then I can switch of all my lights temporary.

     

    I don't see my Syncbox, Huesensor is also activated and tells me connected to 2045

    Thanks for your  valuable advice.

    Edited by Sjakie
    found how to restart QA
  • Topic Author
  • Posted

    I don't have a sync box so I don't know what type that is. So I would assume it's not supported.

    I have pushed v0.15 of HueConnector with some minor fixes.

    Posted (edited)

    Aha, thanks.

    error

    Please login or register to see this code.

    Also in latest version

    If I click print devices

    Please login or register to see this code.

    Bridge software1.53.1953188020 (last known version)

    Edited by Sjakie
    • 2 weeks later...
    Posted

    @jgab

    I did some testing with the following example code:

     

    Please login or register to see this code.

     

    I started this getEvents function and until now for at least 12 hours the hue events are still coming in.

    This GET method seems to me a very promising way of processing the Hue event queue.

     

  • Topic Author
  • Posted

    The hub seems to time out once in a while so it's good to retry if there is a timeout/wantread response from the server.

    Also, it makes little sense to do

    Please login or register to see this code.

    instead do a json.decode on the whole response.data. If there is more fields then data: you may get garbage at the end...

    Posted

    I did it that way because the response.data part is a string, but not in json format.

     

    [16.11.2022] [13:34:19] [DEBUG] [QUICKAPP204]: HueEvent@Algemeen : httpSuccess: id: 1668602059:0 data: [{"creationtime":"2022-11-16T12:34:18Z","data":[{"button":{"last_event":"short_release"},"id":"85ac2939-40ec-42f9-9fac-5db45372b830","id_v1":"/sensors/17","owner":{"rid":"77d3f0c1-b18e-4f40-b4b0-641c83d74d52","rtype":"device"},"type":"button"}],"id":"3b365597-c24c-4d8f-a107-1d34c8cebc90","type":"update"}]

     

    It seems to me that just the data substring is in json format and according the hue v2 documentation every event has an id and data part.

     

    (By the way: the hue44 in the URL of my previous post is of course the hostname of my hue bridge)

  • Topic Author
  • Posted
    1 hour ago, Alex de Bruin said:

    I did it that way because the response.data part is a string, but not in json format.

     

    [16.11.2022] [13:34:19] [DEBUG] [QUICKAPP204]: HueEvent@Algemeen : httpSuccess: id: 1668602059:0 data: [{"creationtime":"2022-11-16T12:34:18Z","data":[{"button":{"last_event":"short_release"},"id":"85ac2939-40ec-42f9-9fac-5db45372b830","id_v1":"/sensors/17","owner":{"rid":"77d3f0c1-b18e-4f40-b4b0-641c83d74d52","rtype":"device"},"type":"button"}],"id":"3b365597-c24c-4d8f-a107-1d34c8cebc90","type":"update"}]

     

    It seems to me that just the data substring is in json format and according the hue v2 documentation every event has an id and data part.

     

    (By the way: the hue44 in the URL of my previous post is of course the hostname of my hue bridge)

    It's json format

    Posted

    I don't agree.

    When I first skip the initial Hi response from the bridge then a json.decode(response.data) gives the following error:

     

    [16.11.2022] [15:26:01] [ERROR] [QUICKAPP204]: /usr/share/lua/5.3/json/decode/state.lua:175: Cannot set key on array.

     

  • Topic Author
  • Posted

    Sorry, I didn't see your http headers.

    Yes, if you put 

    Accept = "text/event-stream"

    you will kind of get an http stream, the problem is that the intention is that you should keep the connection open and continuously read from it. Something we can't do with net.HTTPClient (could code our own http get using net.TCPClient though). It's also a stream protocol that is more than just the json data and that is what you try to skip.

    It becomes a bit messy if you repeatedly do GET requests. I'm a bit surprise that the hub sort of continue to send requests and doesn't restart with an "hi" 

    If you debug the responses you get you will see that you get a lot of empty responses if you poll quickly.

    If you want to do this (will probably put a strain on the hub) you should match with balanced brackets to get the json part. Ex.

    Please login or register to see this code.

     

    What I thought you did was set Accept to the default application/json. Then you will get the pure json response and not the stream data.

    The advantage is that the requests will hang if there are no events (up to timeout) and return immediately when events are available. It's pretty efficient and close

    to what we get with /refreshStates on the HC3.

     

    You can see how I done it in HUEv2Engine.lua.

     

     

    Posted

    Thanks for the reply.

    I don''t understand what you mean by multiple GET requests, quickly polling and empty responses.

    In my opninion I do just one single GET and the success function keeps processing (for many hours) all the incoming events. There are null empty responses.

    net.HTTPClient does keep the connection open, but I agree that some error control is necessary to restart in case the connection is broken.

  • Topic Author
  • Posted
    On 11/16/2022 at 10:39 PM, Alex de Bruin said:

    Thanks for the reply.

    I don''t understand what you mean by multiple GET requests, quickly polling and empty responses.

    In my opninion I do just one single GET and the success function keeps processing (for many hours) all the incoming events. There are null empty responses.

    net.HTTPClient does keep the connection open, but I agree that some error control is necessary to restart in case the connection is broken.

    Dang, you are absolutely right. I made the mistake of running it in my emulator first (where net.HTTPClient doesn't handle streams) and then never correctly verified it on the HC3.

    I have never seen this behaviour net.HTTPClient ever before (calling the success handler repeatedly) and that's why I was so (wrongfully) sure of myself...

    ...but it seems there is support for "text/event-stream" to get this behaviour... (maybe it was added when they added websockets?)

    Anyway, this makes it even more efficient to poll for events from the hub. However, it may close once in a while (in the Hue forum there are complaints) so it may be worth restarting it from the error handler.

    Thanks!

    /J

    Posted

    OK, i am  working on better error handling. My last started connection is now open for more than 24 hours, so it seems pretty stable. I let  it run in parallel with the curl command as stated in the event section of the core concepts chapter in the Hue V2 documentation .

     

    curl --insecure -N -H 'hue-application-key: <appkey>' -H 'Accept: text/event-stream' https://<ipaddress>/eventstream/clip/v2

     

    Hue documentation says this is the recommended method of getting the status updates.

    Learned from the differences that sometimes there are more events in a single event-message. Catching all events now.

    • 1 month later...
    Posted (edited)

    Jan, the best wishes and good health for 2023.

    My HC3 is running in the new apartment.

    I face the error if if press print devices

    Please login or register to see this code.

    If I list all devices I get this as result:

    Please login or register to see this code.

    What you have listed as example I don't see in my HUEconnector

    Please login or register to see this code.

    Please advice

     

    Edited by Sjakie
    remark COH removed
    • 4 weeks later...
    Posted

    Jan, I have added in our kitchen a Zigbee lamp added on the HUE bridge.

    I can not find it when I list HUE lights

    Can you add?

    Info from HUE app:

    Color temperature light

    Fab: Rexense

    Model:AG0002

    Software: 20220326

    Thanks in advance

    Posted

    @jgabIs this posible or do you need more info?

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