Skip to content

Commit 1de5b33

Browse files
committed
Add option to adjust off_delay
1 parent 0eb850e commit 1de5b33

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

config/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ const winston = require('winston')
66
class Config {
77
eufyUsername
88
eufyPassword
9+
910
mqttUrl
1011
mqttUsername
1112
mqttPassword
1213
mqttKeepalive
1314

15+
haOffDelay
16+
1417
constructor () {
1518
let config
1619
try {
@@ -26,9 +29,10 @@ class Config {
2629
this.mqttUrl = get(config, 'mqtt.url')
2730
this.mqttUsername = get(config, 'mqtt.username')
2831
this.mqttPassword = get(config, 'mqtt.password')
29-
3032
this.mqttKeepalive = parseInt(get(config, 'mqtt.keepalive', { default: 60 }))
3133

34+
this.haOffDelay = parseInt(get(config, 'home_assistant.off_delay', { default: 5 }))
35+
3236
if (
3337
typeof this.eufyUsername === "undefined" ||
3438
typeof this.eufyPassword === "undefined" ||

data/config.example.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ mqtt:
55
url: "mqtt://dockerhost:1883"
66
username: "user"
77
password: "password"
8-
keepalive: 60
8+
keepalive: 60
9+
home_assistant:
10+
off_delay: 5

mqtt/ha-discovery.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { NotificationType } = require('../enums/notification_type');
22
const { SensorType } = require('../enums/sensor_type');
33
const { DeviceCapabilities } = require('../enums/device_type')
4+
const config = require('../config')
45

56
class HaDiscovery {
67

@@ -177,7 +178,7 @@ class HaDiscovery {
177178
state_topic: `${sensorBaseTopic}/state`,
178179
json_attributes_topic: `${sensorBaseTopic}/attributes`,
179180
payload_on: sensorPayloadOn,
180-
off_delay: 5,
181+
off_delay: config.haOffDelay,
181182
unique_id: sensorId,
182183
device: {
183184
identifiers: deviceSN,

readme.md

+27-12
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,10 @@ help with adding support for new devices or message types that aren't supported
4949

5050
## Setup
5151

52-
### Docker configuration
52+
### Configuration
5353

54-
The data folder contains the config, logs and a record of all push notifications (so new types of notifications can
55-
be discovered). Mount this directory to a local folder. Replace `/path/to/local/data/folder`
56-
below with the location where you want to store this data.
57-
58-
If you run your MQTT broker on the same host as this Docker image, it cannot simply connect to `localhost` from inside
59-
this Docker image. In that case, add a line to add the correct IP for the Docker network inside the image as
60-
`dockerhost`. You can then use `mqtt://dockerhost:1883` as the MQTT url. Otherwise, you can remove that line from the
61-
example below.
62-
63-
In the data directory, you will need to create a `config.yml` file with your credentials. It should contain the
64-
following contents:
54+
In the data directory, you will need to create a `config.yml` file with your credentials. You can copy this from
55+
`config.example.yml`. It should contain the following contents:
6556

6657
```yaml
6758
eufy:
@@ -71,8 +62,32 @@ mqtt:
7162
url: "mqtt://dockerhost:1883"
7263
username: "user"
7364
password: "password"
65+
keepalive: 60
66+
home_assistant:
67+
off_delay: 5
7468
```
7569
70+
Only the Eufy username and password and MQTT url are required. Also MQTT username and password when set at the broker.
71+
The other options can be omitted, with the defaults shown above.
72+
73+
* MQTT keepalive: adjusts the keepalive interval for the MQTT connection. This is the maximum interval in seconds
74+
between messages to/from the MQTT broker. Set this higher when you encounter disconnects.
75+
* Home Assistant `off_delay`: Sets the delay in seconds after which a motion/doorbell sensor is set back to "No motion"
76+
after motion is detected.
77+
78+
### Data folder
79+
80+
The data folder contains the config, logs and a record of all push notifications (so new types of notifications can
81+
be discovered). Mount this directory to a local folder. Replace `/path/to/local/data/folder` in the Docker setups
82+
below with the location where you want to store this data.
83+
84+
### Connecting to MQTT
85+
86+
If you run your MQTT broker on the same host as this Docker image, it cannot simply connect to `localhost` from inside
87+
this Docker image. In that case, add a line to add the correct IP for the Docker network inside the image as
88+
`dockerhost`. You can then use `mqtt://dockerhost:1883` as the MQTT url. Otherwise, you can remove that line from the
89+
example below.
90+
7691
### Run via Docker
7792

7893
Run the container, with a volume mapping to the local data directory, for example:

0 commit comments

Comments
 (0)