node-red-contrib-esphome icon indicating copy to clipboard operation
node-red-contrib-esphome copied to clipboard

"Assertion failed" and "sendMessage timeout"

Open Bond246 opened this issue 1 year ago • 13 comments

Hello,

i try to connect a new esphome project - my first project with esphome. While i'm not using HA i tried MQTT but had a lot of reboots. The maintainer told me to try to disable mqtt and use the API instead. Thats why i moved to this project.

But unfortunately i have much more issues with that flow in Node-RED. First connection is fine but after a while it loses connection, i see a lot of reconnects on esp-side and get a lot of messages like:

"Assertion failed"
"sendMessage timeout"

My Node-RED is on latest version 3.1.0 with node.JS v18 on docker.

Is there anything that could be improved or better logs?

Thanks

Bond246 avatar Nov 20 '23 14:11 Bond246

I recommend turning off encryption and using a password. See how the result will be

twocolors avatar Nov 20 '23 14:11 twocolors

I don't use encryption or a password actually. Its all plain unencrypted traffic.

An the esp32 is just 10cm away from the hotspot.

Bond246 avatar Nov 21 '23 22:11 Bond246

hm, show me screen what you send to out-node

twocolors avatar Nov 22 '23 07:11 twocolors

hm, show me screen what you send to out-node

nothing. It actually dont use the output-node. Thats the fun :)

Bond246 avatar Nov 22 '23 14:11 Bond246

hm, show me screen what you send to out-node

nothing. It actually dont use the output-node. Thats the fun :)

ping from host where install node-red ?

twocolors avatar Nov 22 '23 14:11 twocolors

I'm in docker and normaly a ping is ~20ms.

Bond246 avatar Nov 22 '23 19:11 Bond246

docker network like make ? use

    network_mode: host

twocolors avatar Nov 23 '23 14:11 twocolors

No, of course not. All my smarthome services are in a user defined bridge network. Nothing else is needed.

Bond246 avatar Nov 24 '23 19:11 Bond246

@Bond246 try new version, will show more info in error

twocolors avatar Dec 26 '23 09:12 twocolors

I have the same errors. "Assertion failed" "Failure: Invalid wire type: %s (at position %s)" "sendMessage timeout"

Editing each config node without making any change but clicking 'update' (and deploy) usually fixes it: reconnects instantly and runs happily for another 24 hours or so, then errors again.

This time it failed to reconnect, and crashed NR completely.

Devices:

Yaml Config

-power_save_mode: LIGHT
+power_save_mode: none

Crash logs:

30 Dec 18:04:41 - [error] [esphome-device:Rumpus-radar] sendMessage timeout waiting for DeviceInfoResponse
[NodeRed2 B323@Rumpus Occupancy Sensor@Rumpus Occupancy Sensor@Occupancy Detected] characteristic value expected valid finite number and received "NaN" (number)
30 Dec 18:05:47 - [error] [esphome-device:Rumpus-radar] sendMessage timeout waiting for DeviceInfoResponse
[NodeRed2 B323@Rumpus Occupancy Sensor@Rumpus Occupancy Sensor@Occupancy Detected] characteristic value expected valid finite number and received "NaN" (number)
30 Dec 18:05:50 - [red] Uncaught Exception:
30 Dec 18:05:50 - [error] Error: write after end
    at new NodeError (node:internal/errors:405:5)
    at _write (node:internal/streams/writable:322:11)
    at Socket.Writable.write (node:internal/streams/writable:337:10)
    at PlaintextFrameHelper.sendMessage (/home/pi/.node-red/node_modules/@2colors/esphome-native-api/lib/utils/plaintextFrameHelper.js:70:21)
    at EsphomeNativeApiConnection.sendMessage (/home/pi/.node-red/node_modules/@2colors/esphome-native-api/lib/connection.js:179:26)
    at EsphomeNativeApiConnection.disconnect (/home/pi/.node-red/node_modules/@2colors/esphome-native-api/lib/connection.js:168:18)
    at EsphomeNativeApiClient.disconnect (/home/pi/.node-red/node_modules/@2colors/esphome-native-api/lib/client.js:84:25)
    at RED.nodes.registerType.credentials.encryptionkey.type.<anonymous> (/home/pi/.node-red/node_modules/node-red-contrib-esphome/src/nodes/device.ts:167:21)
    at RED.nodes.registerType.credentials.encryptionkey.type.Node.close (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:340:26)
    at stopNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:745:31)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=20s expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 2.

caitken-com avatar Dec 30 '23 07:12 caitken-com

@caitken-com try [email protected]

twocolors avatar Dec 30 '23 13:12 twocolors

I also encountered the same problem, and I think it may be caused by ESP32s, because my other projects, such as ESP8266, are running normally. image image

chibm avatar Feb 25 '24 03:02 chibm

hi enable in device reconnect and update to 0.2.8

twocolors avatar Jul 15 '24 12:07 twocolors