Skip to content

Commit

Permalink
Add ConfiguredName for Dimmer, Switch, Valve (#85)
Browse files Browse the repository at this point in the history
* Fix iOS 16 service name appeared as accessory name.

* Silence characteristic warning.
  • Loading branch information
0x5e authored Nov 16, 2022
1 parent 6b3a48f commit daab3fa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/accessory/BaseAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class BaseAccessory {
.setCharacteristic(this.Characteristic.Manufacturer, MANUFACTURER)
.setCharacteristic(this.Characteristic.Model, this.device.product_id)
.setCharacteristic(this.Characteristic.Name, this.device.name)
.setCharacteristic(this.Characteristic.ConfiguredName, this.device.name)
.setCharacteristic(this.Characteristic.SerialNumber, this.device.uuid)
;
}
Expand Down
7 changes: 7 additions & 0 deletions src/accessory/DimmerAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export default class DimmerAccessory extends BaseAccessory {

const service = this.accessory.getService(schema.code)
|| this.accessory.addService(this.Service.Lightbulb, schema.code, schema.code);

service.setCharacteristic(this.Characteristic.Name, schema.code);
if (!service.testCharacteristic(this.Characteristic.ConfiguredName)) {
service.addOptionalCharacteristic(this.Characteristic.ConfiguredName); // silence warning
service.setCharacteristic(this.Characteristic.ConfiguredName, schema.code);
}

this.configureOn(service, index);
this.configureBrightness(service, index);
}
Expand Down
4 changes: 4 additions & 0 deletions src/accessory/SwitchAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default class SwitchAccessory extends BaseAccessory {
|| this.accessory.addService(this.mainService(), schema.code, schema.code);

service.setCharacteristic(this.Characteristic.Name, schema.code);
if (!service.testCharacteristic(this.Characteristic.ConfiguredName)) {
service.addOptionalCharacteristic(this.Characteristic.ConfiguredName); // silence warning
service.setCharacteristic(this.Characteristic.ConfiguredName, schema.code);
}

service.getCharacteristic(this.Characteristic.On)
.onGet(async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/accessory/ValveAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class ValveAccessory extends BaseAccessory {
|| this.accessory.addService(this.Service.Valve, schema.code, schema.code);

service.setCharacteristic(this.Characteristic.Name, schema.code);
if (!service.testCharacteristic(this.Characteristic.ConfiguredName)) {
service.addOptionalCharacteristic(this.Characteristic.ConfiguredName); // silence warning
service.setCharacteristic(this.Characteristic.ConfiguredName, schema.code);
}
service.setCharacteristic(this.Characteristic.ValveType, this.Characteristic.ValveType.IRRIGATION);

service.getCharacteristic(this.Characteristic.InUse)
Expand Down

0 comments on commit daab3fa

Please sign in to comment.