Git Product home page Git Product logo

Comments (7)

ZeroOne3010 avatar ZeroOne3010 commented on July 24, 2024 1

Just to close this old issue: version 3.0.0-alpha is now out and it supports those server sent events. ❤️

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on July 24, 2024

Hey, thanks for submitting this as an issue! You are definitely right, the SSE would be an awesome feature to have and I'll definitely want the library to have it some day! 🤩 Unfortunately I haven't had much time to work on this library lately, but I'm hoping I'll get a bit more time starting next week. For now, what little time I've had, I've spent on #46 to add mDNS discovery support, as Philips is deprecating the UPNP discovery method.

While I'm hoping the SSE feature in itself might be a pretty straight forward one to implement, it would need more of the new v2 API to be implemented around it. For one, the SSE API identifies the devices with a UUID, which does not exist in the API v1. Also, when implementing the API v2, I would need to see if it can be compatible with the current interfaces that the library offers, or if I should just be bold and break all the backwards compatibility and release new major version (3.0.0) that would support the API v2 only.

For now I'm hoping I could add SSE into the current version without breaking backwards compatibility, but to fully support everything else that the new API v2 offers a new major version might be required. I would still need to explore and experiment with the new API to form a full picture of the situation.

Finally, I'm slightly worried about the beta status of the server-sent events, as that would mean the API might still change, which would not be good for the library. Maybe a beta version of the library is needed while the API is in beta, too. 🤔 So, a lot to consider here!

As a note to mainly myself, the docs for the server-sent events can be found here: https://developers.meethue.com/develop/hue-api-v2/core-concepts/#events

from yetanotherhueapi.

philipparndt avatar philipparndt commented on July 24, 2024

Hi,

I started to do some tests with the SSE API. It is pretty easy to use, but the identifiers are no longer compatible, as you already mentioned. I also found another incompatible change for the Friends Of Hue buttons. There is no push notification when pressing two buttons at once. The old API reported this as an extra button, which was nice.

I've used this dependency in my tests https://github.com/autopreet/apache-sseclient, but the byte-code is not compatible with Java 8.

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on July 24, 2024

Luckily the client side of the SSE protocol seems simple enough, there should be no need to use any libraries... 🤞

from yetanotherhueapi.

NathanSweet avatar NathanSweet commented on July 24, 2024

Getting events from the server rather than polling is crucial. I'd suggest making breaking changes to support v2. People who want to continue using v1 can use the older version of this library.

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on July 24, 2024

@philipparndt @NathanSweet Hi, I've just pushed a commit to the api-v2 branch in case you would like to take a look at the initial events API support. 😊 The new io.github.zeroone3010.yahueapi.v2.Hue (notice the "v2" in the package name there) class now has a subscribeToEvents(HueEventListener) method that you can call with your custom event listener that implements the simple interface there.

For some reason subscribing to the event stream breaks all other communication with the Bridge, for me at least. I've posted a question about it to the official Hue forum, but so far to no avail.

Also the subscribeToEvents method actually puts the thread to sleep after starting to listen for the events. Not as it's supposed to be, but I couldn't immediately figure out a way to properly return from the method while keeping the connection open! I've been using the HueEventsTestRun class for testing, and if I move the sleep there, no events are logged... 😕 (Give the test run class two arguments: IP address and API key, if you want to try it.) Any help would be appreciated. 😃

The events that the API returns should also, IMO, include a proper object reference to the resource that sent the event, e.g. a button, a light, or a sensor. Right now there's just the owner field which has an id and a type.

from yetanotherhueapi.

philipparndt avatar philipparndt commented on July 24, 2024

Hi @ZeroOne3010

Thanks for letting me know. I've switched to TypeScript in my project.
I only implemented support for API v2 and it is up and running very stable 😄

Maybe interesting for you: I have the SSE API always running, and do not have issues with other applications that are using the API. Like iConnectHue for example.

from yetanotherhueapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.