Skip to content

Commit

Permalink
Make keepalive configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
matijse committed Feb 5, 2021
1 parent b431864 commit df3c702
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
3 changes: 3 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Config {
mqttUrl
mqttUsername
mqttPassword
mqttKeepalive

constructor () {
let config
Expand All @@ -26,6 +27,8 @@ class Config {
this.mqttUsername = get(config, 'mqtt.username')
this.mqttPassword = get(config, 'mqtt.password')

this.mqttKeepalive = parseInt(get(config, 'mqtt.keepalive', { default: 60 }))

if (
typeof this.eufyUsername === "undefined" ||
typeof this.eufyPassword === "undefined" ||
Expand Down
3 changes: 2 additions & 1 deletion data/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ eufy:
mqtt:
url: "mqtt://dockerhost:1883"
username: "user"
password: "password"
password: "password"
keepalive: 60
2 changes: 1 addition & 1 deletion mqtt/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MqttClient {

async connect() {
let options = {
keepalive: 60,
keepalive: config.mqttKeepalive,
reconnectPeriod: 1000,
will: {
topic: HaDiscovery.availabilityTopic,
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"get-value": "^3.0.1",
"js-yaml": "^3.14.1",
"node-fetch": "^2.6.1",
"sqlite3": "^5.0.0",
"sqlite3": "^5.0.1",
"winston": "^3.3.3"
}
}

0 comments on commit df3c702

Please sign in to comment.