simont77 / fakegato-history

Module to emulate Elgato Eve history
MIT License
168 stars 16 forks source link

Accessory vs Platform API #43

Closed ebaauw closed 6 years ago

ebaauw commented 6 years ago

I want to use a different filename, based on the device unique ID (ZigBee mac address) instead of on the (user changeable!) accessory name. I managed this by setting the accessory.displayName, but now it also shows the history service (007) under the ID. I figured I could create the 007 service myself, and fakegato-history would pick it up: https://github.com/simont77/fakegato-history/blob/8e88a4a24c79b484b1a4acf3a2e7af77256c04ec/fakegato-history.js#L440-L448

However, my platform plugin is recognised as accessory plugin. Shouldn't line 440 check for getServices() instead of getService()?

https://github.com/nfarina/homebridge/blob/b670ec1036135b0df06094f1738d7c93499c3a39/lib/server.js#L388

NorthernMan54 commented 6 years ago

@ebaauw When I write that, I was looking at this to determine if the passed object was an Accessory ( Platform V2 API ) or a Service ( Accessory API). I realize it could be a little more elegant, but for my plugins it seems to work.

https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/Accessory.js#L237

ebaauw commented 6 years ago

Ok, this would be a differece between platforms with dynamic accessories vs static accessories. Could we check for either?

simont77 commented 6 years ago

Sorry, I cannot help on that, I have only static plugins

ebaauw commented 6 years ago

Are they recognised as platform or as accessory? For static plugins you would have getServices() as you don’t have accees to the hap.Accessory object.

simont77 commented 6 years ago

They all have getServices()

ebaauw commented 6 years ago

Ok, so the platform part is meant only for dynamic platforms.