tsightler / ring-mqtt

Ring devices to MQTT Bridge
MIT License
603 stars 106 forks source link

ERROR - Uncaught Exception ring-mqtt Cannot read properties of undefined (reading 'toString') #782

Closed vincentfhylla closed 9 months ago

vincentfhylla commented 9 months ago

Describe the Issue

Issue with all ring devices not working, uninstalled and reinstalled but cannot see any entities but they show in the logs

Steps take so far

I've uninstalled MQTT Broker and Ring MQTT Addon. Getting an error message in the logs below

Log Output

2024-02-01T17:40:44.816Z ring-mqtt WARNING - Unhandled Promise Rejection
2024-02-01T17:40:44.816Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.816Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Camera.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Camera.publishPolledState (file:///app/ring-mqtt/devices/camera.js:586:22)
    at Camera.publishState (file:///app/ring-mqtt/devices/camera.js:425:14)
2024-02-01T17:40:44.816Z ring-mqtt WARNING - Unhandled Promise Rejection
2024-02-01T17:40:44.816Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.816Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Camera.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Camera.publishPolledState (file:///app/ring-mqtt/devices/camera.js:586:22)
    at Camera.publishState (file:///app/ring-mqtt/devices/camera.js:425:14)
2024-02-01T17:40:44.816Z ring-mqtt WARNING - Unhandled Promise Rejection
2024-02-01T17:40:44.816Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.817Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Camera.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Camera.publishPolledState (file:///app/ring-mqtt/devices/camera.js:586:22)
    at Camera.publishState (file:///app/ring-mqtt/devices/camera.js:425:14)
2024-02-01T17:40:44.817Z ring-mqtt WARNING - Unhandled Promise Rejection
2024-02-01T17:40:44.817Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.817Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Camera.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Camera.publishPolledState (file:///app/ring-mqtt/devices/camera.js:586:22)
    at Camera.publishState (file:///app/ring-mqtt/devices/camera.js:425:14)
2024-02-01T17:40:44.817Z ring-mqtt WARNING - Unhandled Promise Rejection
2024-02-01T17:40:44.817Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.817Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Camera.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Camera.publishPolledState (file:///app/ring-mqtt/devices/camera.js:586:22)
    at Camera.publishState (file:///app/ring-mqtt/devices/camera.js:425:14)
2024-02-01T17:40:44.818Z ring-mqtt ERROR - Uncaught Exception
2024-02-01T17:40:44.818Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.818Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Chime.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Chime.publishState (file:///app/ring-mqtt/devices/chime.js:95:18)
    at Object.next (file:///app/ring-mqtt/devices/base-polled-device.js:21:41)
2024-02-01T17:40:44.819Z ring-mqtt ERROR - Uncaught Exception
2024-02-01T17:40:44.819Z ring-mqtt Cannot read properties of undefined (reading 'toString')
2024-02-01T17:40:44.819Z ring-mqtt TypeError: Cannot read properties of undefined (reading 'toString')
    at MqttClient._removeTopicAliasAndRecoverTopicName (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:747:34)
    at MqttClient._storeAndSend (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:862:24)
    at MqttClient._sendPacket (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:980:22)
    at publishProc (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:368:26)
    at MqttClient.publish (/app/ring-mqtt/node_modules/mqtt/build/lib/client.js:379:14)
    at EventEmitter.<anonymous> (file:///app/ring-mqtt/lib/mqtt.js:33:25)
    at EventEmitter.emit (node:events:514:28)
    at Chime.mqttPublish (file:///app/ring-mqtt/devices/base-ring-device.js:233:21)
    at Chime.publishState (file:///app/ring-mqtt/devices/chime.js:95:18)
    at Object.next (file:///app/ring-mqtt/devices/base-polled-device.js:21:41)
2024-02-01T17:40:45.818Z ring-mqtt The ring-mqtt process is shutting down...
2024-02-01T17:40:45.819Z ring-mqtt Setting all devices offline...
2024-02-01T17:40:45.819Z ring-mqtt The ring-mqtt process is shutting down...
2024-02-01T17:40:45.819Z ring-mqtt Setting all devices offline...

Screenshots

No response

Config File

ring-mqtt.js version: 5.6.3
Node version v18.17.1
NPM version 9.1.2
git version 2.38.5
-------------------------------------------------------
Running ring-mqtt...
2024-02-01T17:50:52.432Z ring-mqtt Detected runmode: addon
2024-02-01T17:50:52.434Z ring-mqtt Configuration file: /data/options.json
2024-02-01T17:50:54.075Z ring-mqtt Reading latest data from state file: /data/ring-state.json
2024-02-01T17:50:54.077Z ring-mqtt Succesfully started the token generator web UI
2024-02-01T17:50:54.078Z ring-mqtt Discovered MQTT Host: core-mosquitto
2024-02-01T17:50:54.079Z ring-mqtt Discovered MQTT Port: 1883
2024-02-01T17:50:54.079Z ring-mqtt Discovered MQTT User: addons
2024-02-01T17:50:54.080Z ring-mqtt Discovered MQTT password: <hidden>
2024-02-01T17:50:54.080Z ring-mqtt MQTT URL: mqtt://addons:********@core-mosquitto:1883
2024-02-01T17:50:54.141Z ring-mqtt Attempting connection to Ring API using saved refresh token...
2024-02-01T17:50:56.733Z ring-mqtt Successfully established connection to Ring API using saved token
2024-02-01T17:50:56.734Z ring-mqtt Received updated refresh token
2024-02-01T17:50:56.734Z ring-mqtt Saving updated refresh token to state file
2024-02-01T17:50:57.747Z ring-mqtt Successfully saved updated state file: /data/ring-state.json
2024-02-01T17:50:58.733Z ring-mqtt Attempting connection to MQTT broker...
2024-02-01T17:50:58.817Z ring-mqtt MQTT connection established, processing Ring locations...

Install Type

Addon

Version

5.6.3

Operating System

HA OS

Architecture

No response

tsightler commented 9 months ago

To resolve this will require full logs. I've had this issue reported randomly a couple of times before, but everyone only post log snippets while those are just symptoms of something going wrong earlier. Usually a restart fixes the issue so then they never come back and post the full logs and thus I've never been able to even have a chance to figure out the core issue.

The function failing is actually in the MQTT client library, not in ring-mqtt itself, and it appears to be during the attempt to stringify the topic, which somewhat implies that there is an invalid topic being generated, but I have no idea why. Did you for some reason change the default top level topic (you didn't actually post your config, just more logs).

If this consistently fails even after a restart, please provide full logs and I will see if we can figure it out.

vincentfhylla commented 9 months ago

I tried to get some of this info and do some more trouble shooting and I made it worse..... Now my MQTT Broker isn't operational either. Maybe HA isn't for me lol.

MQTT Broker

vincentfhylla commented 9 months ago

I also tried to got the full logs for you following the directions that you provided and the terminal will not start for my to get the logs

image

tsightler commented 9 months ago

It sounds like you have more serious issues than just ring-mqtt not working. Unfortunately, I can't help with general HA issues so I'm not sure what more I can do here.

vincentfhylla commented 9 months ago

Thanks for your time. If I get back to that other point, I will reach out to you again.

vincentfhylla commented 9 months ago

Got back to the original spot where we started. I tried to get full logs using your instructions but nothing comes up when I type the in “docker logs addon_03cabcc9_ring_mqtt 2>&1 | gzip > ring-mqtt.log.gz” into the terminal.