mirror of
https://github.com/tsightler/ring-mqtt.git
synced 2025-09-26 21:01:12 +08:00
Implement new HA entity naming standards
This commit is contained in:
@@ -57,11 +57,11 @@ export default class RingDevice {
|
||||
|
||||
// Build a Home Assistant style MQTT discovery message for the entity
|
||||
let discoveryMessage = {
|
||||
...entity.hasOwnProperty('name')
|
||||
? { name: entity.name }
|
||||
...entity.hasOwnProperty('isMainEntity') || entity.hasOwnProperty('name')
|
||||
? { name: entity.hasOwnProperty('name') ? entity.name : '' }
|
||||
: { name: `${entityKey.replace(/_/g," ").replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase())}` },
|
||||
...entity.hasOwnProperty('unique_id')
|
||||
? { unique_id: entity.unique_id }
|
||||
...entity.hasOwnProperty('isMainEntity') || entity.hasOwnProperty('unique_id')
|
||||
? { unique_id: entity.hasOwnProperty('unique_id') ? entity.unique_id : `${this.deviceId}` }
|
||||
: { unique_id: `${this.deviceId}_${entityKey}`},
|
||||
...entity.component === 'camera'
|
||||
? { topic: entityStateTopic }
|
||||
|
@@ -53,7 +53,7 @@ export default class BinarySensor extends RingSocketDevice {
|
||||
this.entity[this.entityName] = {
|
||||
component: 'binary_sensor',
|
||||
...device_class ? { device_class: device_class } : {},
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
|
||||
// Only official Ring sensors can be bypassed
|
||||
|
@@ -11,7 +11,7 @@ export default class CoAlarm extends RingSocketDevice {
|
||||
this.entity.co = {
|
||||
component: 'binary_sensor',
|
||||
device_class: 'gas',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ export default class Fan extends RingSocketDevice {
|
||||
|
||||
this.entity.fan = {
|
||||
component: 'fan',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
|
||||
this.data = {
|
||||
|
@@ -7,7 +7,7 @@ export default class Lock extends RingSocketDevice {
|
||||
|
||||
this.entity.lock = {
|
||||
component: 'lock',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ export default class ModesPanel extends RingPolledDevice {
|
||||
|
||||
this.entity.mode = {
|
||||
component: 'alarm_control_panel',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
|
||||
this.data = {
|
||||
|
@@ -8,7 +8,7 @@ export default class MultiLevelSwitch extends RingSocketDevice {
|
||||
this.entity.light = {
|
||||
component: 'light',
|
||||
brightness_scale: 100,
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ export default class SecurityPanel extends RingSocketDevice {
|
||||
alarm: {
|
||||
component: 'alarm_control_panel',
|
||||
attributes: true,
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
},
|
||||
siren: {
|
||||
component: 'switch',
|
||||
|
@@ -9,7 +9,7 @@ export default class Siren extends RingSocketDevice {
|
||||
siren: {
|
||||
component: 'switch',
|
||||
icon: 'mdi:alarm-light',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
},
|
||||
...(this.device.data.deviceType === 'siren.outdoor-strobe') ? {
|
||||
volume: {
|
||||
|
@@ -14,7 +14,7 @@ export default class SmokeAlarm extends RingSocketDevice {
|
||||
this.entity.smoke = {
|
||||
component: 'binary_sensor',
|
||||
device_class: 'smoke',
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ export default class Switch extends RingSocketDevice {
|
||||
|
||||
this.entity[this.component] = {
|
||||
component: this.component,
|
||||
unique_id: `${this.deviceId}` // Force backward compatible unique ID for this entity
|
||||
isMainEntity: true
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user