nicoduj / homebridge-harmony

Harmony websocket plugin for homebridge
The Unlicense
211 stars 22 forks source link

Add Correct name to the Accessories #428

Open carlosgamezvillegas opened 1 year ago

carlosgamezvillegas commented 1 year ago

When adding switches or other devices their name is not shown correctly. I have found out that if the following is added the name of each accessory will be shown correctly when they are added in HomeKit.

code lines that could be added:

  service.addOptionalCharacteristic(Characteristic.ConfiguredName);
  service.setCharacteristic(Characteristic.ConfiguredName, accesoryName);

I added those lines in the function below and it fixed the issue

getSwitchService(harmonyPlatform, accessory, switchName, serviceSubType) { let service = accessory.getServiceByUUIDAndSubType(switchName, serviceSubType); if (!service) { harmonyPlatform.log( '(' + harmonyPlatform.name + ')' + 'INFO - Creating Switch Service ' + switchName + '/' + serviceSubType ); service = new Service.Switch(switchName, 'switchService' + switchName); service.addOptionalCharacteristic(Characteristic.ConfiguredName); service.setCharacteristic(Characteristic.ConfiguredName, switchName); service.subtype = serviceSubType; accessory.addService(service); } return service;

Kind regards

nicoduj commented 6 months ago

Hi, it was done on purpose, since the name can be set in the config with the "pipe" syntax, but I will check if this option is better for common use case, thanks.