Title: GitHub · Where software is built
Open Graph Title: hap-java/HAP-Java
X Title: hap-java/HAP-Java
Description: Java implementation of the HomeKit Accessory Protocol - hap-java/HAP-Java
Open Graph Description: Java implementation of the HomeKit Accessory Protocol - hap-java/HAP-Java
X Description: Java implementation of the HomeKit Accessory Protocol - hap-java/HAP-Java
Opengraph URL: https://github.com/hap-java/HAP-Java
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Better mechanism for optional characteristics needed","articleBody":"# TL;DR\r\n\r\nThe current mechanism of implementing additional interfaces to add support for optional characteristics is non-conducive to supporting dynamic sets of optional characteristics.\r\n\r\n# Background and current workaround\r\n\r\nIn my fork of Openhab-homekit, I support low battery notification. However, whether or not an accessory actually has low-battery notification support is based on the items configuration. As a workaround, in order to avoid creating two classes for sensors that potentially have battery status reporting support, [I create a faux-battery notification implementation that always returns batteryLow=false](https://github.com/timcharper/openhab2-addons/blob/v2.4.0-homekit-5/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/battery/NoBatteryStatus.java)).\r\n\r\n# Limitations of providing substitute static-values\r\n \r\nSuch workarounds are not possible when adding a characteristic that fundamentally changes the presentation of an accessory in homekit. For example, with the thermostat, the addition of optional characteristics `Characteristic.CoolingThresholdTemperature` and `Characteristic.HeatingThresholdTemperature` causes the UI to show a temperature range, rather than a single temperature, when the AUTO TargetCoolingHeatingState is active.\r\n\r\n# Proposal and way forward\r\n\r\nI propose that accessories classes only specify getters, setters, and subscribers for their base class.\r\n\r\nThen, for optional characteristics, I propose that the accessory has an overridable getter which gets some optional characteristic, with the default value being none:\r\n\r\n```\r\n@Override\r\nprotected Optional\u003cHeatingThresholdCharacteristicSupport\u003e heatingThresholdTemperatureCharacteristic() {\r\n heatingThresholdItem.map(item -\u003e {\r\n\r\n new HeatingThresholdCharacteristicSupport() {\r\n @Override\r\n CompletableFuture\u003cDouble\u003e getHeatingThresholdTemperature() {\r\n ...\r\n }\r\n ...\r\n }\r\n });\r\n}\r\n```\r\n\r\nThe `HeatingThermostat` trait can be modified such that the interface methods are lifted out in to `HeatingThresholdCharacteristicSupport`, retaining backwards compatibility (and potentially marking as deprecated for removal in next minor release of HAP-Java). After such a lift, the interface would be effectively empty:\r\n\r\n```\r\npackage com.beowulfe.hap.accessories.thermostat;\r\n\r\nimport com.beowulfe.hap.HomekitCharacteristicChangeCallback;\r\nimport java.util.concurrent.CompletableFuture;\r\n\r\n@Deprecated\r\npublic interface HeatingThermostat extends BasicThermostat, HeatingThresholdCharacteristicSupport {\r\n}\r\n```\r\n","author":{"url":"https://github.com/timcharper","@type":"Person","name":"timcharper"},"datePublished":"2019-02-04T08:41:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":25},"url":"https://github.com/63/HAP-Java/issues/63"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:4f5d8462-a98f-526f-38ce-40838b3611dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 880C:2893D2:7E20BB:A04BA5:6974507C |
| html-safe-nonce | bac589aa79477f18aa47efbf757e86807bc4a09bdf9eb8a56cdc2a5f725e61d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODBDOjI4OTNEMjo3RTIwQkI6QTA0QkE1OjY5NzQ1MDdDIiwidmlzaXRvcl9pZCI6IjM1OTIwNTM5MDM1ODg2MTAxNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25d8d1f53f64ac690829b59eb8f14e3b3a925fc18fe0cee610e886ca04121497 |
| hovercard-subject-tag | repository:31193475 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/hap-java/HAP-Java/issues/63 |
| twitter:image | https://opengraph.githubassets.com/46f043e6c2c6bad5e66ed115ddefb25036d223a8d68183e2e8050964043c74e6/hap-java/HAP-Java |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46f043e6c2c6bad5e66ed115ddefb25036d223a8d68183e2e8050964043c74e6/hap-java/HAP-Java |
| og:image:alt | Java implementation of the HomeKit Accessory Protocol - hap-java/HAP-Java |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e0b95d743b7672c9ac0e1032d5f117950182dc164a83434a7db86510e8f0b37c |
| turbo-cache-control | no-cache |
| go-import | github.com/hap-java/HAP-Java git https://github.com/hap-java/HAP-Java.git |
| octolytics-dimension-user_id | 47992845 |
| octolytics-dimension-user_login | hap-java |
| octolytics-dimension-repository_id | 31193475 |
| octolytics-dimension-repository_nwo | hap-java/HAP-Java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31193475 |
| octolytics-dimension-repository_network_root_nwo | hap-java/HAP-Java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fe7e2e8de6e57740bca50402351ea656f7a4bf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width