arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
466 stars 104 forks source link

Update index.js #649

Closed zazula closed 10 months ago

zazula commented 11 months ago

Send service names to HomeKit using the ConfiguredName characteristic.

We could also watch for name changes in HomeKit and store them but I didn't see a clear path to that. Something like:

service.getCharacteristic(Characteristic.ConfiguredName) .onSet(/ store the new name /);

arachnetech commented 10 months ago

Looks uncontroversial, but before I merge could you give me some background on the purpose of this change please? Thanks in advance, David.

zazula commented 10 months ago

Thanks for listening. Without this change, all services have the name given to the accessory at the top level, e.g.,

{
  accessory: "mqttthing",
  name: <<<< this field
  ...
}

With this change, each service gets the individual name specified along with it, e.g.,

{
  accessory: "mqttthing",
  name: "big daddy",
  ...
  "services" : [
    type: "motionsensor",
    name: <<<< this field
  ...
}

So, you see the name for each service in Home.app instead of a bunch of switches or whatever with the same name.

arachnetech commented 10 months ago

Thanks, I understand. Sorry it's taken me so long to get around to merging, incidentally - work has been even busier than usual and I just haven't made time for mqttthing!

arachnetech commented 10 months ago

Is there anything that we can do to fix https://github.com/arachnetech/homebridge-mqttthing/issues/656? Perhaps your new behaviour needs to be optional, enabled by another configuration setting?

zazula commented 9 months ago

Is there anything that we can do to fix #656? Perhaps your new behaviour needs to be optional, enabled by another configuration setting?

Yes, we can watch for 'onSet' of 'Characteristic.ConfiguredName' on all services and write out an updated config file. The homebridge API package includes a method for this:

https://www.jsdocs.io/package/homebridge#API.updatePlatformAccessories

However, I looked and don't see an existing code path that writes out the config file currently.

Also, we'd want to handle changes to any of the derived names (e.g., speakers and inputs in a 'television' service).