Node-red-contrib-home-assistant-websocket

Release v0.5.0

New Features

  • Added secondary outputs for halt if logic for the current-state, events-state, and poll-state nodes

  • Call-service node now has the option for custom location output or no output

  • New node get-entities: Get entities based on search criteria with 3 different output options

Added

  • Added Spinner UI element to poll-state node

Changed

  • Refactored the UI for halt if logic into an external file and loaded on demand

Fixed

  • Fixed the handling of multiple entity ids for the homeassistant domain for the call-service node Fixed #57

If you run into any issues please report them on github


Hereā€™s a post to show some examples on how one might use the new get entities node.


Buy me a coffee For those that enjoy my work.

6 Likes

Since last hassio update I have this error:

21 Dec 12:15:17 - [info] [server:Home Assistant] WebSocket Connected to https://XXXXXXX.duckdns.org:8123 (node:625) UnhandledPromiseRejectionWarning: #<Object> (node:625) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:625) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:625) UnhandledPromiseRejectionWarning: #<Object> (node:625) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:625) UnhandledPromiseRejectionWarning: #<Object> (node:625) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) (node:625) UnhandledPromiseRejectionWarning: #<Object> (node:625) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

  • Node Red Version: [e.g. 0.19.5]
  • NR Home Assistant Plugin Version: [e.g. 0.5.0]
  • Is Node Red running in Docker: [e.g. yes/no/hassio]

Does this only apear in your logs when you reboot home assistant?

I updated from 0.43 to 0.50 and when restarting Node-RED I can no longer deploy (full, modified flows, or modified nodes) - There are no errors in Node-RED console or in debug. Iā€™m running Home Assistant 0.84.6 with a long lived access token, Node RED 0.18.3, and Node 9.8.0

EDIT: Updated Node-RED to 0.19.5 and now everything is working as expected

Solved with last HA update.

I am having similar issues as you described: I can never deploy twice with the same deploy setting. I have two change between 'Full Deploy" and ā€œOnly changed flowsā€ everytime. When I do try to deploy for the second time with the same setting I see this error: ā€œDeploy failed: no response from serverā€.

I am running both HA and Nodered as part of a docker-compose file. HA is on v0.84.6 and NodeRed on v0.19.5

Additionally, I noticed some wrong status info beneath deployed nodes:
This example has a status ā€œswitch.turn_on calledā€, but the service call is an input_boolean turn_on
28

And this example is another node, but that same input_boolean.turn_on service call, yet the status below the node states turn_off was called.
32

I double checked to make sure I had configured the nodes correctly, but they are. It looks like this is where some of my automations break.

Any tips on what I may be doing wrong, or is this a (known?) issue?

Not sure I have an answer to your first issue sounds more of a nod-red issue. May want to look through the issues on the GitHub node-red repo.

For your second issue do you have another call-service node somewhere prior to the one in the screenshot? The call-service passing its properties into the payload so when you chain them together the first one will override all following call-service config data. Either change the output location or set it to None.

thanks that seems to have fixed my problem, although I do not understand the logic behind it yet :slight_smile: Will get more into it. Thanks for making this awesome software!

Release v0.5.1

Fixed

  • Fixed get-entities to use custom label if valid

  • Correct possessive apostrophe in trigger state node constraint list (@albertnis)

  • Fixed condition where wildcard type state changes fired before current states were actually saved

  • Fixed onDeploy for trigger-state node when using substring/regex for entity id


If you run into any issues please report them on github


Buy me a coffee For those that enjoy my work.

After a crash of my home assistant, Iā€™m moving a lot of my applications into Docker. I have node-red operating in a Docker, but Iā€™m having an issue with installing the home-assistant-websocket node. I donā€™t have issues with other nodes, so Iā€™m assuming that itā€™s maybe a port forwarding issue, or similar inside of Docker. You may, or may not, be able to help and I thought Iā€™d just throw it out and see.

So, the installation goes just fine and completes without any errors. However, as soon as I restart the Docker I receive errors that the nodes canā€™t be deployed. When checking the status I see the blow:

Screenshot%20from%202018-12-31%2008-46-37

Also, pulling up the node-red log gives me this:

31 Dec 16:45:13 - [info]

Welcome to Node-RED

===================

31 Dec 16:45:13 - [info] Node-RED version: v0.19.5

31 Dec 16:45:13 - [info] Node.js version: v6.11.0

31 Dec 16:45:13 - [info] Linux 4.14.79-v7+ arm LE

31 Dec 16:45:14 - [info] Loading palette nodes

31 Dec 16:45:18 - [warn] ------------------------------------------------------

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/server] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/server-events] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/server-state-changed] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/trigger-state] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/poll-state] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/api-call-service] SyntaxError: Unexpected identifier (line:2)

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/ha-fire-event] SyntaxError: Unexpected identifier (line:1)

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/api-current-state] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/ha-get-entities] SyntaxError: Unexpected identifier

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/api-get-history] SyntaxError: Unexpected identifier (line:2)

31 Dec 16:45:18 - [warn] [node-red-contrib-home-assistant-websocket/api-render-template] SyntaxError: Unexpected identifier (line:2)

31 Dec 16:45:18 - [warn] ------------------------------------------------------

Any idea on what might be causing this? As mentioned earlier, I donā€™t have any issues with the installation of other simpler nodes such as timers, etc.

Thanks in advance!

From the README

If you're running Node-Red in Docker you'll need to pull the -v8 image for this to work.

Okay, Iā€™ll give that a shot. Itā€™s running on a Pi so I went with the RPI variant. Iā€™ll see if the v8 plays well with that hardware.

Thanks for the help. Iā€™ll report back once I have a chance to try it out.

thereā€™s a raspberry pi v8 version

rpi-v8

Hi,
Iā€™m running node-red in a docker-container, and have installed this module through the pallette. Home assistant is running on a different host in the same network. Everything is working fine at first, I can set up some flows and test them, node-red receives the events it supposed to. But, when left over night, the connection is somehow lost. I need to restart the nodered container to get the connection back.
I canā€™t find anything in the logs suggesting that the connection is lost, only thing there is [info] [server:Hass] WebSocket Connected to <host>.

Iā€™m a new with node-red, can I enable some extended logging to help out with debugging?

I donā€™t see anything on the home assistant side on losing connection. Should I enable some debug logging there as well?

Iā€™m running v0.5.1 of the module, but it was the same thing in previous verison.
Node-red docker-compose container running on fedora host:

[info] Node-RED version: v0.19.5
[info] Node.js  version: v8.12.0
[info] Linux 4.18.19-100.fc27.x86_64 x64 LE

Edit: When the connection is lost, the node-red ui seems happy, but it wonā€™t receive any events from home assistant.

When it goes into its ā€œnon receivingā€ state are you able to trigger a call-service node and see if it completes, like turning a light on/off?

Yes. In that state, I can use the inject node to trigger a service call

The injected call succeeds, and my light is toggled. But when I click my button that triggers the event, nothing gets in the debug log.

Above is just one example. I have a flow that listens for other events, and another that listens for state change. Both behave the same as the above.

Quick but for me complex question.

What does this actually mean?

ā€œCall Service and Fire Event nodes are now able to render mustache templates in the data property. Templates also work on the new entity id field for the Call Service nodeā€

Any property of the message object that gets passed into a call-service node is accessible via a template variable.

Example message object being passed in

message: {
  payload: "home",
  data: {
    attributes: {
       friendly_name: "Jason"
    }
  }
}

You can use these values within the Data field. Variables are defined by having double curly brackets around them. So to access the message.payload you would use {{payload}}

Before you were able to use templates within the data string you had to use a template or function node to format the data property before passing it to the call-service node.

Try dropping a events: all node with a full debug message node and see if that is still outputing events.

[{"id":"e5b10769.4c9968","type":"server-events","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","event_type":"","x":204,"y":784,"wires":[["1b5ee05f.b199f"]]},{"id":"1b5ee05f.b199f","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":338,"y":784,"wires":[]}]

Kermit

Is there any difference (dumb question time) between ā€˜node-red-contrib-home-assistant-websocketā€™ and ā€™ Community Hass.io Add-ons: Node-REDā€™?

The terminology (for a non-tech person) confuses me.

I have been using ā€™ Community Hass.io Add-ons: Node-REDā€™ for a long time, and when I look at the pallet manager I can see ā€˜node-red-contrib-home-assistant-websocketā€™ as installed

I am considering (as I have a spare 3B+) putting Node Red with your branch and my MQTT broker on it.