Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event from home assistant crashing node red with TypeError: Cannot read property 'split' of null #301

Closed
ernout opened this issue Dec 5, 2020 · 2 comments
Labels
Type: Bug Something isn't working

Comments

@ernout
Copy link

ernout commented Dec 5, 2020

When I update one of my binary sensors in home assistant, Node Red crashes with this error (for example when I open a door):

5 Dec 22:03:26 - [red] Uncaught Exception:
5 Dec 22:03:26 - TypeError: Cannot read property 'split' of null
at ServerStateChangedNode.getCastValue (/opt/node_modules/node-red-contrib-home-assistant-websocket/lib/base-node.js:299:30)
at ServerStateChangedNode.getComparatorResult (/opt/node_modules/node-red-contrib-home-assistant-websocket/lib/base-node.js:386:27)
at ServerStateChangedNode.onHaEventsStateChanged (/opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/events-state-changed/events-state-changed.js:90:36)
at HaWebsocket.emit (events.js:327:22)
at HaWebsocket.onClientEvents (/opt/node_modules/node-red-contrib-home-assistant-websocket/lib/ha-websocket.js:294:26)
at Object.callback (/opt/node_modules/node-red-contrib-home-assistant-websocket/lib/ha-websocket.js:229:31)
at Connection._handleMessage (/opt/node_modules/home-assistant-js-websocket/dist/haws.cjs:353:26)
at WebSocket. (/opt/node_modules/home-assistant-js-websocket/dist/haws.cjs:191:57)
at WebSocket.onMessage (/opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (/opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/websocket.js:797:20)
at Receiver.emit (events.js:315:20)
at Receiver.dataMessage (/opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/receiver.js:437:14)
at /opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/receiver.js:394:23
at /opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/permessage-deflate.js:306:9
at /opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/permessage-deflate.js:385:7
at afterWrite (_stream_writable.js:490:5)
at onwrite (_stream_writable.js:470:7)
at InflateRaw.afterTransform (_stream_transform.js:98:3)
at Zlib.processCallback (zlib.js:578:8)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

To Reproduce

Create an home assistant event node, set it to 'if state: in' and add some items to filter for.
Now remove the items clicking on 'x' to remove the contents for if state. It will look like this:

Screenshot 2020-12-06 at 00 11 52

Now every time an event comes in for this sensor, the node red install will crash.

Expected behavior

I dont expect node red to crash based on an event from home assistant.

Environment (please complete the following information):

Node-RED version: v1.2.5
Node.js version: v12.18.4
Linux 5.4.72 x64 LE
node-red-contrib-home-assistant-websocket: 0.27.5
Is Node Red running in Docker:HA addon

Add-on: Node-RED
Flow-based programming for the Internet of Things

Add-on version: 7.2.11
You are running the latest version of this add-on.
System: HassOS 4.15 (amd64 / qemux86-64)
Home Assistant Core: 0.118.5
Home Assistant Supervisor: 2020.12.6

Other (please complete the following information):

I've searched for duplicate issues.
Ive looked up this line in the code, and it seems that its assuming the payload to be not null when its of type 'list' in the 'cast type' method.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2020

@ernout: hello! 👋

This issue is being automatically closed because it does not follow the issue template.

Fixing this with automatically reopen the issue.

@github-actions github-actions bot closed this as completed Dec 5, 2020
@ernout ernout changed the title TypeError: Cannot read property 'split' of null Event from home assistant crashing node red with TypeError: Cannot read property 'split' of null Dec 5, 2020
@github-actions github-actions bot reopened this Dec 5, 2020
@ernout
Copy link
Author

ernout commented Dec 5, 2020

Ah i've figured it out. Looking through the code a bit more, I saw that its using the split call when the events node is configured with 'if state is in'.

I've adjusted this in my flows, and now the problem is gone.
I've updated my issue above to show when this happens. Maybe a small tweak can be made to check for null here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants