Skip to content

Commit 8a1d486

Browse files
committed
Add support for T8222, resend thumbnails on Home Assistant restart
1 parent 7105772 commit 8a1d486

File tree

4 files changed

+46
-20
lines changed

4 files changed

+46
-20
lines changed

enums/device_type.js

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const deviceType = {
1414
MOTION_SENSOR: 'T8910',
1515
VIDEO_DOORBELL_1080P_BATTERY: 'T8220',
1616
VIDEO_DOORBELL_1080P_POWERED: 'T8221',
17+
VIDEO_DOORBELL_1080P_POWERED2: 'T8222',
1718
VIDEO_DOORBELL_2K_BATTERY: 'T8210',
1819
VIDEO_DOORBELL_2K_POWERED: 'T8200',
1920
VIDEO_DOORBELL_2K_POWERED2: 'T8202',
@@ -92,6 +93,12 @@ const capabilities = {
9293
NotificationType.EVENT_DOORBELL_PRESSED,
9394
NotificationType.THUMBNAIL,
9495
],
96+
[deviceType.VIDEO_DOORBELL_1080P_POWERED2]: [
97+
NotificationType.EVENT_MOTION_DETECTED,
98+
NotificationType.EVENT_PERSON_DETECTED,
99+
NotificationType.EVENT_DOORBELL_PRESSED,
100+
NotificationType.THUMBNAIL,
101+
],
95102
[deviceType.VIDEO_DOORBELL_2K_BATTERY]: [
96103
NotificationType.EVENT_MOTION_DETECTED,
97104
NotificationType.EVENT_PERSON_DETECTED,

eufy/client.js

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const winston = require('winston')
12
const config = require('../config')
23
const { MqttClient } = require('../mqtt')
34
const { EufyHttp, EufyPush, EufyDevices } = require('../eufy')
@@ -11,6 +12,8 @@ class EufyClient {
1112
this.eufyPush = new EufyPush(this.mqttClient)
1213
this.eufyDevices = new EufyDevices(this.eufyHttpClient, this.mqttClient)
1314

15+
this.mqttClient.onMqttMessage = this.onMqttMessage.bind(this)
16+
1417
await this.mqttClient.connect()
1518
await this.eufyHttpClient.refreshStoredDevices()
1619
await this.mqttClient.setupAutoDiscovery()
@@ -24,6 +27,23 @@ class EufyClient {
2427
await this.eufyDevices.processDeviceProperties()
2528
}, true)
2629
}
30+
31+
async onMqttMessage (topic, message) {
32+
message = message.toString()
33+
winston.debug(`MQTT message: [${topic}]: ${message}`)
34+
35+
if (topic === 'homeassistant/status') {
36+
if (message === 'online') {
37+
await this.onHomeAssistantStartup()
38+
}
39+
}
40+
}
41+
42+
async onHomeAssistantStartup () {
43+
await this.eufyHttpClient.refreshStoredDevices()
44+
await this.mqttClient.setupAutoDiscovery()
45+
await this.eufyDevices.retrieveDeviceThumbnails()
46+
}
2747
}
2848

2949
exports.EufyClient = EufyClient

mqtt/client.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const HaDiscovery = require('./ha-discovery')
1212

1313
class MqttClient {
1414

15+
onMqttMessage = null
16+
1517
async connect() {
1618
this.client = await MQTT.connectAsync(config.mqttUrl, {
1719
username: config.mqttUsername,
@@ -33,11 +35,8 @@ class MqttClient {
3335
})
3436

3537
this.client.on('message', async (topic, message) => {
36-
winston.debug(`MQTT message: [${topic}]: ${message.toString()}`)
37-
if (topic === 'homeassistant/status') {
38-
if (message.toString() === 'online') {
39-
await this.setupAutoDiscovery()
40-
}
38+
if (typeof this.onMqttMessage === 'function') {
39+
await this.onMqttMessage(topic, message)
4140
}
4241
})
4342

readme.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ for an option to run it as an Add-on.
2525
The following devices and features are supported. When a device of that type is detected, the sensors that are supported
2626
are automatically discovered in Home Assistant.
2727

28-
| | Motion detected | Person detected | Doorbell press | Crying detected | Sound detected | Pet detected | Thumbnail last event |
29-
|--|--|--|--|--|--|--|--|
30-
| Eufy Cam 2 (T8114) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
31-
| Eufy Cam 2 Pro (T8140) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
32-
| Eufy Cam 2C (T8113) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
33-
| Eufy Cam 2C Pro (T8142) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
34-
| Eufy Cam E (T8112) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
35-
| Floodlight Camera (T8420) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
36-
| Indoor Cam 2K (T8400) | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
37-
| Indoor Cam Pan & Tilt (T8410) | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
38-
| Motion Sensor (T8910) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: |
39-
| Eufy video doorbell 1080P (battery) (T8220) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
40-
| Eufy video doorbell 1080P (powered) (T8221) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
41-
| Eufy video doorbell 2K (battery) (T8210) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
42-
| Eufy video doorbell 2K (powered) (T8200 / T8202) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
28+
| | Motion detected | Person detected | Doorbell press | Crying detected | Sound detected | Pet detected | Thumbnail last event | Battery status |
29+
|--|--|--|--|--|--|--|--|--|
30+
| Eufy Cam 2 (T8114) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
31+
| Eufy Cam 2 Pro (T8140) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
32+
| Eufy Cam 2C (T8113) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
33+
| Eufy Cam 2C Pro (T8142) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
34+
| Eufy Cam E (T8112) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
35+
| Floodlight Camera (T8420) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
36+
| Indoor Cam 2K (T8400) | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
37+
| Indoor Cam Pan & Tilt (T8410) | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
38+
| Motion Sensor (T8910) | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: |
39+
| Eufy video doorbell 1080P (battery) (T8220) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
40+
| Eufy video doorbell 1080P (powered) (T8221 / T8222) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: | :x: |
41+
| Eufy video doorbell 2K (battery) (T8210) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
42+
| Eufy video doorbell 2K (powered) (T8200 / T8202) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: | :x: |
4343

4444
Also, the Door Sensor (T8900) is supported, this generates a seperate sensor, based on door open/closed events.
4545

0 commit comments

Comments
 (0)