Node-red-contrib-home-assistant-websocket

The add-on merely runs node-red in a container. It has a preconfigured palette to connect to home Assistant

The ‘node-red-contrib-home-assistant-websocket’ is the palette used in node-red

Because that’s the palette being used by the add-on.

Node-red is really nothing to do with home assistant. It’s a separate project that has been around for years. There just happens to be a way to connect to home assistant and use it. Some of us don’t run hassio, but use node-red to run our automation, so the palette is a way for us to connect them.

Thanks @Kermit for this!

Just migrated to it from the llat version…totally painless - all previous flows work fine.

To confirm what I did:

Stop Node Red
cd to the Node Red directory on my box
nano package.json
remove the line with the node-red-contrib-home-assistant-llat package, close and save file.

cd  node-modules
rm -r node-red-contrib-home-assistant-llat
cd ..
npm install node-red-contrib-home-assistant-websocket

Then reboot. I then created a new access token in HA and everything connected!

The reason I manually removed the old package is that I was having all sorts of issues with files being left behind the other way.

Thanks again and hopefully I am ‘future proofed’ for a while as I know the llat node is not being developed any further.

I spoke too soon. After about 2 hours I get errors:

‘Error calling service. Home Assistant API error’

Reboot and it works for another couple of hours.

I am on HA 0.84.6, NR 19.2 on the latest version of the node. Tried using both access token and legacy password. Running it in a LXC container (not docker). Weird as I saw issue HERE that has been closed but it seems to describe the intermittent issue I had.

Restored from a backup (i just love Linux containers!) and back on the LLAT at the moment. Any ideas?

Thank you. Appreciate the explanation.

Can you post your call-service node and the a full output debug message of the node before the call-service node?

I misread your post, and outputed msg.payload. At 3 AM, the events just stopped coming in. Nothing in the node-red debug log indicates anything wrong, and nothing in home assistant. I’ve updated the debug print, and added debug logging for homeassistant.components.websocket_api. I hope I can get something good out of that.

Doing a re-deploy seem to wake the connection, and the events come in again.

I also have a polling flow, that stops working at the same time. So even if the websocket is up, it seems stale.

Will do in a bit. Need to reinstall node again to do this.

I did do it yesterday again and although it worked, it took about a minute for state changes etc - if at all.
A re-deploy got things working again for about 5 mins before it broke. I’ll see when I have time later today to reinstall as obviously troubleshooting without the logs is impossible!

Once I rolled back to the LLAT node all worked fine again and motion sensors etc were instant.

Thanks

EDIT: looking at dlindau’s post - these seem to be the exact issues I am getting. You wouldn’t know there are issues in the UI or in HA…except that nothing is being passed (or if so very slowly) from HA to NR. All node show as connected.

Had it running last night, and the events stopped coming in at 3AM again. The time have given me a clue what it might be about. :slight_smile:

I reboot my wifi router every night at 3am, since it has some issues if it runs for too long. Enabling debug logs in HA gave me a lot of stacktraces around that time, but nothing in node-red. So HA seems to get the everything up again, while node-red can’t.
Browsing through the HA logs I can see that a new incoming websocket is set up as soon as the network becomes available again. But node-red is still in the stale mode.

I also realized that I fooled myself earlier. In this stale mode, I can’t trigger anything from my inject-button. Instead I get an API Error. So I think @markbajaj and I see the exact same thing. Earlier I had to do a deploy to get the button up, which woke the websocket up.

I remember reading something about there being some problem with HA restarting, and the websocket became unavailable. Maybe this is the same thing then?

1 Like

What version of Home Assistant are you running?

I’m running 0.84.6

Also to get more debug information for the logs you can start node-red with DEBUG=home-assistant* node-red.

ignore. No idea how I fixed it, but it is working now.

In the process of moving HA to a linux box running on my network and installing NR on a rPi. HA is working fine, and NR is up and running. I installed the Node-red-contrib-home-assistant-websocket, and am attempting to connect to HA with no luck. I enter the HA instance ip address and put in the long lived access token, but I get an error message of “can’t get entities”. I’m running the latest version of NR on latest version of raspbian (no docker or anything). I have the v10.15.0 of node.js. I am running HassOs on the Linux box (Mint), and version 0.84.6 of HA.

One thing that might be going on is that Hass has the NR addon installed. I tried stopping it, and connecting the rPi but that didn’t work. Should I uninstall the addon? Or is there some other issue?

Hi all. New here, had a good read but…

I’m struggling to get the call service node to send the data I am inputting into it to home assistant.

To clarify the system is working as it should afaik. I just can’t get the node to output the data.

I’m trying to get it to call climate.set_temperature with a temperature. I’m sending the required temperature to the node from a thermostat node. The msg.payload is just a number

The debug from the thermostat is:

13/01/2019, 23:25:53node: Living room temperature set point.

target : msg : Object

object

topic: “target”

payload: 18.29

qos: 0

retain: false

_msgid: “f242126d.2f46c”

The debug from the call service node is:

13/01/2019, 23:25:54node: 38f8212b.381b56

target : msg : Object

object

topic: “target”

payload: object

domain: “climate”

service: “set_temperature”

data: object

entity_id: “climate.danfoss_popp_radiator_thermostat_heating_1”

temperature: “”

qos: 0

retain: false

_msgid: “f242126d.2f46c”

So, in short. How do I get the 18.29 from the thermostat between the “” of the call service output?

Sorry if this is simple and I’m sure it’s very obvious but I’m struggling.

Regards.

Need to set the temperature in the data field

[{"id":"ac0146ab.de3628","type":"api-call-service","z":"6edf92e.d52b66c","name":"","server":"8d00ebbc.99a928","service_domain":"climate","service":"set_temperature","data":"{\"entity_id\":\"climate.danfoss_popp_radiator_thermostat_heating_1\",\"temperature\":\"{{payload}}\"}","render_data":true,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":742,"y":448,"wires":[[]]}]
1 Like

Thanks. It works now. I was using {“temperature”:"{{msg.payload}}"}

I also noticed I was using an old version of the node.

Not sure what I did but my debug in Node-Red is now filled with

"Home assistant connection failed with error: Connection to home assistant could not be established with config: https://notmydomain.duckdns.org:8123 <password redacted>"

for each variant of the URL I tried… ie 4-5 messages keep spamming in the debug even if I remove the connection, uninstall the contrib etc… anyone know how I can remove it?

This error message isn’t from this fork it’s from one of the other two make sure you own have only one installed.

If you have command line access:

$ cd ~/.node-red
$ npm uninstall node-red-contrib-home-assistant
$ npm uninstall node-red-contrib-home-assistant-llat
# restart node-red

New Release v0.6.0

New Features

  • The call-service node autocomplete for entity_id now handles multiple entities

  • The properties field of a trigger-state node now has autocomplete

  • Added a new comparator, ‘in group’, to the get-entities node

  • Get-history node can use a relative time string for its date fields

Added

  • A more verbose error message for the autocomplete error when the server config hasn’t been deployed

  • More informative error message for the call-service node when there’s an API error

Changed

  • Change the connect timeout for hass.io users so it doesn’t bombard the proxy when attempting to connect. (#76)

Fixed

  • HomeAssistant object updated before firing state_change event (#74)

  • Fixed HTTP API so it returns an empty string and not the response object when res.data is empty.

(#78)

5 Likes