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][WIP] Hue Play HDMI Sync Box Binding - Initial contribution #16516

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9e7fa3a
☠️ Binding skeleton created for org.openhab.binding.huesync
pgfeller Feb 8, 2024
bc72f9a
🔃 Version Sync - we'll use 4.1.x for development ...
pgfeller Feb 9, 2024
377df2f
💳 updated credits in headers (initial code by Marco Kawon)
pgfeller Feb 9, 2024
360f167
✏️ class & filenames updated to be consistent with other bindings
pgfeller Feb 9, 2024
676fe38
🔎 skeleton mDNS discovery implemented
pgfeller Feb 9, 2024
452df77
🔎 mDNS device discovery - use API to get device information (wip 🔨)
pgfeller Feb 10, 2024
0b18704
🔐 preparation(s) to support SSL (wip), create ThingUID for discovered…
pgfeller Feb 13, 2024
f72a383
🏭 Inbox/Thing Factory (wip)
pgfeller Feb 14, 2024
edbf604
🔎 device discovery improvements (wip)
pgfeller Feb 16, 2024
0c59b98
💬 Basic JSON de-serialization added to Thing-Handler to get device in…
pgfeller Feb 17, 2024
f52e9b7
🔐 SSL Handshake & 🔎 Discovery working - 👍
pgfeller Feb 24, 2024
3178f26
🔓 Registration (acquire API token) - wip 🔧
pgfeller Feb 25, 2024
eab70d1
🔧 Prototype to use resource strings for loggger, exceptions & UI ...
pgfeller Feb 29, 2024
f7a9a76
🔓 Registration (acquire API token) - wip 🔧
pgfeller Mar 2, 2024
a2a03ec
🔓 Registration (acquire API token)
pgfeller Mar 7, 2024
416137b
⏫ pom version change to 4.2
pgfeller Mar 12, 2024
ba801a2
📜 linter fix ...
pgfeller Mar 12, 2024
a42500f
📜 linter fix
pgfeller Mar 13, 2024
e51e230
📜 ... temporary refactoring/removal of log message consistency mechan…
pgfeller Mar 16, 2024
7c7bd48
📦 Device information DTO
pgfeller Mar 17, 2024
397dacb
Merge branch 'openhab:main' into 10218-hue-add-hue-sync-box
pgfeller Mar 18, 2024
5b5f6e6
👤 Added myself as owner of the huesync binding
pgfeller Mar 21, 2024
d3f4f64
🔧 refactoring to simplify API connection
pgfeller Mar 22, 2024
c6ce2dc
feat(unregistration): 👋 Device unregistration
pgfeller Mar 23, 2024
51fe84e
fix(linter): 🔎 Format should be constant. Use placeholder to reduce t…
pgfeller Mar 23, 2024
fdf069e
fix(linter): 🔎 Format should be constant. Use placeholder to reduce t…
pgfeller Mar 23, 2024
cd5b2b9
refactor: 📜 code moved and group areas added to improve overview
pgfeller Mar 29, 2024
31923c7
refactor: 📜 refactoring to simplify maintentance and pending implemen…
pgfeller Mar 31, 2024
8fae6c1
fix(linter): 🔎 linter performance check fixed
pgfeller Mar 31, 2024
9b01c45
feat(infrastructure): 🔌 check online/offline state (poll) - wip ...
pgfeller Apr 6, 2024
84f3704
refactor(code review): 🔎 improved null handling based on code review
pgfeller Apr 12, 2024
b51b136
refactor(code review): 🔎 improved null handling based on code review
pgfeller Apr 12, 2024
4a12cf1
refactor(code review): 🔎 improved null handling based on code review
pgfeller Apr 12, 2024
5e97fc4
refactor(code review): 🔎 improved null handling based on code review
pgfeller Apr 12, 2024
d992334
refactor(code review): 🔎 code split (single response) and better enca…
pgfeller Apr 15, 2024
3bdbdc7
refactor(code review): 🔎 improved null handling based on code review …
pgfeller Apr 15, 2024
2196f10
refactor(code review): 🔎 improved null handling based on code review
pgfeller Apr 18, 2024
7cce127
refactor(connection): 📜 Simplified authentication mechanism
pgfeller Apr 26, 2024
153d91f
refactor(communication): 📜 improved error handling and manual configu…
pgfeller Apr 30, 2024
a4e7e94
feat(channel): 🔧 firmware channel group added
pgfeller May 3, 2024
0549ac6
fix(channel): 🔃 keep properties and firmware channel information in sync
pgfeller May 7, 2024
ca9af19
feat(dto): 📺 HDMI Status DTO & Get API implemented
pgfeller May 8, 2024
9a33031
feat(channel): Some HDMI input and ouput channels added (read only) -…
pgfeller May 14, 2024
52fa73e
feat(channel): Additional channel `connection-status`added
pgfeller May 18, 2024
5481bfc
feat(channel): ➕ Additional channel `connection-lastSyncMode` added
pgfeller May 19, 2024
41208a7
Merge branch 'openhab:main' into 10218-hue-add-hue-sync-box
pgfeller May 25, 2024
1c948dd
refactor(dto class renamed): 📜 Dto classes renamed to include the nat…
pgfeller May 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -149,6 +149,7 @@
/bundles/org.openhab.binding.hpprinter/ @cossey
/bundles/org.openhab.binding.http/ @openhab/add-ons-maintainers
/bundles/org.openhab.binding.hue/ @cweitkamp @andrewfg
/bundles/org.openhab.binding.huesync/ @pgfeller
/bundles/org.openhab.binding.hydrawise/ @digitaldan
/bundles/org.openhab.binding.hyperion/ @tavalin
/bundles/org.openhab.binding.iammeter/ @lewei50
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Expand Up @@ -736,6 +736,11 @@
<artifactId>org.openhab.binding.hue</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.huesync</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.hydrawise</artifactId>
Expand Down
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.huesync/.gitignore
@@ -0,0 +1 @@
scripts
15 changes: 15 additions & 0 deletions bundles/org.openhab.binding.huesync/AUTHORS
@@ -0,0 +1,15 @@
# This is the list of huesync's significant contributors.
#
# This does not necessarily list everyone who has contributed code,
# To see the full list of contributors, see the revision history in
# source control.

@pgfeller - Patrik Gfeller <patrik.gfeller@proton.me>

# The binding used work from the following developvers as reference
# and base for the implementation:
@HHomey-GER - Marco Kawon (https://github.com/Homey-GER/openhab-addons)

@andrewfg - Andrew Fiddian-Green (hue binding)
@cweitkamp - Christoph Weitkamp (hue binding)

13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.huesync/NOTICE
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
100 changes: 100 additions & 0 deletions bundles/org.openhab.binding.huesync/README.md
@@ -0,0 +1,100 @@
# HueSync Binding

This binding integrates the [Play HDMI Sync Box](https://www.philips-hue.com/en-us/p/hue-play-hdmi-sync-box-/046677555221) into openHAB.
The integration happens directly through the Hue [HDMI Sync Box API](https://developers.meethue.com/develop/hue-entertainment/hue-hdmi-sync-box-api/) (not via a Hue Bridge).

![Play HDMI Sync Box](doc/bridge1.png)
![Play HDMI Sync Box](doc/bridge2.png)

## Supported Things

_Please describe the different supported things / devices including their ThingTypeUID within this section._
_Which different types are supported, which models were tested etc.?_
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._

- `bridge`: Short description of the Bridge, if any
- `sample`: Short description of the Thing with the ThingTypeUID `sample`

## Discovery

The beinding is using [mDNS](https://en.wikipedia.org/wiki/Multicast_DNS) to discover HDMI Sync devies 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](https://www.philips-hue.com/en-in/explore-hue/propositions/entertainment/hue-sync).

If the device is not discovered you can check if it is properly configured and discoverable in the network:

<details>
<summary>Linux (Ubuntu based distributions)</summary>

```bash
$ avahi-browse --resolve _huesync._tcp
+ wlp0s20f3 IPv4 HueSyncBox-XXXXXXXXXXX _huesync._tcp local
= wlp0s20f3 IPv4 HueSyncBox-XXXXXXXXXXX _huesync._tcp local
hostname = [XXXXXXXXXXX.local]
address = [192.168.0.12]
port = [443]
txt = ["name=Sync Box" "devicetype=HSB1" "uniqueid=XXXXXXXXXXX" "path=/api"]
```

</details>


## Thing Configuration

To enable the binding to communicate with the device, a registration is required.
Once the registration process is completed, the acquired token will authorize the binding to communicate with the device.
After initial discovery and thing creation the device will stay offline.
To complete the authentication you need to pressed the registration button on the sync box for 3 seconds.


_Describe what is needed to manually configure a thing, either through the UI or via a thing-file._
_This should be mainly about its mandatory and optional configuration parameters._

_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._

### `sample` Thing Configuration

| Name | Type | Description | Default | Required | Advanced |
|-----------------|---------|---------------------------------------|---------|----------|----------|
| hostname | text | Hostname or IP address of the device | N/A | yes | no |
| password | text | Password to access the device | N/A | yes | no |
| refreshInterval | integer | Interval the device is polled in sec. | 600 | no | yes |

## Channels

_Here you should provide information about available channel types, what their meaning is and how they can be used._

_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._

| Channel | Type | Read/Write | Description |
|---------|--------|------------|-----------------------------|
| control | Switch | RW | This is the control channel |

## Full Example

_Provide a full usage example based on textual configuration files._
_*.things, *.items examples are mandatory as textual configuration is well used by many users._
_*.sitemap examples are optional._

### Thing Configuration

```java
Example thing configuration goes here.
```
### Item Configuration

```java
Example item configuration goes here.
```

### Sitemap Configuration

```perl
Optional Sitemap configuration goes here.
Remove this section, if not needed.
```

## Any custom content here!

_Feel free to add additional sections for whatever you think should also be mentioned about your binding!_
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.huesync/pom.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.2.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.huesync</artifactId>

<name>openHAB Add-ons :: Bundles :: Hue Play HDMI Sync Box Binding</name>

</project>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.huesync-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-huesync" description="Hue HDMI Sync Box Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-mdns</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.huesync/${project.version}</bundle>
</feature>
</features>
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.huesync.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link HueSyncConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Patrik Gfeller - Initial contribution
*/
@NonNullByDefault
public class HueSyncConstants {
public static final String APPLICATION_NAME = "openHAB";

/** Minimal API Version required. Only apiLevel >= 7 is supported. */
public static final Integer MINIMAL_API_VERSION = 7;

public static final String BINDING_ID = "huesync";
public static final ThingTypeUID THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "box");

public static final String PARAMETER_HOST = "host";
public static final String PARAMETER_PORT = "port";

public static final Integer REGISTRATION_INITIAL_DELAY = 3;
public static final Integer REGISTRATION_INTERVAL = 1;

public static final String REGISTRATION_ID = "registrationId";
public static final String API_TOKEN = "apiAccessToken";
}
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.huesync.internal.api.dto;

/**
* HDMI Sync Box Device Information Cababilities DTO
*
* @author Patrik Gfeller - Initial Contribution
*
* @see <a href=
* "https://developers.meethue.com/develop/hue-entertainment/hue-hdmi-sync-box-api/#Resource%20Table">Hue
* HDMI Sync Box API</a>
*/
public class HueSyncDeviceInfoCapabilities {
/** The total number of IR codes configurable */
public int maxIrCodes;
/** The total number of Presets configurable */
public int maxPresets;
}
@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.huesync.internal.api.dto.device;

import java.util.Date;

import org.eclipse.jdt.annotation.Nullable;

/**
* HDMI Sync Box Device Information DTO - Extended information (only available
* to registered clients)
*
* @author Patrik Gfeller - Initial Contribution
*
* @see <a href=
* "https://developers.meethue.com/develop/hue-entertainment/hue-hdmi-sync-box-api/#Resource%20Table">Hue
* HDMI Sync Box API</a>
*/
public class HueSyncDetailedDeviceInfo extends HueSyncDeviceInfo {
public HueSyncDeteiledDeviceInfoWifi wifi;
public HueSyncDetailedDeviceInfoUpdate update;

/** UTC time when last check for update was performed. */
public Date lastCheckedUpdate;
/**
* Build number that is available to update to. Item is set to null when there
* is no update available.
*/
public @Nullable Integer updatableBuildNumber;
/**
* User readable version of the firmware the device can upgrade to. Item is set
* to null when there is no update available.
*/
public @Nullable String updatableFirmwareVersion;
/**
* 1 = regular; 0 = off in powersave, passthrough or sync mode; 2 = dimmed in
* powersave or passthrough mode and off in sync mode
*/
public int ledMode;
/** none, doSoftwareRestart, doFirmwareUpdate */
public String action;
public String pushlink;
}
@@ -0,0 +1,38 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.huesync.internal.api.dto.device;

/**
* HDMI Sync Box Device Information DTO - Automatic Firmware update
*
* @author Patrik Gfeller - Initial Contribution
*
* @see <a href=
* "https://developers.meethue.com/develop/hue-entertainment/hue-hdmi-sync-box-api/#Resource%20Table">Hue
* HDMI Sync Box API</a>
*/

public class HueSyncDetailedDeviceInfoUpdate {
/**
* Sync Box checks daily for a firmware update. If true, an available update
* will automatically be installed. This will be postponed if Sync Box is
* passing through content to the TV and being used.
*/
public boolean autoUpdateEnabled;
/**
* TC hour when the automatic update will check and execute, values 0 – 23.
* Default is 10. Ideally this value should be set to 3AM according to user’s
* timezone.
*/
public int autoUpdateTime;
}
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.huesync.internal.api.dto.device;

/**
* HDMI Sync Box Device Information DTO - Wifi connection information
*
* @author Patrik Gfeller - Initial Contribution
*
* @see <a href=
* "https://developers.meethue.com/develop/hue-entertainment/hue-hdmi-sync-box-api/#Resource%20Table">Hue
* HDMI Sync Box API</a>
*/
public class HueSyncDeteiledDeviceInfoWifi {
pgfeller marked this conversation as resolved.
Show resolved Hide resolved
/** Wifi SSID */
public String ssid;
/** 0 = not connected; 1 = weak; 2 = fair; 3 = good; 4 = excellent */
public int strength;
}