Comments (7)
Just to close this old issue: version 3.0.0-alpha
is now out and it supports those server sent events. ❤️
from yetanotherhueapi.
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.
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.
Luckily the client side of the SSE protocol seems simple enough, there should be no need to use any libraries... 🤞
from yetanotherhueapi.
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.
@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.
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)
- Add colorloop effect
- Add group 0, i.e. the "all lights" group
- NPE when bridge doesn't return sensors HOT 5
- could you make a java 11 version which includes a module-info file. THX HOT 2
- Get color of light HOT 1
- Turn on / off room without setState (color, alert, etc...) HOT 2
- Why so restrictive? HOT 7
- Add mDNS support for discovering bridges HOT 1
- Add new light HOT 6
- Implement a findByUiniqueId for lights and sensors HOT 11
- No logging by default HOT 3
- TemperatureSensor#getDegreesCelsius NPE HOT 10
- Get state ... question ? HOT 3
- Why such a restrictive State.Builder? HOT 2
- EffectType from String "prism": not one of the values accepted for Enum HOT 2
- Error when using v2 HOT 2
- JKS not found and java.io.FileNotFoundException: https://discovery.meethue.com/ HOT 28
- Client code generation HOT 2
- save bridge details HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yetanotherhueapi.