Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[huesync] Hue Play HDMI Sync Box Binding - Initial contribution #16516

Open
wants to merge 111 commits into
base: main
Choose a base branch
from

Conversation

pgfeller
Copy link
Contributor

@pgfeller pgfeller commented Mar 12, 2024

This binding integrates the Play HDMI Sync Box into openHAB. The integration happens directly through the Hue HDMI Sync Box API.

The binding is using mDNS to discover HDMI Sync devices in the local network. The LED on the Sync Box must be white or red. This indicates that the device is connected to the Network. If the LED is blinking blue, you need to setup the device using the official Hue Sync App.

Community discussion thread: Philips HDMI Sync API

Closes #10218

Credits

  • Marco Kawon: The code is based on his work - but the binding code was refactored/re-implemented. The refactoring is done to implement functionality step-by-step, so that I understand the code and in the hope to simplify it a bit to improve maintainability (and as a learning exercise for me).
  • Andrew Fiddian-Green: Code review and technical support/advice
  • April_Wexler (Kai): Testing

Tasks

  • ☠️ Binding skeleton created for org.openhab.binding.huesync
  • 🔎 skeleton mDNS discovery implemented
  • communication infrastructure
    • 🔎 mDNS device discovery - use API to get device information
    • 🔐 SSL Handshake & 🔎 Discovery
    • 🤝 Device registration
    • 👋 Device unregistration (remove thing)
    • ⛔ solve timing problems during shutdown
    • 📜 improve handling of configuration update(s)
  • CI/CD & Code maintainability
    • ⛔ Fix CI validation errors
    • ⚠️ Fix PR CI validation warnings
    • 🗨️ check feasibility of re-using resources for log & exception messages ✅
    • 🗨️ check feasibility of using AuthenticationStore
  • Implementation
    • 🔌 device status polling
      • 🐞Solve handling of invalid tokens (automatic re-registration)
      • 🐞Investigate and resolve "Bad Request" warning
      • 🐞 Investigate and resolve partial device information during "poll"
    • 📦 Create device state DTO
      • Device status
      • HDMI input/output status
      • Commands
    • Channels
      • 📜 update/revert icons to use basic icon set
      • Create .channel xml declaration/poc for device information
      • Create .channel xml declaration prototype for HDMI input/output status
      • ➕ HDMI input/output channels (read only)
      • ➕ "execution" API infrastructure added ...
        • ➕ Add support to switch ambilight on / off
        • ➕ Add support to select mode
        • ➕ Add support to select HDMI source added
        • ➕ Add support for HDMI active channel
        • ➕ Add support to adjust brightness
        • ➕ Add support for intensity channel
    • 📜 Documentation
      • README
      • PR in Docu-Repo to add binding icon

ℹ️: The 1st version will not support all possible functions - as the basic setup can be done via the official App ➡️ - I'll focus on status information and commands that are most relevant for automation in this PR.

@pgfeller pgfeller added new binding If someone has started to work on a binding. For a new binding PR. work in progress A PR that is not yet ready to be merged labels Mar 12, 2024
@pgfeller pgfeller requested a review from andrewfg March 12, 2024 23:12
@pgfeller pgfeller self-assigned this Mar 12, 2024
@pgfeller pgfeller requested a review from a team as a code owner March 12, 2024 23:12
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/philips-hdmi-sync-api/111679/39

@pgfeller pgfeller force-pushed the 10218-hue-add-hue-sync-box branch 2 times, most recently from edf4eb7 to 565fc72 Compare March 12, 2024 23:41
@andrewfg
Copy link
Contributor

@pgfeller I will start to look at this tomorrow.

@pgfeller pgfeller removed the request for review from maniac103 March 12, 2024 23:58
@pgfeller
Copy link
Contributor Author

@andrewfg Thanks! Take your time - progress will be slow unfortunately; as free time is a rare commodity ...

@pgfeller pgfeller force-pushed the 10218-hue-add-hue-sync-box branch 3 times, most recently from 566ee5d to a42500f Compare March 16, 2024 22:52
@jlaur jlaur added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Mar 17, 2024
CODEOWNERS Outdated Show resolved Hide resolved
@pgfeller pgfeller force-pushed the 10218-hue-add-hue-sync-box branch 2 times, most recently from 186bd73 to 0549ac6 Compare May 7, 2024 19:55
@pgfeller

This comment was marked as outdated.

@andrewfg

This comment was marked as outdated.

@pgfeller

This comment was marked as outdated.

@pgfeller

This comment was marked as outdated.

@pgfeller pgfeller requested a review from lsiepel October 26, 2024 22:15
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed the review. Many relative small changes are required. When all comments are addressed (please do so by thumbs up or writing a comment, not by resolving comments), i'll look over it again and we are ready to merge this.

.gitignore Outdated Show resolved Hide resolved
logMessage = HueSyncLocalizer.getResourceString(message);
}

logger.error("{}", logMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't log from the exception itself, better to log when it occurs and base it on how it is handles.

try {
return new HueSyncHandler(thing, this.httpClientFactory);
} catch (Exception e) {
// TODO: Implementation ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle the TODO

bundles/org.openhab.binding.huesync/README.md Outdated Show resolved Hide resolved
@pgfeller
Copy link
Contributor Author

@lsiepel Thank you for the fast review! I'll work on the findings as soon as possible. I'll split the work into multime commits - as I can sometimes not allocate a lot of time to work on the project. Once I've addressed all feedback I'll send you a message. I'll not mark the comments as resolved, but add a comment (e.g. commit id).

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/philips-hdmi-sync-api/111679/52

pgfeller and others added 16 commits October 30, 2024 20:49
…binding/huesync/internal/handler/tasks/HueSyncRegistrationTask.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/handler/HueSyncHandler.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncDeviceConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/handler/tasks/HueSyncUpdateTask.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
Update names to follow coding convention.

Signed-off-by: Patrik Gfeller <[email protected]>
Obsolete image file removed.

Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncDeviceConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncDeviceConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/connection/HueSyncDeviceConnection.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
…binding/huesync/internal/discovery/HueSyncDiscoveryParticipant.java

Co-authored-by: lsiepel <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When looking at some resolved comments, i noticed some new and wanted to share them right away.

Besides these i want to point you to the coding guidelines regarding logging:
https://www.openhab.org/docs/developer/guidelines.html#f-logging


### Registration

To communicate with the sync box, you need to couple the thing with the hardware (registration). The thing will start this process automatically. To complete the registration you just press the "coupling" button on the sync box for 3 seconds.:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each sentence on its own line

Suggested change
To communicate with the sync box, you need to couple the thing with the hardware (registration). The thing will start this process automatically. To complete the registration you just press the "coupling" button on the sync box for 3 seconds.:
To communicate with the sync box, you need to couple the thing with the hardware (registration).
The thing will start this process automatically.
To complete the registration you just press the "coupling" button on the sync box for 3 seconds.:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The logging is still no my todo -... but I'll have a look at the guidelines. The markdown mistake I make every time. I wonder if the linter could mark them as error as well - so that you and other reviewers do not need to waste time on such trivialities. Same goes for naming conventions - as every project I'm working on uses different conventions and sometimes I do not work on one of them for a while it is easy to do it wrong (and if I read the coventions every time again, the timeslot is already over ...).

The CI/CD and linter of the project already has a very high quality. I'm not familiar with the stack used - but maybe the investment in some more linter rules would increase productivity and review overhead. Do you know who is the maintainer of the pipeline? Then I could ask if that's easy to achieve - or a bigger project.

Something else the README: I had a look at the Hue binding README as a reference and noticed, that it used some images for visualization. We removed them from the README; but honestly if possible I would like to re-introduce them - as it seems other bindings do so as well and I realy think the documentation looks better without them. Would it be acceptable to re-introduce them?

https://www.openhab.org/addons/bindings/hue/#philips-hue-binding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confectrician did a lot of work on the documentation/linter. I use vscode and it markes all the issue by default (atleast i'm not aware that i added an extension). Maybe the static code analysis can be extended to cehck the thing-structure.xml files for naming convention. If you can make the life easier for contributers and maintainers, your are very welcome!

Regarding the images i prefer that you leave them out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

[hue] Add Hue Sync Box
7 participants