twocolors / node-red-contrib-esphome

Node-RED nodes to ESPhome devices
MIT License
18 stars 5 forks source link

"Assertion failed" and "sendMessage timeout" #26

Open Bond246 opened 7 months ago

Bond246 commented 7 months ago

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

twocolors commented 7 months ago

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

Bond246 commented 7 months ago

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

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

twocolors commented 7 months ago

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

Bond246 commented 7 months ago

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

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

twocolors commented 7 months ago

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 ?

Bond246 commented 7 months ago

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

twocolors commented 7 months ago

docker network like make ? use

    network_mode: host
Bond246 commented 7 months ago

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

twocolors commented 6 months ago

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

caitken-com commented 6 months ago

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

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.
twocolors commented 6 months ago

@caitken-com try node-red-contrib-esphome@0.2.6

chibm commented 4 months ago

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