When the device has multple switches, SwitchAccessory.js does not create services with properly unique name
Closed this issue · 2 comments
Describe the bug
lumi.switch.acn032 is a multi-switch with a touch LCD panel. When multiple of the devices is used, the resulting accessories created get the same name and causes confusion to homebridge and status update is random and sometimes wrong.
In SwitchAccessory.js: setupMainAccessoryService(), when the device has multiple switches, the code create the services for each switch and name it using the service description string found in the spec. When 2 such devices are present, the choice of using service description string causes accessories of the same name to be created. This confuses homebridge and causes random reporting of the status of the accessory.
I add the device name to the service name to avoid name collision as follows:
setupMainAccessoryService() {
if (this.getDevice().hasMultiplySwitchServices()) {
this.getDevice().getAllSwitchServices().forEach((service, i) => {
let uniqueServiceName = this.getDevice().getName() + ' ' + service.getDescription();
let serviceOnProp = service.getPropertyByType('on');
if (serviceOnProp) {
this.addPropWrapper(uniqueServiceName, serviceOnProp, null, null, null, null);
}
});
} else {
this.switchService = this.createStatefulSwitch(this.getName(), 'switchService', this.isSwitchOn, this.setSwitchOn);
this.addAccessoryService(this.switchService);
}
}
Expected behavior
A clear and concise description of what you expected to happen.
Your config.json
Provide the config.json entry for your device.
Debug log
Provide a snippet of a debug log when the issue occurs. Ideally with the deepDebugLog
property enabled.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Thanks for reporting. Will validate that and provide a fix!
Should be fixed with version 1.7.5