Kirbo / ha-addons-repository

HASS.IO Supervisor add-ons by Kirbo
0 stars 0 forks source link

The service is not running continuously and stops. #2

Open yltsa opened 2 years ago

yltsa commented 2 years ago

Hi, the service is not running continuously and stops. Here ere are error messages from the log:

/ruuvigw2ha/index.js:116 humidity: Number(humidity.toFixed(options.decimals.humidity || 2)), ^ TypeError: Cannot read properties of undefined (reading 'toFixed') at handleData (/ruuvigw2ha/index.js:116:33) at MqttClient. (/ruuvigw2ha/index.js:39:5) at MqttClient.emit (node:events:527:28) at MqttClient._handlePublish (/ruuvigw2ha/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/ruuvigw2ha/node_modules/mqtt/lib/client.js:410:12) at work (/ruuvigw2ha/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

Kirbo commented 2 years ago

That looks like you have something funky in the configurations. There might be a bug in my code as well, that's not outruled by any means, but I should be able to reproduce this, therefore I'd like to see the configuration you have (without the credentials obviously) 🙂

Kirbo commented 2 years ago

Here is the example configuration that you should have:

mqtt_protocol: mqtt
mqtt_host: core-mosquitto
mqtt_port: 1883
mqtt_credentials:
  client_id: ruuvi-gw-mqtt-to-ha
  username: 
  password: 
mqtt_ha_topic: homeassistant/
mqtt_ruuvi_topic: ruuvi/#
mqtt_parsed_ruuvi_topic: ruuvi/parsed/
update_interval: 60
decimals:
  humidity: 2
  temperature: 2
  pressure: 2
  battery: 0
  voltage: 2
battery:
  minimum: 2000
  maximum: 3000
  low_battery: 2100
use_prefixes: true
yltsa commented 2 years ago

Hi, this was working before.. Or it was running 1-3 months before it stopped and needed a new manual start. My configuration looks the same as yours:

mqtt_protocol: mqtt mqtt_host: 192.168.0.29 mqtt_port: 1883 mqtt_credentials:   client_id: ruuvi-gw-mqtt-to-ha   username: XXXXXX   password: XXXXXX mqtt_ha_topic: homeassistant/ mqtt_ruuvi_topic: ruuvi/# mqtt_parsed_ruuvi_topic: ruuvi/parsed/ update_interval: 60 decimals:   humidity: 2   temperature: 2   pressure: 2   battery: 0   voltage: 2 battery:   minimum: 2000   maximum: 3000   low_battery: 2100 use_prefixes: false

Kirbo commented 2 years ago

Hmm, weird.. It looks as if the ruuvitag didn't have humidity set. Well, anyway, I'll make this a bit more robust soon

Kirbo commented 2 years ago

I added a bit more logging in the version 2.0.2, if you could try with that and once your service restarts, check the Logs and paste a portion (preferably where the restart occurs) of it here, to help me investigate what's the issue at hand. 🙂

yltsa commented 2 years ago

Hi, 2.0.2 is not stopping but there are some error messages in the log:

at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11) parsedData { accelerationX: -828, accelerationY: -252, accelerationZ: -448, battery: 2995, humidity: undefined, mac: 'ED:20:26:86:0B:48', measurementSequenceNumber: 12079, movementCounter: 236, pressure: undefined, temperature: 25.525, txPower: 4 } TypeError: Cannot read properties of undefined (reading 'toFixed') at handleData (/ruuvigw2ha/index.js:119:35) at MqttClient. (/ruuvigw2ha/index.js:39:5) at MqttClient.emit (node:events:527:28) at MqttClient._handlePublish (/ruuvigw2ha/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/ruuvigw2ha/node_modules/mqtt/lib/client.js:410:12) at work (/ruuvigw2ha/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11) parsedData { accelerationX: -840, accelerationY: -256, accelerationZ: -440, battery: 2995, humidity: undefined, mac: 'ED:20:26:86:0B:48', measurementSequenceNumber: 12080, movementCounter: 236, pressure: undefined, temperature: 25.51, txPower: 4 } TypeError: Cannot read properties of undefined (reading 'toFixed') at handleData (/ruuvigw2ha/index.js:119:35) at MqttClient. (/ruuvigw2ha/index.js:39:5) at MqttClient.emit (node:events:527:28) at MqttClient._handlePublish (/ruuvigw2ha/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/ruuvigw2ha/node_modules/mqtt/lib/client.js:410:12) at work (/ruuvigw2ha/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11) parsedData { TypeError: Cannot read properties of undefined (reading 'toFixed') at handleData (/ruuvigw2ha/index.js:119:35) at MqttClient. (/ruuvigw2ha/index.js:39:5) at MqttClient.emit (node:events:527:28) at MqttClient._handlePublish (/ruuvigw2ha/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/ruuvigw2ha/node_modules/mqtt/lib/client.js:410:12) at work (/ruuvigw2ha/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11) accelerationX: -840, accelerationY: -256, accelerationZ: -440, battery: 2995, humidity: undefined, mac: 'ED:20:26:86:0B:48', measurementSequenceNumber: 12080, movementCounter: 236, pressure: undefined, temperature: 25.51, txPower: 4 } parsedData { accelerationX: -828, accelerationY: -252, accelerationZ: -444, battery: 2995, humidity: undefined, mac: 'ED:20:26:86:0B:48', measurementSequenceNumber: 12081, movementCounter: 236, pressure: undefined, temperature: 25.51, txPower: 4 } TypeError: Cannot read properties of undefined (reading 'toFixed') at handleData (/ruuvigw2ha/index.js:119:35) at MqttClient. (/ruuvigw2ha/index.js:39:5) at MqttClient.emit (node:events:527:28) at MqttClient._handlePublish (/ruuvigw2ha/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/ruuvigw2ha/node_modules/mqtt/lib/client.js:410:12) at work (/ruuvigw2ha/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/ruuvigw2ha/node_modules/mqtt/lib/client.js:335:5) at doWrite (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/ruuvigw2ha/node_modules/readable-stream/lib/_stream_writable.js:307:11)

Kirbo commented 2 years ago

Have you updated RuuviTag firmwares or bought new ones or something? It looks as if the ruuvitag-parser is unable to parae both pressure and humidity. I’ll add more debug at least, so that you get the original message as well, to help me further investigate where the problem is at. I’m quite sure the ruuvitag-parser (which this addon uses) is somehow not working properly on your case

yltsa commented 2 years ago

Hi, the firmwares are the newest available. There are three types of Ruuvitags in the system. Two Pro sensors have no pressure and a third Ruuvi Pro has also no humidity.

These are the sensors:

Kirbo commented 2 years ago

Oooh, okay. I haven't even tried with Pro sensors. These might not work properly..

Kirbo commented 2 years ago

I wasn't even aware that some of the sensors might not broadcast all the data. I should make it so that if e.g. humidity or pressure doesn't exist, then it wouldn't even try to read it. As per now, it relies on the assumption that every piece of data (humidity, pressure, temperature, battery, acceleration) exists on every RuuviTag.