ZeroOne3010 / yetanotherhueapi

A Java library for controlling Philips Hue lights. Available from the Maven Central.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alert Functionality

fk0ff92 opened this issue · comments

Hey, first of all, thanks for this good work, I love your API. Hope I have not overlooked anything and do not annoy. I really need the alert functionality and don't want to emulate it. The original Hue app would have to understand alerts.

Cool, thanks for your message! The library has been developed based on my own needs, and until now I have not needed alerts, so it's not there yet. It's a good idea, though! I'll have to see how it would work out. 🤔 Would you happen to have any ideas or suggestions on how the alert system should work in this library?

Cool, I'm really glad you're interested and open to new features. In various implementations and also in the original API I have found hints that there must also be an "alert" in the state. The options for this are select (blink once) and lselect(blink ten times). The most sensible way would be to include it either via the state builder. Or you can wrap it and apply it to lights and rooms (groups). I also noticed that you work a lot with rooms, but a light group is hard to access. If you are interested to talk about more ideas let me know.

By the way, I use your implementation to implement a kind of Hue Disco. It is not necessary to implement it myself, because there are already many apps but I wanted to do it with a real beat detector and in real time on a raspberry pi. For me it's actually a bit cumbersome to use your builder, even if it's really super easy to use.I had to wrap your lights and your rooms unfortunately, because they are final and you don't allow any further implementations or inheritances. In my wrapper I built many methods that make the lights blink or flash. I was thinking about just developing your code further, but then I'm afraid that I can migrate updates from you only with difficulty.

Cumbersome, huh? Well, that's obviously not too good... I'd love to take a look at your code, if you wouldn't mind uploading it to GitHub? 😃

Also, having now taken a look at the official docs, I would tend to agree that the state builder would be the best place to put the alert functionality into. 👍

I'm not sure what you mean by saying that a light group is hard to access. What kind of a light group are we talking about? The library does support zones with the getZones() and getZoneByName(String) methods. They are completely analogous to the getRooms() and getRoomByName(String) methods.

I lack a bit of confidence to share my code with you without comment, because I'm still a student and just started actively programming java a few weeks ago. I had some help from my colleague who gave me code reviews. My code at the moment consists mainly of adding the general beat detector (https://github.com/generic-beat-detector/GBD). It was a lot of work to configure a raspberry pi with a microphone connected so that the general beat detector has something to analyze. I'm proud of the progress though, because now i get the "kick events" in real time, so i can react to every bass kick with a lamp reaction. Your used work can be found under functionalLight. This part of the implementation is as I said not very advanced yet, because I'm always thinking about how to access the lights and if and how to wrap them. I would like to have the functional light also as a functinal room, because some commands would be good if they would be executed synchronously by the whole room. I have shared the repository privately with you. Thanks for you input.

Probably I have then selected exactly the group type, which is not so implemented. I have a group in Hue called Alarm, which is neither a Zone nor a Room, but a Light group. The only way to get to it is this way.

hue.getGroupsOfType(GroupType.LIGHT_GROUP).stream().map(x-> x.getName() == "Alarm").findFirst()

Hey, thanks for sharing! The code looks very nice, nothing to be ashamed of there! ☺️

FunctionalLight looks like a sensible class. It follows the composition over inheritance principle. I can see your frustration with the transition time, your idea of .on(int) and .off(int) could be worth including with the library itself.

I certainly welcome new ideas, so keep them coming!

@fk0ff92 Hey, I just finished the alerting feature. I wonder if you might want to take a look at it before I merge it to master..? It's in pull request #33.

Alerts have been merged to master.

Alert functionality has been releases in version 2.1.0. Enjoy!