Files
ring-mqtt/devices/smoke-co-listener.js
tsightler b8338e30de Release 5.1.0 (#537)
* Use MQTT for start-stream debug messages
* Fix ANSI colors
* Refactor event URL management
* Fix subscription detection
* Improve event URL expiry handling by parsing Amazon S3 expire time
* Convert to ESM/replace colors with chalk
* Force colors for chalk
* Migrate to ESM
* Fix stop of keepalive stream
* Add transcoded event selections
* Update event URL on raw/trancoded toggle
* Switch to per-camera livecall threads
* Customized WebRTC functions
Mostly copied from ring-client-api with port to pure Javascript, removal of unneeded features and additional debugging modified for use as worker thread with ring-mqtt.  Allows easier testing with updated Werift versions.
* Add nightlight enable/disable
* Include nightlight state as attribute
* Only pro versions have nightlight
* Tweak battery level reporting for dual battery cameras
* Release 5.1.0
2023-02-02 20:59:09 -05:00

28 lines
1.0 KiB
JavaScript

import RingSocketDevice from './base-socket-device.js'
export default class SmokeCoListener extends RingSocketDevice {
constructor(deviceInfo) {
super(deviceInfo, 'alarm')
this.deviceData.mdl = 'Smoke & CO Listener'
this.entity.smoke = {
component: 'binary_sensor',
device_class: 'smoke'
}
this.entity.co = {
component: 'binary_sensor',
device_class: 'gas',
name: `${this.deviceData.name} CO`, // Legacy compatibility
unique_id: `${this.deviceId}_gas` // Legacy compatibility
}
}
publishState() {
const smokeState = this.device.data.smoke && this.device.data.smoke.alarmStatus === 'active' ? 'ON' : 'OFF'
const coState = this.device.data.co && this.device.data.co.alarmStatus === 'active' ? 'ON' : 'OFF'
this.mqttPublish(this.entity.smoke.state_topic, smokeState)
this.mqttPublish(this.entity.co.state_topic, coState)
this.publishAttributes()
}
}