homebridge / HAP-NodeJS

Node.js implementation of the HomeKit Accessory Protocol (HAP)
Apache License 2.0
2.69k stars 630 forks source link

Centralized custom Service/Characteristic repository #223

Closed SphtKr closed 4 years ago

SphtKr commented 8 years ago

An idea, not sure how best it fits.

When I wrote the homebridge-yamaha platform, I created a custom AudioDeviceService and two custom Characteristics AudioVolume and Muting. Obviously these have application outside of only the Yamaha AVR integration. I thought it would be valuable to consider somehow collecting generally applicable custom Characteristics and making them available on a similar footing as the Apple-standard ones included in HAP-NodeJS. Also in this category are the Eve power usage characteristics, which are apparently being used in the FHEM Homebridge plugin and I want to add them to the Z-Way plugin as well. It seems sensible to attempt to apply DRY and find somewhere to define these reusable characteristics in one place.

By collecting and promoting the use of shared, commonly used Characteristics, we could possibly even set de facto standards that app developers could incorporate--or I suppose even Apple (even if they wouldn't adopt the UUIDs, the taxonomies of custom Services and Characteristics could provide inspiration--I'd settle for being "Sherlocked").

Unsure how best to implement this, especially since I'm not sure what HomeKitTypes.js is generated from. A separate GitHub project/repo for this might well make sense, but some hooks would be needed at Hap-NodeJS or Homebridge. It seemed like HAP-NodeJS might be the better place to connect, but whichever is fine with me.

PaulWieland commented 8 years ago

+1 for this. @rodtoll check this out...

snowdd1 commented 8 years ago

I like the idea. A separate repo (eg hapnodejs-customtypes) is a little strange, as plugins using these custom services/characteristics need to depend on the existence of the mod. I think if plugins have the repo in their dependencies npm will install it in a location so deep and away that a

try { require('hapnodejs-customtypes') } 

as a hook within hap-nodejs would always lead to nothing, even if it does not break with an exception. Said that, I haven't tried.

SphtKr commented 8 years ago

What the...Eve recognizes my custom Audio Volume characteristic all of a sudden!

img_1415 1

So I guess app devs are willing to add support for custom services and Characteristics!

KhaosT commented 8 years ago

@SphtKr That's awesome :)

snowdd1 commented 8 years ago

I am really flabbergasted. @SphtKr You made up the UUID and the name for that characteristic, right? How does EVE recognize it, even with an icon? Can you try with a misspelled "Audio Volume" to see whether Elgato (the maker of EVE) is reading here (and is using your UUID) or if the match of display name did the trick?

:astonished:

SphtKr commented 8 years ago

@snowdd1 I'll do one better. I went into the YamahaAVR plugin code and changed the custom characteristic's UUID by one digit. No icon (gets Eve's generic circle-in-square icon). Changed it back, speaker icon is back.

Now, I added that custom characteristic with that UUID back in September, so it's been there a while now. And it's just a percentage value, so very easy to implement. But the only possible conclusion is that Eve's developers have added support for that custom characteristic by its UUID since then.

Gentlemen, I think we have a mole. :open_mouth: Someone at Elgato must use the Yamaha plugin.

justme-1968 commented 8 years ago

yes. we should do that. there are already two other issues and a gist where such data is collected:

https://github.com/KhaosT/HAP-NodeJS/issues/155 https://github.com/KhaosT/HAP-NodeJS/issues/140 https://gist.github.com/gomfunkel/b1a046d729757120907c

having everything in one place and easily includable would be great.

using the same uuid across different plugins would not only avoid that i have to change my volume characteristic to the one eve apparently recognizes :( and allows them grouping in homekit apps but also makes it easier to switch it apple decides to include new standard characteristics.

KhaosT commented 8 years ago

I currently maintains a metadata for all built-in HomeKit services and characteristics that has special properties, sample. Maybe we can build like a platform to allow people to search and submit new services and characteristics so it can be easier for app developers to integrate?

justme-1968 commented 8 years ago

just changed my old custom volume characteristic to the one eve apparently recognizes and it really just works. very nice :)

we should try to get them to include more of these...

color temperature for lights would be one canditate.

SphtKr commented 8 years ago

Of note, here's some more use cases: https://github.com/SphtKr/homebridge-itunes/blob/master/HomeKitMediaTypes.js . I'll be building out the taxonomy for media device controls more and would welcome feedback/suggestions.

inator commented 8 years ago

Hello all -

I think this issue warrants reopening, as there's a ton of merit in setting up a way to share and use custom homekit types across apps. The simplest approach to me is via separate node module with various type categories as individual methods that can be loaded as required.

I'll work something up as a proof of concept and share here for comment/participation.

ebaauw commented 7 years ago

Just stumbled upon this issue. Any news on this? I would like to support it. I think HomeKit app developers would as well.

Here's the potentially re-usable custom characteristics I've come across:

Related to this:

SphtKr commented 7 years ago

Hi folks. FWIW, I had started to build this but just had to spend time on other projects. And, I never watched my own repo 🤦‍♂️ , so didn't realize there are already five forks of it. Not sure if one of those have taken off and run with it. But you might use what I had as a model or as a lesson. Anyone want to own the repo I'll transfer it too, I've just not had the time to keep it up.

NorthernMan54 commented 7 years ago

@SphtKr I looked at your work a few months back and found that the @homespun fork to be the most updated.

mrose17 commented 7 years ago

@NorthernMan54 - if not, please let me know.... thanks!

ToddGreenfield commented 7 years ago

Has anyone figured out a way to do a custom type for Audio Input (CD, NET, etc)?