Skip to content

Commit

Permalink
Add Name and ConfiguredName to AccessoryInformation Service
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Jul 12, 2024
1 parent 07a4be4 commit 5a81ca3
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/homebridge-ring/base-device-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ export abstract class BaseDeviceAccessory extends BaseDataAccessory<RingDevice>
serviceType: Service.AccessoryInformation,
getValue: (data) => data.serialNumber || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.Name,
serviceType: Service.AccessoryInformation,
getValue: (data) => data.name || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: Service.AccessoryInformation,
getValue: (data) => data.name || 'Unknown',
})

if ('volume' in initialData && 'setVolume' in device) {
this.registerCharacteristic({
Expand Down
20 changes: 20 additions & 0 deletions packages/homebridge-ring/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,26 @@ export class Camera extends BaseDataAccessory<RingCamera> {
serviceType: Service.AccessoryInformation,
getValue: (data) => data.device_id,
})
this.registerCharacteristic({
characteristicType: Characteristic.Name,
serviceType: Service.AccessoryInformation,
getValue: (data) => {
if ('metadata' in data && 'third_party_model' in data.metadata) {
return data.description
}
return device.name ?? 'Unknown'
},
})
this.registerCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: Service.AccessoryInformation,
getValue: (data) => {
if ('metadata' in data && 'third_party_model' in data.metadata) {
return data.description
}
return device.name ?? 'Unknown'
},
})

if (device.hasBattery) {
this.registerCharacteristic({
Expand Down
10 changes: 10 additions & 0 deletions packages/homebridge-ring/chime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,15 @@ export class Chime extends BaseDataAccessory<RingChime> {
serviceType: Service.AccessoryInformation,
getValue: (data) => data.device_id || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.Name,
serviceType: Service.AccessoryInformation,
getValue: () => device.name || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: Service.AccessoryInformation,
getValue: () => device.name || 'Unknown',
})
}
}
10 changes: 10 additions & 0 deletions packages/homebridge-ring/intercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ export class Intercom extends BaseDataAccessory<RingIntercom> {
serviceType: Service.AccessoryInformation,
getValue: (data) => data.device_id || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.Name,
serviceType: Service.AccessoryInformation,
getValue: () => device.name || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: Service.AccessoryInformation,
getValue: () => device.name || 'Unknown',
})
}

private getLockState() {
Expand Down
10 changes: 10 additions & 0 deletions packages/homebridge-ring/location-mode-switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,15 @@ export class LocationModeSwitch extends BaseAccessory<Location> {
serviceType: AccessoryInformation,
onValue: of('N/A'),
})
this.registerObservableCharacteristic({
characteristicType: Characteristic.Name,
serviceType: AccessoryInformation,
onValue: of(accessoryName ?? 'Unknown'),
})
this.registerObservableCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: AccessoryInformation,
onValue: of(accessoryName ?? 'Unknown'),
})
}
}
10 changes: 10 additions & 0 deletions packages/homebridge-ring/panic-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ export class PanicButtons extends BaseDataAccessory<RingDevice> {
serviceType: Service.AccessoryInformation,
getValue: () => 'None',
})
this.registerCharacteristic({
characteristicType: Characteristic.Name,
serviceType: Service.AccessoryInformation,
getValue: (data) => data.name || 'Unknown',
})
this.registerCharacteristic({
characteristicType: Characteristic.ConfiguredName,
serviceType: Service.AccessoryInformation,
getValue: (data) => data.name || 'Unknown',
})

super.initBase()
}
Expand Down

0 comments on commit 5a81ca3

Please sign in to comment.