Custom Component for node-red-contrib-home-assistant-websocket

Hi. I don’t know what is wrong, but now i can’t run the package dependency in Hassio anymore ,after a Hass restart.:

[10:35:08] FATAL: Failed installing npm package git+https://github.com/zachowj/node-red-contrib-home-assistant-websocket#integration
[cont-init.d] user.sh: exited 1.
[cont-finish.d] executing container finish scripts…
[cont-finish.d] 99-message.sh: executing…

            Oops! Something went wrong.

On the github page i see Build-Failing.
Please advise me if you can. Thank you.

Sorry, I should have changed the post here after I did a full release. I have pushed these changes to the master branch and removed the integration branch. Looks like you’re using hass.io and the last time I looked the addon hasn’t been updated to include v0.17.0.

Solution until the node-red addon for hass.io gets updated: change ...#integration to ...#master

Thank You very much. That solved it for now.

Why do I get this error message on sensor node?

The files are copied to the correct space. node-red-contrib-home-assistant-websocket is already included in node-red. And think node-red config should be correct.

Hassio was reinstalled a few days ago.

Node red, by the way, takes a long time to start. Check timestamps from the log.

Last bit of the logg:

[19:16:05] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[19:16:06] INFO: Password is NOT in the Have I Been Pwned database! Nice!
patching file nodes/ui_base.html
Hunk #1 succeeded at 1243 (offset 712 lines).
up to date in 1.727s
found 0 vulnerabilities
[cont-init.d] node-red.sh: exited 0.
[cont-init.d] user.sh: executing... 
[19:16:13] INFO: Starting installation of custom NPM/Node-RED packages...
+ [email protected]
added 1 package from 1 contributor, updated 3 packages and audited 3721 packages in 59.566s
found 0 vulnerabilities
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[19:17:17] INFO: Starting Node-RED...
> hassio-addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
16 Dec 19:17:23 - [info] 
Welcome to Node-RED
===================
16 Dec 19:17:23 - [info] Node-RED version: v1.0.3
16 Dec 19:17:23 - [info] Node.js  version: v10.16.3
16 Dec 19:17:23 - [info] Linux 4.14.98-v7 arm LE
16 Dec 19:17:25 - [info] Loading palette nodes

I think you don’t need that npm package as it’s already part of the add-on, what you do need is the custom component below.

1 Like

I already have those files (look at the picture), :slightly_smiling_face:

Have you added it to the integration page in HA?

@mbonani Last I looked there hasn’t been a release of the hass.io addon with v0.17.x in it.

1 Like

Oops, my bad. I’m running Node-RED in a container (not the add-on) and wrongly assumed the add-on was updated. I’m sorry.

1 Like

I couldn’t find node-red under integrations earlier, so I skipped that step.
Took a restart of hassio every now and then it showed up under integrations. Got it added and now the error message is gone and everything works fine.
Thanks a lot for your help and hints.

The zachowj/ hass-node-red is installed via HACS, Node Red added on integration page but nothing appeared in the Node RED. It was several Hassio restart without any result. I use Hassio in Docker under Ubuntu 18.04.



image
image

:tada: A new version of the add-on with node-red-contrib-home-assistant-websocket v0.17.1 was just released.

You might need to update the Node-RED add-on to its newest version (v5.0.7).

Thank you! It is working now! :beers:

I am not seeing the “off” events in node red on the event: state node. I am expecting on/off message when I toggle the switch, instead it moves to “DISABLED” on NR… what am I missing? I an not sure how I can use the DISABLED state of that node.

Is this a valid use case? I want to turn on/off a switch to control the flow of data in the middle of a flow rather than use it a method to start the flow. I guess that is where my disconnect its. I was assuming the main event: state node would output a on and off since it matches the entity_id of the switch that is created. but once its disabled it doesn’t output anything…

I have gotten around fixed this by creating one node to create the switch in HA and another node with the entity_id with the id of the switch that was created to get its true on/off state.

I don’t see that working because when you turn off the switch in HA it will disable the node and it won’t trigger on the switch.send_notifacation_garage state change event.

Interesting use from your post on Github with the traffic light. A possible change to those would be to swap out the traffic node and use a current-state node where you check the state of the exposed switch unless you’re turning on and off the traffic node from something off-screen. I have it on my todo list to create a node that does this exact use-case but I haven’t implemented it.

[{"id":"c5c37106.31bc6","type":"inject","z":"9ce184b.0f5bb78","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":256,"y":1520,"wires":[["1b39943.738206c"]]},{"id":"1b39943.738206c","type":"api-current-state","z":"9ce184b.0f5bb78","name":"","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.test_event","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":482,"y":1520,"wires":[["ac14dc49.0c81c"],[]]},{"id":"bcc85509.194c78","type":"server-state-changed","z":"9ce184b.0f5bb78","name":"test_event","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"test_event","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":252,"y":1568,"wires":[[]]},{"id":"ac14dc49.0c81c","type":"debug","z":"9ce184b.0f5bb78","name":"Send Alarm Alerts","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":730,"y":1520,"wires":[]}]

The scenario where I see exposed nodes being used is if you have a flow that is started by an event and you want to have the ability to disable it from the HA UI. Something like if you have a motion sensor that triggers a light turning on and off in the bathroom and for some reason you want the light to be a dumb switch now.

[{"id":"2cea436.7c324bc","type":"server-state-changed","z":"9ce184b.0f5bb78","name":"","version":1,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"bathroom motion"},{"property":"icon","value":""}],"entityidfilter":"sensor.bathroom_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":210,"y":1744,"wires":[["efb949c.4bd71b8","60777439.e2037c"],[]]},{"id":"efb949c.4bd71b8","type":"ha-wait-until","z":"9ce184b.0f5bb78","name":"","outputs":2,"entityId":"sensor.bathroom_motion","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"5","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":460,"y":1792,"wires":[[],["ff66455d.a47be8"]]},{"id":"60777439.e2037c","type":"api-call-service","z":"9ce184b.0f5bb78","name":"","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_{{payload}}","entityId":"switch.bathroom_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":680,"y":1744,"wires":[[]]},{"id":"ff66455d.a47be8","type":"change","z":"9ce184b.0f5bb78","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1792,"wires":[["60777439.e2037c"]]}]

Thanks for the confirmation.

I have gotten it working using something like what you mentioned in first use case. Where I have event: state node tied to switch.enable_front_notifications and then created a HA switch using a new set of nodes.

I use traffic lights pretty heavily in my flows too. Nearly everything goes through a traffic light node before it gets processed, in case I want to disable things.

Also found something, if you stick one of these nodes into a sub flow then every time the sub flow is hit, it creates a new switch not just the first time its used… no biggie, i have created a NR flow in which I am creating all the “switches”

This is fantastic… just tried, but will put to some real testing asap and report back :smile: thanks!