-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[homekit.binding] New HomeKit client binding #19340
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
Merged
Merged
Changes from 163 commits
Commits
Show all changes
192 commits
Select commit
Hold shift + click to select a range
ce7a3e1
initial contribution
andrewfg 72bb54a
work in progress
andrewfg f20fc81
work in progress
andrewfg 62aaa90
work in progress
andrewfg 1cc5a0b
Merge branch 'openhab:main' into homekit-client
andrewfg 1a1824a
work in progress
andrewfg 4cac1c8
Merge branch 'homekit-client' of https://github.com/andrewfg/openhab-…
andrewfg f11ec7f
work in progress
andrewfg 4417971
work in progress
andrewfg 6217919
work in progress
andrewfg 46a7904
fix wrong exception type
andrewfg 9de2d04
work in progress
andrewfg 84ff44a
work in progress
andrewfg 6151a88
work in progress
andrewfg 81706c8
work in progress
andrewfg 0477c23
work in progress
andrewfg 3ea7db7
Merge remote-tracking branch 'upstream/main' into homekit-client
andrewfg 1358bc2
work in progress
andrewfg 22878c2
line endings
andrewfg f03016a
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg a457726
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg 1115774
adopt first round copilot suggestions
andrewfg adc4f25
Update README.md
andrewfg 16864eb
adopt copilot second suggestions
andrewfg a42501a
work in progress
andrewfg b75d1f3
fix unit testing; add support for property channels
andrewfg 9a63e20
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg a6f06f8
Merge remote-tracking branch 'upstream/main' into homekit-client
andrewfg 02fb31e
adopt reviewer suggestions
andrewfg 8e6fbe8
implement IP transport plus various fixes
andrewfg 44775fd
work in progress
andrewfg de1d5a7
improve channel ids
andrewfg 99c5339
refactoring
andrewfg 89b85ec
small fixes
andrewfg a08cc71
adopt reviewer suggestions
andrewfg 5b69543
fix jmdns issue; refactoring
andrewfg f837ce7
work in progress
andrewfg 7adc7f4
pairing setup now working
andrewfg 4049ca9
Merge branch 'openhab:main' into homekit-client
andrewfg 84a2439
refactoring
andrewfg f9684c6
work in progress
andrewfg 1523e38
Merge remote-tracking branch 'upstream/main' into homekit-client
andrewfg 403e955
work in progress
andrewfg ffdce47
first working build
andrewfg b78f740
readme fixes
andrewfg bbe4b4c
work in progress
andrewfg e6477ee
unique xxx-type uids
andrewfg 13d2991
refactor type provider code
andrewfg 453c27b
Merge branch 'openhab:main' into homekit-client
andrewfg b4eeea4
refactoring and fix write characteristic
andrewfg bd268e5
fix issues with characteristic write
andrewfg e6fbd44
throw different exception if port is missing
andrewfg 46feb32
exact length client id; add validators
andrewfg 05eae28
cleaner log cosmetics
andrewfg 4ec0df0
send TLVs in specified order; refactor TLV enums
andrewfg a4e7e96
improve getProperties fix
andrewfg 75f41c3
improved testing and logging
andrewfg 608bcb9
work in progress
andrewfg 9bb63fc
refactor http parsing; support chunked
andrewfg 97704ca
work in progress
andrewfg 4931ba1
remove useless prefixes
andrewfg d8fe07c
work in progress
andrewfg d2e5f2f
implement json key store
andrewfg 43d7530
controller id is mac address
andrewfg ffa62cd
widen airing code matcher; use UUID for device id
andrewfg 0d4fd4d
fixes
andrewfg 05236fc
add discovery flag properties
andrewfg dc23790
fix channel fields; tweak ff param enum
andrewfg 04dc7a3
use uuid strings; improve logging
andrewfg d7a7ed6
fix build error
andrewfg dc647a7
remove id size checks
andrewfg 18d972d
add length to tlv trace logs
andrewfg 422ddd4
uom tweaks
andrewfg 59a005b
Simplify accessory discovery
jlaur 9c527b8
various
andrewfg 1f840fa
create unique thing labels
andrewfg 09fa62b
Merge pull request #3 from jlaur/homekit-discovery
andrewfg 59dd447
add velux junit test stub
andrewfg 7e23479
spotless
andrewfg b429040
fix rollershutter button commands
andrewfg 2fdf314
add junit intricate use cases, and fixes arising thereforom
andrewfg 242054e
work towards using light state machine
andrewfg a42d692
completed light state model
andrewfg b91026e
various
andrewfg 78fea42
implement event/trigger channel update
andrewfg 06b9586
implement immediate stop
andrewfg fa8d0f0
various
andrewfg 7d936eb
prepare i18n and event handling
andrewfg 2ce57a1
typo
andrewfg 091507d
eventing code completed
andrewfg 3257f59
eliminate recursion loop; eliminate duplicate code
andrewfg f7f2acb
spotless
andrewfg a5c48ad
fix evented channels not discovered
andrewfg a33a1fb
various
andrewfg 1e6dd29
suppress log message on closing
andrewfg 2f80690
fix disposition of HS parts of HSB commands
andrewfg f3a72a5
fix hsb brightness and on/off
andrewfg ea6a844
quick update hsb dependent channels
andrewfg 3bc8ef1
flip online state
andrewfg f0822c3
add i18n for enum values and channel labels
andrewfg cd7646d
restart polling after bridge disconnect and reconnect
andrewfg 4b602ab
revert 3bc8ef1
andrewfg 6b8aa0a
various
andrewfg b638163
various
andrewfg f52fa73
restart also after command error
andrewfg aa17e4a
various
andrewfg fb1c59b
documentation
andrewfg 698f468
Update bundles/org.openhab.binding.homekit/src/main/resources/OH-INF/…
andrewfg cfe9bcf
revert prior
andrewfg 2bfab6f
fix http split frame issue
andrewfg 61aba1f
various
andrewfg cb67603
code optimisations
andrewfg e3ad3dc
i18n
andrewfg 70a47c7
handle previously uncaught exceptions
andrewfg 031e2f1
Merge remote-tracking branch 'upstream/main' into homekit-client
andrewfg 805155f
use thing action for pairing
andrewfg 2994e8f
fixes for pairing action
andrewfg 9be0f38
i18n
andrewfg 4827ae7
add thing action unpair
andrewfg 4cf1a20
various
andrewfg fd286e4
various
andrewfg 256580e
Add support for manual configuration
jlaur ffcb31c
documentation of pairing thing action
andrewfg 46abcdc
update read me for manual configuration
andrewfg 1d17956
add example
andrewfg 392115e
Merge pull request #4 from jlaur/homekit-config
andrewfg 19c8246
various
andrewfg 917ac5b
various
andrewfg 0f8c236
escape host name spaces
andrewfg 579f0e8
second try for host name with spaces
andrewfg 7d48c9f
various
andrewfg f62fe43
various
andrewfg 17a23a8
various refactoring
andrewfg 3a16aa9
fix shutdown bug
andrewfg 0682b4a
ensure unique channel ids
andrewfg 4bbb18f
add result messages for thing actions
andrewfg c1658de
small fixes
andrewfg a94c296
fix compile error
andrewfg 6b66f2c
add HSB parts to evented, polled cxx lists
andrewfg cc30ce8
[breaking] various
andrewfg ce8d964
typos
andrewfg 50b38fd
improve volatile resource clean-up and usage
andrewfg 036553b
differentiate root vs. child accessory thing type ids
andrewfg 605e41c
adjust readme
andrewfg 181328f
oops
andrewfg 509ab06
simplify child check
andrewfg bc2ebdc
rename thing type ids
andrewfg 03ad488
minor tweaks to readme and thing xml
andrewfg d3f4384
discovery creates unique thing labels
andrewfg 59bc7a3
adopt reviewer suggestions
andrewfg fac3df6
fix some (but not all) checkstyle warnings
andrewfg e581ce9
hardening and refactoring
andrewfg b50667b
Update bundles/org.openhab.binding.homekit/README.md
andrewfg e0c3fa3
Update bundles/org.openhab.binding.homekit/README.md
andrewfg f7df9ed
Update bundles/org.openhab.binding.homekit/README.md
andrewfg b859910
refactor names to match new thing-type id schema
andrewfg 920aa86
Merge branch 'openhab:main' into homekit-client
andrewfg aadf181
adopt reviewer suggestions - part 1
andrewfg 4e20891
typo
andrewfg 3c0031c
adopt reviewer suggestions - part 2
andrewfg 8f9c9d2
adopt reviewer suggestions
andrewfg e55701a
fix @text argument passing
andrewfg ae994a8
fix writing to immutable map
andrewfg 2c5a98b
Invert delay check for throttling logic
andrewfg 32d1b91
Merge branch 'openhab:main' into homekit-client
andrewfg f502424
Update bundles/org.openhab.binding.homekit/README.md
andrewfg 564263a
various
andrewfg c602ca4
sleeker start up process
andrewfg 6eafb2e
handle case of thing (re)enable after start-up
andrewfg c5b7209
various
andrewfg 1120986
fix silly error
andrewfg f0b750d
Merge branch 'openhab:main' into homekit-client
andrewfg 5c12539
various
andrewfg 096b261
third attempt; awaiting dependent things
andrewfg 2dc0120
adopt some reviewer suggestions
andrewfg bae66af
adapt based on prior review comments
andrewfg 22d983f
adopt some reviewer suggestions
andrewfg f9ebe16
sacrifice javadoc clarity for fewer code style warnings
andrewfg dac81d5
use fully qualified class names
andrewfg dfeb6b4
split signal paths for channel definitions and properties
andrewfg 113b4ad
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg bc09b2d
provisional: adopt reviewer suggestions
andrewfg 8336efe
add equipment tag
andrewfg 45d0fd1
improve equipment tagging
andrewfg b4700e6
Merge branch 'openhab:main' into homekit-client
andrewfg b333f54
fix misclassification of battery powered accessories
andrewfg b1a951f
tweak equipment tag code
andrewfg a9d0cc2
Update bundles/org.openhab.binding.homekit/README.md
andrewfg 8232057
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg 178ee86
Update bundles/org.openhab.binding.homekit/src/main/java/org/openhab/…
andrewfg 7450b0b
Merge branch 'main' into homekit-client
andrewfg 7b6b1d2
fix bad github merge suggestion
andrewfg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # HomeKit Binding | ||
|
|
||
| This binding allows pairing with HomeKit accessories and **imports** their services as channel groups and their respective service- characteristics as channels. | ||
| Do not confuse this with the [HomeKit system integration](https://www.openhab.org/addons/integrations/homekit/) which **exports** openHAB Items to a HomeKit controller. | ||
|
|
||
| ## Supported Things | ||
|
|
||
| There are three types of Things supported: | ||
|
|
||
| - `accessory`: This integrates a single HomeKit accessory, which has its own LAN connection. | ||
| Its services appear as Channel Groups, and their respective characteristics appear as Channels. | ||
| - `bridged-accessory`: This integrates a single HomeKit accessory, which does NOT have its own LAN connection. | ||
| It has the same functionality as an `accessory`, except that its communication is done via a `bridge` (see below). | ||
| - `bridge`: This integrates a HomeKit bridge accessory, which has its own LAN connection. | ||
| It does not have any own Channels. | ||
| Instead it contains multiple `bridged-accessory` Things (see above). | ||
|
|
||
| Things of type `bridge` and `accessory` both communicate directly with their HomeKit accessory device via the LAN. | ||
| Whereas `bridged-accessory` Things communicate via their respective `bridge` Thing. | ||
|
|
||
| ## Discovery | ||
|
|
||
| Both `accessory` and `bridge` Things will be auto-discovered via mDNS. | ||
| And once a `bridge` Thing has been instantiated and paired, its `bridged-accessory` Things will also be auto-discovered. | ||
|
|
||
| ## Configuration for `bridge` and `accessory` Things | ||
|
|
||
| The following table shows the Thing configuration parameters for `bridge` and `accessory` Things. | ||
|
|
||
| | Name | Type | Description | Default | Required | Advanced | | ||
| |-------------------|---------|------------------------------------------------------|-----------|----------|----------| | ||
| | `ipAddress` | text | IP v4 address of the HomeKit accessory. | see below | yes | no | | ||
| | `httpHostHeader` | text | The fully qualified host name as discovered by mDNS. | see below | yes | yes | | ||
| | `macAddress` | text | Unique accessory identifier as discovered by mDNS. | see below | yes | yes | | ||
| | `refreshInterval` | integer | Interval at which the accessory is polled in sec. | 60 | no | yes | | ||
|
|
||
| NOTE: as a general rule, if you create the Things via the Inbox from the mDNS discovery result, then all of the above configuration parameters will have their proper values already preset. | ||
|
|
||
| `ipAddress` must match the format `123.123.123.123:4567` representing its IP v4 address and port. | ||
|
|
||
| `httpHostHeader` is required for the 'Host:' header of HTTP requests sent to the `accessory` or `bridge`. | ||
| It must be the fully qualified host name (e.g. `foobar._hap._tcp.local.` or, if the port is not 0 or 80, `foobar._hap._tcp.local.:1234`) as found manually via (say) an mDNS discovery app. | ||
|
|
||
| `macAddress` must be the unique accessory identifier as found manually via (say) an mDNS discovery app. | ||
|
|
||
| ### Configuration for `bridged-accessory` Things | ||
|
|
||
| The following table shows the Thing configuration parameters for `bridged-accessory` Things. | ||
|
|
||
| | Name | Type | Description | Default | Required | Advanced | | ||
| |-------------------|---------|------------------------------------------------------|-----------|----------|----------| | ||
| | `accessoryID` | integer | ID of the accessory. | see below | yes | yes | | ||
|
|
||
| As a general rule `accessoryID` is set by the auto-discovery process. | ||
| However you can configure it manually if you wish. | ||
| It must be the ID of the `bridged-accessory` within the `bridge`. | ||
|
|
||
| ## Thing Pairing | ||
|
|
||
| The `bridge` and `accessory` Things need to be paired with their respective HomeKit accessories. | ||
| This requires entering the HomeKit pairing code by means of a Thing Action. | ||
|
|
||
| Note that HomeKit accessories can only be paired with one controller, so if it is already paired with something else, you will need to remove that pairing first. | ||
| There are two forms of pairing: | ||
|
|
||
| 1. Simple pairing. | ||
| This works directly between two devices – a HomeKit client (this binding) and a HomeKit accessory. | ||
| In this case you need only to enter the pairing code into the Thing Action. | ||
| 1. Pairing with external authorization. | ||
| In addition to the HomeKit client (this binding) and the HomeKit accessory, it requires an additional third party to put the accessory into pairing mode. | ||
| Typically the additional third party can be either a) using the accessory's app to put it into pairing mode, or b) pressing a pairing button on the device. | ||
|
|
||
| In either case above, the Pairing Code must be entered manually into the Thing Action dialog. | ||
| The Pairing Code must match the format `XXX-XX-XXX` or `XXXX-XXXX` or `XXXXXXXX` where `X` is a single digit. | ||
|
|
||
| For case 1. above, the `With External Authentication` switch must be `OFF`. | ||
| Whereas for case 2. above, must be `ON`. | ||
|
|
||
| ## Channels | ||
|
|
||
| For `accessory` and `bridged-accessory` Things, the Channels are auto-created depending on the services and characteristics published by the HomeKit accessory. | ||
| Things of type `bridge` do not have own Channels. | ||
|
|
||
| As a general rule openHAB has one Channel for each HomeKit characteristic. | ||
| Some HomeKit accessories have separate characteristics for 'target' and 'current' states. | ||
| The two characteristics may have different values (e.g. for a thermostat). | ||
| In all such cases the Thing has a Channel for each characteristic so that both values can be accessed. | ||
|
|
||
| Some HomeKit characteristics represent fixed information e.g. model number, firmware version, etc. | ||
| Such values appear in openHAB as properties of the respective Thing. | ||
|
|
||
| ### Special Extra HSBType Channel | ||
|
|
||
| In openHAB the norm is that lighting objects shall be represented by a single `HSBType` Channel which manages hue, saturation, brightness, and on-off states. | ||
| By contrast a HomeKit accessory has four separate characteristics for hue, saturation, brightness, and on-off. | ||
| So the Thing creates one additional `HSBType` Channel that amalgamates hue, saturation, brightness, and on-off characteristics, according to the openHAB norm. | ||
|
|
||
| ## Integration with Apple Home App / Ecosystem | ||
|
|
||
| Many HomeKit accessories are able only to be paired with one client. | ||
| This means that if you want to pair such an accessory with this binding, you must first unpair it from the Apple Home app. | ||
|
|
||
| If you want to integrate such an accessory with both this binding and with the Apple Home ecosystem, then you can use this binding to import the Channels as openHAB Items, and then use the openHAB system integration addon to re-export those Items to the Apple HomeKit eco system. | ||
|
|
||
| ## File Based Configuration | ||
|
|
||
| ### Thing Configuration | ||
|
|
||
| Things are automatically configured when they are discovered. | ||
| So for this reason it is difficult to create Things via a '.things' file, and therefore not recommended. | ||
|
|
||
| ```java | ||
| Bridge homekit:bridge:velux "VELUX Gateway" [ host="192.168.0.235:5001", macAddress="XX:XX:XX:XX:XX:XX", hostName="foobar._hap._tcp.local.", refreshInterval=60 ] { | ||
| Thing bridged-accessory sensor "VELUX Sensor" @ "Hallway" [ accessoryID=2 ] | ||
| Thing bridged-accessory skylight_hallway "VELUX Window" @ "Hallway" [ accessoryID=3 ] | ||
| Thing bridged-accessory skylight_bathroom "VELUX Window" @ "Bathroom" [ accessoryID=4 ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Item Configuration | ||
|
|
||
| ```java | ||
| Group VeluxSensorSwitch "Velux indoor climate sensor" (Hallway) ["Sensor"] | ||
|
|
||
| Number:Dimensionless Velux_Hallway_CO2 "CO2 [%d ppm]" <carbondioxide> (VeluxSensorSwitch) ["Measurement", "CO2"] { channel="homekit:bridged-accessory:velux:sensor:sensor-carbon-dioxide#carbon-dioxide-level-17", unit="ppm" } | ||
| Number:Dimensionless Velux_Hallway_Humidity "Humidity [%.0f %%]" <humidity> (VeluxSensorSwitch) ["Measurement", "Humidity"] { channel="homekit:bridged-accessory:velux:sensor:sensor-humidity#relative-humidity-current-13", unit="%" } | ||
| Number:Temperature Velux_Hallway_Temperature "Temperature" <temperature> (VeluxSensorSwitch) ["Measurement", "Temperature"] { channel="homekit:bridged-accessory:velux:sensor:sensor-temperature#temperature-current-10", unit="°C" } | ||
|
|
||
| Group SkylightHallway "Skylight window" (Hallway) ["Window"] | ||
|
|
||
| Rollershutter SkylightHallway_Position "Position" (SkylightHallway) ["OpenState"] { channel="homekit:bridged-accessory:velux:skylight_hallway:window#position-target-11" } | ||
|
|
||
| Group SkylightBathroom "Skylight window" (SmallBathroom) ["Window"] | ||
|
|
||
| Rollershutter SkylightBathroom_Position "Position" (SkylightBathroom) ["OpenState"] { channel="homekit:bridged-accessory:velux:skylight_bathroom:window#position-target-11" } | ||
| ``` | ||
|
|
||
| ### Sitemap Configuration | ||
|
|
||
| ```perl | ||
| Slider item=SkylightHallway_Position | ||
| Slider item=SkylightBathroom_Position | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 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>5.1.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>org.openhab.binding.homekit</artifactId> | ||
|
|
||
| <name>openHAB Add-ons :: Bundles :: HomeKit Client Binding</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.bouncycastle</groupId> | ||
| <artifactId>bcprov-jdk18on</artifactId> | ||
| <version>1.81</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.homekit/src/main/feature/feature.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <features name="org.openhab.binding.homekit-${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-homekit" description="HomeKit Binding" version="${project.version}"> | ||
| <feature>openhab-runtime-base</feature> | ||
| <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.homekit/${project.version}</bundle> | ||
| </feature> | ||
| </features> |
116 changes: 116 additions & 0 deletions
116
...g.homekit/src/main/java/org/openhab/binding/homekit/internal/HomekitBindingConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * Copyright (c) 2010-2025 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.homekit.internal; | ||
|
|
||
| import java.util.regex.Pattern; | ||
|
|
||
| import org.eclipse.jdt.annotation.NonNullByDefault; | ||
| import org.openhab.core.thing.Thing; | ||
| import org.openhab.core.thing.ThingTypeUID; | ||
| import org.openhab.core.thing.type.ChannelDefinition; | ||
| import org.openhab.core.thing.type.ChannelTypeUID; | ||
|
|
||
| /** | ||
| * Defines common constants which are used across the whole HomeKit binding. | ||
| * | ||
| * @author Andrew Fiddian-Green - Initial contribution | ||
| */ | ||
| @NonNullByDefault | ||
| public class HomekitBindingConstants { | ||
|
|
||
| public static final String BINDING_ID = "homekit"; | ||
|
|
||
| // List of all Thing Type UIDs | ||
| public static final ThingTypeUID THING_TYPE_ACCESSORY = new ThingTypeUID(BINDING_ID, "accessory"); | ||
| public static final ThingTypeUID THING_TYPE_BRIDGED_ACCESSORY = new ThingTypeUID(BINDING_ID, "bridged-accessory"); | ||
| public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge"); | ||
|
|
||
| /** | ||
| * Some Characteristics have variable values and others remain static over time. The latter are produced with | ||
| * a {@link ChannelDefinition} with this channel-type uid. And when Things are created, rather than instantiating | ||
| * them as (dynamic data) Channels of the Thing, instead they are added as (static data) Properties of the Thing. | ||
| */ | ||
| public static final ChannelTypeUID CHANNEL_TYPE_STATIC = new ChannelTypeUID(BINDING_ID, "static-data"); | ||
|
|
||
| /** | ||
| * format string for channel-group-type UIDs which represent services | ||
| * format: 'channel-group-type'-[serviceIdentifier]-[serviceIid]-[thingId]-[accessoryId] | ||
| * example: channel-group-type-accessory-information-1-1234567890abcdef-1 | ||
| */ | ||
| public static final String CHANNEL_GROUP_TYPE_ID_FMT = "channel-group-type-%s-%d-%s-%s"; | ||
|
|
||
| /** | ||
| * format string for channel-type UIDs which represent characteristics | ||
| * format: 'channel-type'-[characteristicIdentifier]-[characteristicIid]-[thingId]-[accessoryId] | ||
| * example: channel-type-occupancy-detected-2694-1234567890abcdef-1 | ||
| */ | ||
| public static final String CHANNEL_TYPE_ID_FMT = "channel-type-%s-%d-%s-%s"; | ||
|
|
||
| /** | ||
| * format string for channel-definition IDs like '[characteristicIdentifier]-[characteristicIid]' | ||
| * used to instantiate channels and labels like '[thingName]-[accessoryAid]' used to discover | ||
| * things; examples: | ||
| * <ul> | ||
| * <li>occupancy-detected-2694</li> | ||
| * <li>11:22:33:44:55:66-1234</li> | ||
| * </ul> | ||
| */ | ||
| public static final String STRING_AID_FMT = "%s-%d"; | ||
|
|
||
| // labels for things e.g. 'Living Room Light (11:22:33:44:55:66-1234)' | ||
| public static final String THING_LABEL_FMT = "%s (%s)"; | ||
|
|
||
| // configuration parameters | ||
| public static final String CONFIG_HTTP_HOST_HEADER = "httpHostHeader"; | ||
| public static final String CONFIG_IP_ADDRESS = "ipAddress"; | ||
| public static final String CONFIG_REFRESH_INTERVAL = "refreshInterval"; | ||
| public static final String CONFIG_ACCESSORY_ID = "accessoryID"; | ||
| public static final String CONFIG_MAC_ADDRESS = Thing.PROPERTY_MAC_ADDRESS; | ||
|
|
||
| // thing properties | ||
| public static final String PROPERTY_PROTOCOL_VERSION = "protocolVersion"; | ||
| public static final String PROPERTY_ACCESSORY_CATEGORY = "accessoryCategory"; | ||
| public static final String PROPERTY_REPRESENTATION = "representationProperty"; | ||
|
|
||
| // channel properties | ||
| public static final String PROPERTY_IID = "iid"; | ||
| public static final String PROPERTY_FORMAT = "format"; | ||
| public static final String PROPERTY_DATA_TYPE = "dataType"; | ||
|
|
||
| // HomeKit HTTP URI endpoints and content types | ||
| public static final String ENDPOINT_ACCESSORIES = "/accessories"; | ||
| public static final String ENDPOINT_CHARACTERISTICS = "/characteristics"; | ||
| public static final String ENDPOINT_PAIR_SETUP = "/pair-setup"; | ||
| public static final String ENDPOINT_PAIR_VERIFY = "/pair-verify"; | ||
|
|
||
| public static final String CONTENT_TYPE_PAIRING = "application/pairing+tlv8"; | ||
| public static final String CONTENT_TYPE_HAP = "application/hap+json"; | ||
|
|
||
| // pattern matcher for pairing code XXX-XX-XXX or XXXX-XXXX or XXXXXXXX | ||
| public static final Pattern PAIRING_CODE_PATTERN = Pattern.compile("\\d{3}-\\d{2}-\\d{3}|\\d{4}-\\d{4}|\\d{8}"); | ||
|
|
||
| // pattern matcher for host ipv4 address 123.123.123.123:12345 | ||
| public static final Pattern IPV4_PATTERN = Pattern.compile( | ||
| "^(((25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)):(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]?\\d{1,4})$"); | ||
|
|
||
| // pattern matcher for a fully qualified host name like foobar._hap._tcp.local. or foobar._hap._tcp.local.:12345 | ||
| // NOTE: this specially allows space characters in the host name -- even if normally not allowed by the RFC | ||
| public static final Pattern HOST_PATTERN = Pattern.compile( | ||
| "^([a-zA-Z0-9\\-\\x20]+)\\._hap\\._tcp\\.local\\.(?::([1-9]\\d{0,3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]))?$"); | ||
|
|
||
| // result messages for ThingActions; !! DO NOT LOCALIZE !! | ||
| public static final String ACTION_RESULT_OK = "OK"; | ||
| public static final String ACTION_RESULT_OK_FORMAT = ACTION_RESULT_OK + " (%s)"; | ||
| public static final String ACTION_RESULT_ERROR = "ERROR"; | ||
| public static final String ACTION_RESULT_ERROR_FORMAT = ACTION_RESULT_ERROR + " (%s)"; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.