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

[hue] Implement CLIP 2 / API v2 #13570

Merged
merged 155 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
ccf6b23
[hue] second initial contribution
andrewfg Jan 8, 2023
df6e4a2
[hue] throttling; unused class; reviewer comments
andrewfg Jan 9, 2023
b3aef78
[hue] tweak ping, timeout
andrewfg Jan 10, 2023
d83dcf6
[hue] reset GET streams; adopt reviewer suggestions
andrewfg Jan 12, 2023
70d7d28
[hue] adopt reviewer suggestion
andrewfg Jan 12, 2023
7579915
[hue] fix data frame parsing
andrewfg Jan 12, 2023
750babc
[hue] add link to developer note
andrewfg Jan 13, 2023
57d7116
[hue] throttling and check alive
andrewfg Jan 23, 2023
869f52f
[hue] tweaks regarding http/2
andrewfg Jan 27, 2023
a18dbbe
[hue] adope reviewer findings
andrewfg Feb 12, 2023
599c4b6
[hue] fix enum exception handling
andrewfg Feb 13, 2023
f75a902
[hue] add serial number property
andrewfg Feb 13, 2023
8f258ae
[hue] discovery migrates legacy thing attributes
andrewfg Feb 15, 2023
b2ad3c7
[hue] channel labels and descriptions
andrewfg Feb 15, 2023
62c92f9
[hue] typo
andrewfg Feb 15, 2023
e245cf7
[hue] use osgi constructor injection
andrewfg Feb 15, 2023
1d81c2a
[hue] tweak legacy thing migration
andrewfg Feb 16, 2023
940854b
[hue] delete overridden method
andrewfg Feb 16, 2023
0c92dbd
[hue] fix incorrect ending match
andrewfg Feb 17, 2023
24345fc
[hue] add replication of channel/item links
andrewfg Feb 17, 2023
b2627c7
[hue] update readme
andrewfg Feb 17, 2023
9d78ca7
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg Feb 18, 2023
0b9f51a
[hue] include itests in project build again (??)
andrewfg Feb 18, 2023
20be416
[hue] add itest to reactor
andrewfg Feb 18, 2023
9142ae1
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Feb 18, 2023
7bbdc3c
hue] add JavaDocs
andrewfg Feb 18, 2023
d4ff605
[hue] add support for grouped lights
andrewfg Feb 20, 2023
f055050
[hue] update all thing types
andrewfg Feb 21, 2023
6e329fb
[hue] handle GO_AWAY commands silently
andrewfg Feb 27, 2023
6a01400
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg Mar 1, 2023
c7fcca3
[hue] resolve merge conflict
andrewfg Mar 2, 2023
0e19b9b
[hue] bump Jetty version
andrewfg Mar 3, 2023
3ab7af7
[hue] performance improvements
andrewfg Mar 3, 2023
44353cc
[hue] typo
andrewfg Mar 3, 2023
7eb26e9
[hue] fix synchronize and restore state
andrewfg Mar 4, 2023
c14a80a
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Mar 4, 2023
9d85e3f
[hue] fix compiler warning
andrewfg Mar 5, 2023
684c31c
[hue] prepare for core to provide Http2ClientFactory
andrewfg Mar 5, 2023
e8f7082
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg Mar 5, 2023
6c7efe0
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Mar 6, 2023
eb644b8
[hue] adopt reviewer suggestions
andrewfg Mar 6, 2023
296cd2e
[hue] removed the itests again again again..
andrewfg Mar 6, 2023
646f663
[hue] Zigbee is not a camel
andrewfg Mar 6, 2023
a21cf78
[hue] prepare for OH Core PR #3433, fix communication issues
andrewfg Mar 9, 2023
6975089
[hue] fix discovery of groupedLight
andrewfg Mar 9, 2023
fbc6618
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg Mar 13, 2023
6863ce8
[hue] implement OH Core #3433
andrewfg Mar 13, 2023
b138dc8
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg Mar 13, 2023
541e3e5
[hue] remove itest.bndrun (yet again)
andrewfg Mar 13, 2023
ba41f42
[hue] console applet improvements
andrewfg Mar 14, 2023
3a47184
[hue] exclude bridge itself from console applet
andrewfg Mar 15, 2023
d7c0fab
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Mar 15, 2023
1be6703
[hue] silent delayed restart
andrewfg Mar 20, 2023
c44d073
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Mar 20, 2023
25ff10f
[hue] Eliminate rounding errors on JUnit HSB comparisons.
andrewfg Mar 21, 2023
21ff009
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Mar 23, 2023
11f8987
[hue] fix itests
andrewfg Mar 23, 2023
3b4af42
[hue] adopt ColorUtil XY utilities from core PR #3434
andrewfg Mar 24, 2023
5488b51
[hue] Adopt feedback from user testing
andrewfg Mar 29, 2023
215dbf3
[hue] Adopt reviewer suggestions
andrewfg Mar 29, 2023
fb4c666
[hue] adopt reviewer and test user feedback
andrewfg Apr 1, 2023
7339c56
[hue] cosmetics
andrewfg Apr 1, 2023
216e5f7
[hue] bug fixes after testing
andrewfg Apr 2, 2023
1b79e42
[hue] delete unused logger
andrewfg Apr 2, 2023
100cb85
[hue] support parameteized localization
andrewfg Apr 2, 2023
00ba5b7
[hue] adopt reviewer suggestion
andrewfg Apr 2, 2023
3360dc6
[hue] adopt reviwer suggestion
andrewfg Apr 2, 2023
fc8bbbe
[hue] adopt reviewer suggestions
andrewfg Apr 3, 2023
3ec4e8d
[hue] change to scene dropdown model
andrewfg Apr 3, 2023
b6344e1
[hue] cache multi frame data as byte[] rather than string
andrewfg Apr 5, 2023
db66329
[hue] reduce logging
andrewfg Apr 5, 2023
9dc796c
[hue] tweaks
andrewfg Apr 5, 2023
598bd59
[hue] adopt reviewer suggestions
andrewfg Apr 6, 2023
b9d6d4f
[hue] trim() might wrongly remove whitespace within a split json payload
andrewfg Apr 6, 2023
812f441
[hue] use stripLeading()
andrewfg Apr 6, 2023
23b2565
[hue] same codebase for oh 3.4.x and oh 4.0
andrewfg Apr 6, 2023
b335678
[hue] change thing type to lower case
andrewfg Apr 6, 2023
e84d218
[hue] dynamic update of scene channel
andrewfg Apr 7, 2023
a06162d
[hue] adopt core ColorUtils; improve Gamut, MirekSchema handling
andrewfg Apr 9, 2023
fa0f473
[hue] clean up scene channel code and docu
andrewfg Apr 10, 2023
8e138e4
[hue] tweaks inspired by discussion in issue #12643
andrewfg Apr 10, 2023
cd04c2e
[hue] adopt official naming convention
andrewfg Apr 11, 2023
f43aee3
[hue] more related to naming convention
andrewfg Apr 11, 2023
70ad22a
[hue] corrections to documentation
andrewfg Apr 14, 2023
bfecc1d
[hue] corrections to documentation
andrewfg Apr 14, 2023
e5cbb4a
[hue] add idv1 to console output
andrewfg Apr 14, 2023
941a5d3
[hue] take over legacy thing id when available
andrewfg Apr 16, 2023
6817bca
[hue] multi hub migration; add alert & effect channels
andrewfg Apr 18, 2023
6b32cf2
[hue] improve synch when adding things
andrewfg Apr 18, 2023
1c30fc2
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Apr 19, 2023
dc408cd
[hue] initialize scene channel; improve thread synchronization
andrewfg Apr 20, 2023
c731d49
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Apr 20, 2023
112b11e
[hue] improve state synchronization and logging
andrewfg Apr 21, 2023
c149867
[hue] revert regression and memory leak
andrewfg Apr 21, 2023
cd784b6
[hue] adopt reviewer suggestions
andrewfg Apr 22, 2023
bc11446
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Apr 22, 2023
445d944
[hue] add support for dynamics
andrewfg Apr 22, 2023
d90f415
Merge branch '#13456-hue-clip2' of https://github.com/andrewfg/openha…
andrewfg Apr 22, 2023
22e1c67
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Apr 23, 2023
675ae77
[hue] dynamics tweaks
andrewfg Apr 23, 2023
e6ccbda
[hue] implement thing action; tweak dynamics; fix resolution
andrewfg Apr 23, 2023
364b736
[hue] fix scene actualization and dynamics
andrewfg Apr 25, 2023
1139b25
[hue] fix DTO syntax error
andrewfg Apr 26, 2023
155ba51
[hue] improve UoM, and scene initial;ization
andrewfg Apr 27, 2023
c3de027
[hue] fix mass download sequence; tweak channel type
andrewfg Apr 27, 2023
f368614
[hue] improve scene initialization (again); fix mDNS bug
andrewfg Apr 29, 2023
7f0999f
[hue] adapt Nupnp discovery to API v2
andrewfg Apr 29, 2023
70e86da
[hue] fix itests for NUPnP
andrewfg Apr 30, 2023
799fc1c
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg May 2, 2023
84b148d
[hue] adopt (most) reviewer suggestions
andrewfg May 2, 2023
8a49bd6
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg May 5, 2023
5b18c9e
[hue] synch changes in discovery
andrewfg May 5, 2023
c0c36a7
[hue] adopt reviewer suggestions
andrewfg May 5, 2023
639d29d
[hue] adopt reviewer suggestion
andrewfg May 5, 2023
e550695
[hue] implement minDimLevel; cosmetics
andrewfg May 9, 2023
d8f7035
[hue] remove zigbee channel from documentation
andrewfg May 12, 2023
e2935b5
Merge remote-tracking branch 'upstream/main' into #13456-hue-clip2
andrewfg May 14, 2023
c74f3d7
[hue] synch PRs
andrewfg May 15, 2023
d83f6dc
[hue] fix bridge overload issue
andrewfg May 17, 2023
b72796d
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg May 22, 2023
e105c99
[hue] modify advanced channels as suggested
andrewfg Jun 1, 2023
eb9a502
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Jun 1, 2023
37650ae
[hue] improve readability
andrewfg Jun 1, 2023
cba0c6b
[hue] fix typos
andrewfg Jun 1, 2023
0dae88a
[hue] fix color temperature, use uom to convert
andrewfg Jun 2, 2023
29ea0da
[hue] change channel definitions according to reviewer suggestions
andrewfg Jun 3, 2023
160f7d4
[hue] adjust channel sort order
andrewfg Jun 4, 2023
e06fce9
[hue] adopt reviewer suggestions
andrewfg Jun 5, 2023
d0704a3
[hue] add advanced setters; fix thing offline state
andrewfg Jun 5, 2023
37f1481
[hue] fix thing offline state (again)
andrewfg Jun 5, 2023
46cca34
[hue] offline/config-error third try
andrewfg Jun 8, 2023
7582b53
[hue] offline/config-error fourth try
andrewfg Jun 9, 2023
a931a88
[hue] delete duplicate property
andrewfg Jun 11, 2023
1225b77
[hue] revert prior; own thread pool; restart bug
andrewfg Jun 24, 2023
8ea5ac4
[hue] adopt reviewer suggestions
andrewfg Jun 24, 2023
92f5afa
[hue] more efficient setColorTemperatureAbsolute()
andrewfg Jun 24, 2023
4cc2890
[hue] fix compiler warning
andrewfg Jun 24, 2023
abe2960
[hue] adopt reviewer requests (part 1)
andrewfg Jun 25, 2023
45de44e
[hue] adopt reviewer requests (part 2)
andrewfg Jun 25, 2023
330fe9a
[hue] adopt reviewer requests (part 3)
andrewfg Jun 26, 2023
77cd411
[hue] tweaks
andrewfg Jun 26, 2023
e8442d2
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Jun 26, 2023
6e15f61
Merge branch 'openhab:main' into #13456-hue-clip2
andrewfg Jun 27, 2023
7df14c3
[hue] adopt reviewer suggestions
andrewfg Jun 27, 2023
91e1ec9
[hue] adopt reviewer suggestions
andrewfg Jun 28, 2023
f4ce0e9
[hue] adopt reviewer suggestion
andrewfg Jun 28, 2023
3b50d03
[hue] adopt reviewer suggestions
andrewfg Jun 29, 2023
80c9a7a
[hue] typo
andrewfg Jun 29, 2023
518da05
[hue] fix regression from review
andrewfg Jun 29, 2023
a9fc9a4
[hue] adopt reviewer suggestion
andrewfg Jun 29, 2023
aca84e3
[hue] adopt reviewer suggestion again again
andrewfg Jun 29, 2023
0dea4e1
[hue] save a now call
andrewfg Jun 29, 2023
92bd49f
[hue] adopt reviewer suggestions
andrewfg Jun 29, 2023
43fb612
[hue] fix syntax
andrewfg Jun 30, 2023
d7d174f
[hue] adopt reviewer suggestion; allow interrupt on thread cancel
andrewfg Jul 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
382 changes: 54 additions & 328 deletions bundles/org.openhab.binding.hue/README.md

Large diffs are not rendered by default.

Binary file added bundles/org.openhab.binding.hue/doc/hue2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
358 changes: 358 additions & 0 deletions bundles/org.openhab.binding.hue/doc/readme_v1.md

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions bundles/org.openhab.binding.hue/doc/readme_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Philips Hue Binding Configuration for API v2

[Back to Overview](../README.md#philips-hue-binding)

## Supported Things

The binding supports `bridge-api2`, `device`, `room`, and `zone` thing types.
The `bridge-api2` thing type represents the Hue Bridge which is the server for all other things.
The `device` thing type represents a piece of physical equipment in the home.
Such `device` things may contain either a *light*, a *button*, or (one or more) *sensors*.
Lights can be of any type from a simple on/off light, through dimmable monochrome lights, to full colour dimmable lights.
Buttons are devices having one or more push buttons.
Sensors can be (for example) light level sensors, temperature sensors, or motion sensors.
The `room` and `zone` thing type represents logical groupings of equipment in the home, either within a specific room, or a logical group of equipment.

## Thing Configuration

### Bridge

The Hue Bridge requires the IP address as a configuration value in order for the binding to know where to access it.
It requires an 'application key' to authenticate against the Hue Bridge.
This may be copied from an API v1 installation, or it may be automatically generated (press button to authenticate).
Please note that the generated application key cannot be written automatically to the `.things` file, and has to be set manually.
The generated application key can be found, after pressing the authentication button on the bridge, with the following console command: `openhab:hue <bridgeUID> applicationkey`.
The application key can be set using the `applicationKey` configuration value, e.g.:

```java
Bridge hue:bridge-api2:1 [ ipAddress="192.168.0.64", applicationKey="qwertzuiopasdfghjklyxcvbnm1234" ]
```

| Parameter | Description |
|--------------------------|----------------------------------------------------------------------------------------------------|
| ipAddress | Network address of the Hue Bridge. **Mandatory**. |
| applicationKey | A code generated by the bridge that allows to access the API. **Mandatory** |
| checkMinutes | Interval in minutes between retrying the HTTP 2 and SSE connections. Default is 60. **Advanced** |
| useSelfSignedCertificate | Use self-signed certificate for HTTPS connection to Hue Bridge. Default is `true`. **Advanced** |

### Devices, Rooms, and Zones

Apart from the Bridge, there are three other types of thing -- namely `device`, `room`, and `zone`.
Device things represent physical hardware devices in the system, whereas `room` and `zone` things represent sets of physical lights, either in a room or a zone.
In addition to regular rooms and zones, there is a 'super' `zone` that allows you to control all of the lights in the system.

All things are identified by a unique Resource Identifier string that the Hue Bridge assigns to them e.g. `d1ae958e-8908-449a-9897-7f10f9b8d4c2`.
Thus, all it needs for manual configuration is this single value like
andrewfg marked this conversation as resolved.
Show resolved Hide resolved

```java
device officelamp "Lamp 1" @ "Office" [ resourceId="d1ae958e-8908-449a-9897-7f10f9b8d4c2" ]
..
zone kitchenLights "Kitchen Down Lights" @ "Kitchen" [ resourceId="7f10f9b8-8908-449a-9897-d4c2d1ae958e" ]
```

You can get a list of all devices in the bridge and their respective Resource Ids by entering the following console command: `openhab:hue <bridgeUID> things`
See [console command](#console-command-for-finding-resourceids)

The configuration of all things (as described above) is the same regardless of whether it is a device containing a light, a button, or (one or more) sensors, or whether it is a room or zone.

### Channels for Devices

Device things support some of the following channels:
andrewfg marked this conversation as resolved.
Show resolved Hide resolved

| Channel Type ID | Item Type | Description |
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
|---------------------|--------------------|---------------------------------------------------------------------------------------|
| switch | Switch | This channel supports switching the device on and off. |
| color | Color | This channel supports full color control with hue, saturation and brightness values. |
| brightness | Dimmer | This channel supports adjusting the brightness value. |
| color-temperature | Dimmer | This channel supports adjusting the color temperature from cold (0%) to warm (100%). |
| color-temp-kelvin | Number:Temperature | This channel supports adjusting the color temperature in Kelvin. |
| alert | String | This channel allows setting an alert on a light e.g. flashing them. |
| effect | String | This channel allows setting an effect on a light e.g. 'candle' effect. |
| button-last-event | Number | This channel shows which button was last pressed in the device. |
| rotary-steps | Number | This channel shows the number of rotary steps of the last rotary dial movement. |
| motion | Switch | This channel shows if motion has been detected by the sensor. |
| motion-enabled | Switch | This channel supports enabling / disabling the motion sensor. |
| light-level | Number | This channel shows the current light level measured by the sensor. |
| light-level-enabled | Switch | This channel supports enabling / disabling the light level sensor. |
| temperature | Number:Temperature | This channel shows the current temperature measured by the sensor. |
| temperature-enabled | Switch | This channel supports enabling / disabling the temperature sensor. |
| battery-level | Number | This channel shows the battery level. |
| battery-low | Switch | This channel indicates whether the battery is low or not. |
| zigbee-status | String | This channel provides information about the status of the Zigbee connection. |
| last-updated | DateTime | This channel the date and time when the thing state was last updated. |

The exact list of channels in a given device is determined at run time when the system is started.
Each device reports its own live list of capabilities, and the respective list of channels is created accordingly.

The `zigbee-status` indicates the connectivity state of the device.
If the device has connectivity issues, the thing state will change to 'OFFLINE'

The `button-last-event` channel value is a number that is calculated from the following formula:

```text
value = (button_id * 1000) + event_id;
```

In a single button device, the `button_id` is 1, whereas in a multi- button device the `button_id` can be either 1, 2, 3, or 4 depending on which button was pressed.
The `event_id` can have the following values:

| Event | Value |
|----------------------|-------|
| INITIAL_PRESS | 0 |
| REPEAT | 1 |
| SHORT_RELEASE | 2 |
| LONG_RELEASE | 3 |
| DOUBLE_SHORT_RELEASE | 4 |

So (for example) the channel value `1002` ((1 * 1000) + 2) means that the second button in the device had a short release event.

The `rotary-steps` channel value is the number of steps corresponding to the last movement of a rotary dial.
A positive number means the dial was rotated clock-wise, whereas a negative number means it was roated counter-clockwise.

### Channels for Rooms and Zones

Room and Zone things allow you to control the lights in a given zone or room.
They support the following channels:

| Channel Type ID | Item Type | Description |
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
|---------------------|--------------------|---------------------------------------------------------------------------------------|
| switch | Switch | This channel supports switching the lights on and off. |
| brightness | Dimmer | This channel supports adjusting the brightness value. |
| scene<sup>1)</sup> | String | Setting the string to a valid scene friendly name activates the respective scene. |
| alert<sup>1)</sup> | String | This channel allows setting an alert on the lights e.g. flashing them. |

<sup>1)</sup> The scene and alert channels are optional.
If the respective room or zone has no scenes or alerts associated with it, the respective channel will not be shown.

## Console Command for finding ResourceIds

The openHAB console has a command named `openhab:hue` that (among other things) lists the `resourceId` of all device things in the bridge.
The console command usage is `openhab:hue <brigeUID> things`.
An exampe of such a console command, and its respective output, is shown below..

```text
openhab> openhab:hue hue:bridge-api2:g24 things
Bridge hue:bridge-api2:g24 "Philips Hue Bridge" [ipAddress="192.168.1.234", applicationKey="abcdefghijklmnopqrstuvwxyz0123456789ABCD"] {
Thing device 11111111-2222-3333-4444-555555555555 "Standard Lamp L" [resourceId="11111111-2222-3333-4444-555555555555"] // Hue color lamp
Thing device 11111111-2222-3333-4444-666666666666 "Kitchen Wallplate Switch" [resourceId="11111111-2222-3333-4444-666666666666"] // Hue wall switch module
..
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
}
```

The `openhab:hue <brigeUID> things` command produces an output that can be used to directly create a `.things' file, as shown below..
andrewfg marked this conversation as resolved.
Show resolved Hide resolved

```text
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
openhab> openhab:hue hue:bridge-api2:g24 things > myThingsFile.things
```

## Full Example

### demo.things:

```java
Bridge hue:bridge-api2:g24 "Philips Hue Hub" @ "Home" [ipAddress="192.168.1.234", applicationKey="abcdefghijklmnopqrstuvwxyz0123456789ABCD"] {
Thing device 11111111-2222-3333-4444-555555555555 "Living Room Standard Lamp Left" @ "Living Room" [resourceId="11111111-2222-3333-4444-555555555555"]
Thing device 11111111-2222-3333-4444-666666666666 "Kitchen Wallplate Switch" @ "Kitchen" [resourceId="11111111-2222-3333-4444-666666666666"]

Thing zone 11111111-2222-3333-4444-666666666666 "Kitchen Lights" @ "Kitchen" [resourceId="11111111-2222-3333-4444-666666666666"]
}
```

### demo.items:

```java
Color Living_Room_Standard_Lamp_Left_Colour "Living Room Standard Lamp Left Colour" {channel="hue:device:g24:11111111-2222-3333-4444-555555555555:color"}
Dimmer Living_Room_Standard_Lamp_Left_Brightness "Living Room Standard Lamp Left Brightness [%.0f %%]" {channel="hue:device:g24:11111111-2222-3333-4444-555555555555:brightness"}
Switch Living_Room_Standard_Lamp_Left_Switch "Living Room Standard Lamp Left Switch" (g_Lights_On_Count) {channel="hue:device:g24:11111111-2222-3333-4444-555555555555:switch"}

Number Kitchen_Wallplate_Switch_Last_Event "Kitchen Wallplate Switch Last Event" {channel="hue:device:g24:11111111-2222-3333-4444-666666666666:button-last-event"}
Switch Kitchen_Wallplate_Switch_Battery_Low_Alarm "Kitchen Wallplate Switch Battery Low Alarm" {channel="hue:device:g24:11111111-2222-3333-4444-666666666666:battery-low"}
```

### demo.sitemap:

```perl
sitemap demo label="Hue" {
Frame label="Standard Lamp" {
Switch item=Living_Room_Standard_Lamp_Left_Switch
Slider item=Living_Room_Standard_Lamp_Left_Brightness
Colorpicker item=Living_Room_Standard_Lamp_Left_Colour
}
}
```

[Back to Overview](../README.md#philips-hue-binding)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*/
package org.openhab.binding.hue.internal;

import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

Expand Down Expand Up @@ -53,9 +58,14 @@ public class HueBindingConstants {
public static final ThingTypeUID THING_TYPE_GEOFENCE_SENSOR = new ThingTypeUID(BINDING_ID, "geofencesensor");
public static final ThingTypeUID THING_TYPE_TEMPERATURE_SENSOR = new ThingTypeUID(BINDING_ID, "0302");
public static final ThingTypeUID THING_TYPE_LIGHT_LEVEL_SENSOR = new ThingTypeUID(BINDING_ID, "0106");

public static final ThingTypeUID THING_TYPE_GROUP = new ThingTypeUID(BINDING_ID, "group");

public static final Set<ThingTypeUID> V1_THING_TYPE_UIDS = Set.of(THING_TYPE_COLOR_LIGHT,
THING_TYPE_COLOR_TEMPERATURE_LIGHT, THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_EXTENDED_COLOR_LIGHT,
THING_TYPE_ON_OFF_LIGHT, THING_TYPE_ON_OFF_PLUG, THING_TYPE_DIMMABLE_PLUG, THING_TYPE_DIMMER_SWITCH,
THING_TYPE_TAP_SWITCH, THING_TYPE_PRESENCE_SENSOR, THING_TYPE_TEMPERATURE_SENSOR,
THING_TYPE_LIGHT_LEVEL_SENSOR, THING_TYPE_GROUP);

// List all channels
public static final String CHANNEL_COLORTEMPERATURE = "color_temperature";
public static final String CHANNEL_COLORTEMPERATURE_ABS = "color_temperature_abs";
Expand Down Expand Up @@ -94,11 +104,22 @@ public class HueBindingConstants {
// Thing configuration properties
public static final String LIGHT_ID = "lightId";
public static final String SENSOR_ID = "sensorId";
public static final String PRODUCT_NAME = "productName";
public static final String PROPERTY_PRODUCT_NAME = "productName";
public static final String UNIQUE_ID = "uniqueId";
public static final String FADETIME = "fadetime";
public static final String GROUP_ID = "groupId";

// property names for API v2
public static final String PROPERTY_RESOURCE_ID = "resourceId";
public static final String PROPERTY_RESOURCE_TYPE = "resourceType";
public static final String PROPERTY_RESOURCE_NAME = "resourceName";
public static final String PROPERTY_RESOURCE_ARCHETYPE = "resourceArchetype";
public static final String PROPERTY_PRODUCT_ARCHETYPE = "productArchetype";
public static final String PROPERTY_PRODUCT_CERTIFIED = "productCertified";
public static final String PROPERTY_LEGACY_THING_UID = "legacyThingUID";
public static final String PROPERTY_OWNER = "owner";
public static final String PROPERTY_OWNER_TYPE = "ownerType";

public static final String NORMALIZE_ID_REGEX = "[^a-zA-Z0-9_]";

//
Expand All @@ -107,4 +128,54 @@ public class HueBindingConstants {

// Config status messages
public static final String IP_ADDRESS_MISSING = "missing-ip-address-configuration";

// thing types for API v2
public static final ThingTypeUID THING_TYPE_BRIDGE_API2 = new ThingTypeUID(BINDING_ID, "bridge-api2");
public static final ThingTypeUID THING_TYPE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
public static final ThingTypeUID THING_TYPE_ZONE = new ThingTypeUID(BINDING_ID, "zone");
public static final ThingTypeUID THING_TYPE_ROOM = new ThingTypeUID(BINDING_ID, "room");

// channels for API v2
public static final String CHANNEL_2_BRIGHTNESS = CHANNEL_BRIGHTNESS;
public static final String CHANNEL_2_COLOR = CHANNEL_COLOR;
public static final String CHANNEL_2_COLOR_TEMPERATURE = "color-temperature";
public static final String CHANNEL_2_COLOR_TEMP_KELVIN = "color-temp-kelvin";
public static final String CHANNEL_2_SWITCH = CHANNEL_SWITCH;
public static final String CHANNEL_2_SCENE = CHANNEL_SCENE;
public static final String CHANNEL_2_ALERT = CHANNEL_ALERT;
public static final String CHANNEL_2_EFFECT = CHANNEL_EFFECT;
public static final String CHANNEL_2_BUTTON_LAST_EVENT = "button-last-event";
public static final String CHANNEL_2_ROTARY_STEPS = "rotary-steps";
public static final String CHANNEL_2_MOTION = "motion";
public static final String CHANNEL_2_MOTION_ENABLED = "motion-enabled";
public static final String CHANNEL_2_LIGHT_LEVEL = "light-level";
public static final String CHANNEL_2_LIGHT_LEVEL_ENABLED = "light-level-enabled";
public static final String CHANNEL_2_TEMPERATURE = CHANNEL_TEMPERATURE;
public static final String CHANNEL_2_TEMPERATURE_ENABLED = "temperature-enabled";
public static final String CHANNEL_2_BATTERY_LEVEL = "battery-level";
public static final String CHANNEL_2_BATTERY_LOW = "battery-low";
public static final String CHANNEL_2_ZIGBEE_STATUS = "zigbee-status";
public static final String CHANNEL_2_LAST_UPDATED = "last-updated";

/*
* Map of API v1 channel IDs against API v2 channel IDs where, if the v1 channel exists in the system, then we
* should try to replicate the channel/item links from the v1 channel into the respective v2 channel.
*/
public static final Map<String, String> REPLICATE_CHANNEL_ID_MAP = Stream.of(new String[][] { //
{ CHANNEL_BRIGHTNESS, CHANNEL_2_BRIGHTNESS }, //
{ CHANNEL_COLOR, CHANNEL_2_COLOR }, //
{ CHANNEL_SWITCH, CHANNEL_2_SWITCH }, //
{ CHANNEL_SCENE, CHANNEL_2_SCENE }, //
{ CHANNEL_COLORTEMPERATURE, CHANNEL_2_COLOR_TEMPERATURE }, //
{ CHANNEL_COLORTEMPERATURE_ABS, CHANNEL_2_COLOR_TEMP_KELVIN }, //
{ CHANNEL_DIMMER_SWITCH, CHANNEL_2_BUTTON_LAST_EVENT }, //
{ CHANNEL_LIGHT_LEVEL, CHANNEL_2_LIGHT_LEVEL }, //
{ CHANNEL_PRESENCE, CHANNEL_2_MOTION }, //
{ CHANNEL_TEMPERATURE, CHANNEL_2_TEMPERATURE }, //
{ CHANNEL_BATTERY_LEVEL, CHANNEL_2_BATTERY_LEVEL }, //
{ CHANNEL_BATTERY_LOW, CHANNEL_2_BATTERY_LOW }, //
{ CHANNEL_LAST_UPDATED, CHANNEL_2_LAST_UPDATED } //
}).collect(Collectors.toMap(entry -> entry[0], entry -> entry[1]));
andrewfg marked this conversation as resolved.
Show resolved Hide resolved

public static final String ALL_LIGHTS_KEY = "discovery.group.all_lights.label";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2023 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.hue.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* Configuration for the Clip2BridgeHandler.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public class Clip2BridgeConfig {
public static final String APPLICATION_KEY = "applicationKey";

public @Nullable String ipAddress;
public @Nullable String applicationKey;
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
public int checkMinutes = 60;
public boolean useSelfSignedCertificate = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2023 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.hue.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* Configuration for CLIP V2 things.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public class Clip2ThingConfig {
public @Nullable String resourceId;
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
}
Loading