Node-Red on hass.io

After the better part of a week and frequent dead-ends, plus a few times banging my head against the wall because the Home Assistant documentation is written by and for Home Assistant experts, I finally can control a ZWave switch (Inovelli NZW31) from Node-Red.

I never got the OpenZWave nodes to work. I finally wound up starting over with a new Pi3. I burned the hass.io image to an SD card, then installed the SSH, Node-Red and ZWave add-ons. I finally got to where I can turn a light on or off from Node-Red using the Home Assistant "Call Service Node". But not without more head-banging. Nowhere did any of the tutorials or comments lead me to the "services" tab to build my data for the node properties. If I hadn't found that, my ZWave devices would be on eBay today.

Is there anywhere where the Call Service node properties are explained?
Where is there any description of "Domain" and which one to use? I tried "Switch" because it's a switch that I want to control. I tried "Zwave" because it is a ZWave switch. Neither worked. I just stumbled upon trying the "Home Assistant" domain. It worked.

For "Service" I guessed, apparently correctly, "turn_on", "turn_off" and "toggle".

I was stuck on the "Data" property for hours until I saw on a You-Tube video, for about a half-second where the presenter was using the Home Assistant "Services" tab to build the data in JSON format. Again, the tutorial that is entitled "Getting Started"- is apparently assumed that this was basic knowledge, and no need to explain.

Finally, no amount of searching illuminated any description of how or when to use the "Merge Context" property field.

ha-Service%20Node

Is there a "Home Assistant for Dummies" that I just missed?
Is there anyone here who is one or two steps ahead of me and can offer assistance?

Thanks.

2 Likes

Never seen one myself, but have received support from the Home Assistant forum, a lot of great people over there as there are here. The HA forum also has a Node-Red section now, although I tend to ask my questions here they are very helpful as well.

If you haven't yet, install node-red-contrib-home-assistant version 0.3.2, it is really easy to setup, add your HA ip address and password if you have one (highly recommended). Below is a sample automation that turns off a light after 15 minutes from when it was turned on (hopefully I inserted the snip correctly).
You will need to install the stoptime node to see how it works.
Give it a shot and let us know how it works out.

Clearly I didn't insert it correctly, but it is in the attached file.Turn-light-off-after-5-mins.txt (1.5 KB)

Are you using the "services" tab under Developer Tools in Home Assistant? This is where I build most of the JSON required for the "Call Service" node.

It provides drop-down selection of the service - which in your case would be light.turn_on. It then populates the list of possible entities for you, and after you select the right one it builds the JSON. At the bottom of the screen it also tells you the other JSON parameters that can be supplied (eg. transition). Home Assistant is not too bad about documenting further for the domain - in this case https://www.home-assistant.io/components/light/.

It's also worth noting that you can clear out the text in "service" in the Developer Tools and start typing to get a reduced list - so if you start typing "turn_on" you get all the things that can be turned on.

Then for Node Red, the part on the left of the '.' is the domain and the right is the service and you can copy/paste the JSON.

The Node Red "Info" tab documents the purpose of "Merge Context", but I haven't found a need for it yet, so I'm not sure why you'd ever need it. I've put it into the "when you're an expert" category.

Hi, sorry for not responding earlier, I was on vacation last week :sun_with_face:

What is described above is of course, as usual, one of several ways to do it. I did it using Automation rules. This allows you to create kind of generic rules instead of making one service call configuration for each entity/device/switch

In the rule, I added a trigger for each switch device using value_instance as payload

So when controlling the switch from NR, I just simply send a simple message holding the value_instance to HA via mqtt. In my example the switch will "toggle" on each command but you can of course create automation rules for "on" and "off" respectively.

I do not judge or have an opinion of "best way to do it", this is just the way I did it and there might be more smarter & efficient ways to minimize your configuration work in both ends

See pictures below

Thanks for all the responses. Part of my frustration was the crickets from the Node-Red forums where I usually get really fast and good help.

Unpuertomex: I haven’t tried adding Home Assistant nodes to my existing Node-Red, but that has moved to the top of my list of things to try after crashing my Alexa network. I was in the process of moving my flows from the existing Node-Red (on a Raspian box) to the Node-Red in my hass.io box. At this point Alexa stopped responding to discovery. I shut down Home Assistans and restored my original Node-Red box from a backup and all is working again. I have installed nodes and flows (the flows backup is 163kB) installed on my Raspian instance of Node-Red, so just putting Home Assistant nodes on the palette makes sense. After all, the only reason I installed Home Assistant (on a new Pi3) was to get access to my ZWave devices. I was moving my flows to the new instance to consolidate my smart home into one Pi box.

michaelblight: None of the tutorials or documentation pointed mt to that bit of knowledge. Only a fleeting (two seconds on a You Tube video from “The Hook Up” channel) of seeing the services tab used to build the JSON data got me steered in that direction. In a year I may look back and think “that was so obvious, how did I miss it”, but for now the basics of Home Assistant (Version 0.72.1) is an elusive target. Videos by Hook Up, BRUH and DrZzs all assume the viewer is already familiar with Home Assistant at this level. Even the “Getting Started” videos say simply things like ‘your entity ID goes here’ without ever explaining where a new user would find the entity ID. Yes, the Home Assistant documentation is pretty detailed, but knowing what to look for is the challenge. In your example you say “… the part on the left of the ‘.’ is the domain and the right is the service and you can copy/paste the JSON”. Fine if I have one light. But I have a dozen lights currently being controlled from Node-Red and Home Assistant doesn’t know about most of them. Where is the “domain” described or defined? Is the domain the same as a group? I only discovered by trial and error that my ZWave switches are in the “homeassistant” domain, not the “switch” domain because they are switches, and not the “lights” domain because the switches are controlling lights. Again, that list of domains is Greek to the new user.

krambriw: thanks for the info. I am finding (stumbling upon, really) more than one way to do anything in Home Assistant. And, there is never a “best” process. Ask three people how to do ‘something’ in Node-Red and you’ll get five solutions- and they all work. As I replied to Unpuertomex, above, I plan now to leave my existing Node-Red flows where they are now on a Raspian Pi3, and my ZWave switches in Home Assistant in another Pi3 running hass.io. If installing the Home Assistant nodes into my current Node-Red instance works as hoped then I should be able to interact with my ZWave switches through my Raspian instance of Node-Red. I am still a bit unclear on Groups. How do I determine what group a device falls into? I have two Inovelli ZWave switches and one is in “Switches” group and the other is in the “Lights” group. I don’t know how that happened or how to change it. I would have guessed groups.yaml, but that folder is empty.

Finally, thanks everyone for the tips. It is really appreciated. Hopefully in a year I will be answering newbies questions with a fraction of your knowledge.

Update: As said, I installed "node-red-contrib-home-assistant" through the Palette Manager. I drop a "Call Service" node to test with one of the ZWave lights. And when I Deploy, I get:

"Flows stopped due to missing node types. Check logs for details."

I delete the node from the flow and once again, Deploy works fine.

So, are there dependencies that I am missing?

Did you "check logs for details"? That should tell you which nodes are missing.

I would, but, Which log?

Update:
I restored my Pi from a backup and tried installing Home Assistant again through the Palette Manager. I put in the address of my Home Assistant server (http://192.168.1.128:8123). Now when I double-click on a node to set the node properties, I am getting this error:
Cannot GET /homeassistant/services

Any ideas would be appreciated.

I assume you mean node-red-contrib-home-assistant again?

You also mention hass.io in the initial description, if you are still using hass.io have you tried the URL format for that as per the contrib-nodes README?

If not I would suggest opening an issue on the contrib-nodes github page

given the info you gave us - can you browse to http://192.168.1.128:8123/homeassistant/services outside of Node-RED ?

I've tried both http://hassio/homeassistant and http://192.168.1.128:8123. But dceejay's question below is interesting...

Very interesting....
No.
http://192.168.1.128:8123/homeassistant/services returns a 404 error, but http://192.168.1.128:8123 opens Home Assistant just fine.

Hey Guys, i got the same error back from my nodered. My home assistant and Nodered runs in a Docker Container on a Synology Nas.

My homessistant url works fine. but i also cannot open http://ip:8123/homeassistant/services

has anyone an idea ??

thx

Sounds like a clash between the url root that node-red is using, and what home assistant expects. Can you show us what your settings.js file contains (really just the "node root" settings)? Also, please include the console log output when node-red starts up -- that will show what settings/directories/versions are actually being used.