cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 39 forks source link

how to read AccessoryInformation #102

Open max3232rs opened 4 years ago

max3232rs commented 4 years ago

Hi, I'm new here, but use this plugin with my node-red for a while. Thanks a lot. I searched for a solution to keep this plugin in sync with my node-red without saving the state, because this "wanted" sync state might be wrong or get lost. So I use hb/to/get with {"name":"*"} to inventory the bridge. Therefor I stored some technical date like a device id in the so called ServiceLabel, because I don't want this in the display name. This works great, till I restart the homebridge. The Name property gets lost. You have to fetch it individually per service via hb/to/get/characteristic - very poor. My best idea was to store this in the AccessoryInformation. A device id is quite like a serial number. But I never found a way to retrieve this set information back.

Perhaps I haven't got the documention right, but I decided to go the hard way and patched the controller.js.

As you added the _props feature, I've had the problem to combine the props switch and my info switch. So I deviced to move it to an own property. Now I can do a { "name": "", "info" : 1, "props" : 1 } to hb/to/get either for or a specific service and retrieve the information I need. It's also compatible to _props".

The diff.patch is attached. I would like to hear your mind. controller.patch.txt