Node-red-contrib-home-assistant-websocket

Sensor nodes identify themself to HA by a combination of the server-config node id and the node id of the sensor node. So when that changes in NR Home Assistant thinks it’s a brand new sensor.

A possible solution is to go into the entity registry and delete the original sensor entity_id then rename the entity_id of the new sensor.

Thanks but that is unfortunately not the problem. I’ve tried and it always returns false, furthermore, the configuration node is by default set-up like this:

The On/Off does also work on all my other input_booleans.

Also in the same flow if I make an input on a event change for the sleeping boolean, it detects it correctly:

I’m really lost :frowning:

What does the state of the input Boolean show in home assistant?

Hi Kermit,

Just on or off, in home-assistant seems to all work OK.

image

Drop a debug right before the current state node. Does it contain a msg.payload.entity_id? If so it’s overwriting the current state nodes entity id and is actually looking up that entity’s state.

Check the Block Input Overrides box in the current state node.

Edit:
I can pretty much say that’s your issue based off the screenshot of the debug window.

New Release 0.19.1

Documentation for the Node-RED information panel is now automatically generated from the markdown documentation.

If you see errors or items that need better clarification. All you have to do it click on the link at the bottom of any of the documentation pages.

image

All examples found in the cookbook are now available directly from the examples tab on the import menu in Node-RED.

Bug Fixes

  • include correct files when publishing to npm (8f8eb6f)
  • point changelog to new documentation (0c1a93e)
  • run correct task for convert docs action (b9b3ee4)
  • Catch rejection for lost connection when unsubbing (0008406)

Features

  • docs: Markdown docs will be automatically converted to NR help files (5abfb62)
  • api: Add debug ouput option (72cf55b)
  • sensor: Add the ability to choose how input values are handled (cbd48b9)

0.19.2 (2020-01-06)

Bug Fixes

  • get-history: Don’t send an enddate when using relative time (d536c3c), closes #183
  • get-history: Fix for using flatten results with output type split (38b9c9c)

Buy me a coffee For those that enjoy my work.

4 Likes

Hi.
Please can you help me. Im unable to transfer data from any sensor (i.e. temperature) to Hass.io.

I have a simple flow,


get data from UDP (from arduino temp. sensor) and transfer it to Hass.io.

Output from function block is this:

OneWire/2699EFE501000090 : msg.payload : Object
{ temperature: 23.843 }

But there is a problem with API node, which is unable to connect to Hass.io.

It show me this log:

5 Jan 23:12:27 - [info] [server:http://hassio/homeassistant] WebSocket Connected to http://hassio/homeassistant
5 Jan 23:12:35 - [error] [ha-api:3b52fbe5.c96594] Error Message: Request failed with status code 404

That is the config of this API node:


API_3

Where is a problem?

{{entity_id}} in the path field assumes that msg.entity_id will contain a value. I’m assuming it doesn’t based on the 404 coded returned by HA.

https://developers.home-assistant.io/docs/en/external_api_rest.html#post-apistatesltentity_id
POST /api/states/<entity_id> expects the data field to contain at least state to be set. You’re passing { temperature: 23.843} as just msg.payload it expects it to be in msg.payload.data.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/API.html#input

Change your function node to out the temperature value to msg.payload.data.state

msg.payload =

{
    "data": {
        "state": 23.843
    }
}

Checking the Show Debug Information will give you the output of what the node is sending to HA.

So you’re running home assistant on port 80? Or running a reverse proxy?

Why are you pointing to a path? It should just point to your hassio instance.

No, I use default port 8123 (and no proxy). Should I set it somewhere?

When I set Path (in API node) to /api/states/msg.payload and correct function node as you describe it works ok.
It create in Hass.io new entity msg.payload.
But when I want to rename it (i.e. on onewire2ha_temperature_livingroom) it doesnt work :frowning:
I simply change the Path to /api/states/onewire2ha_temperature_livingroom

/api/states/sensor.onewire2ha_temperature_livingroom

1 Like

Thanks. It works perfect!

Sorry. Your server name (terrible choice BTW) had me mistaken to be the URL you were connecting to.

I’ve been running an old version and recently tried upadating to the most current. I’m running in Docker and ran the following commands to updated within the docker

docker exec -it node-red /bin/bash

Followed by

cd /data

and then

npm install node-red-contrib-home-assistant-websocket

After that I receive the following warnings

node-red@07eccede3280:/data$ npm install node-red-contrib-home-assistant-websocket
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm http fetch GET 304 https://registry.npmjs.org/node-red-contrib-home-assistant-websocket 769ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/axios 155ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/debug 309ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ws 326ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/is-buffer 119ms (from cache)
npm info lifecycle [email protected]~preuninstall: [email protected]
npm info lifecycle [email protected]~uninstall: [email protected]
npm info lifecycle [email protected]~postuninstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info linkStuff [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN [email protected] requires a peer of moment@>= 2 but none was installed.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none was installed.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none was installed.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

+ [email protected]
updated 1 package in 13.204s
npm info ok 

Unfortunately this has caused the websocket to stop working. Is there something new that needs to be installed which I seem to be missing?

Any assistance is appreciated. Thanks!

Update your node-red image. The one you’re using is still using node v8.1.3.

Okay, thank you. I’ll try and pull the latest rpi variant.

Okay, so I upgraded to the latest ARM variant of Node-Red, but I’m not receiving the following errors upon boot.

Welcome to Node-RED

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


11 Jan 08:58:15 - [info] Node-RED version: v1.0.3

11 Jan 08:58:15 - [info] Node.js  version: v10.17.0

11 Jan 08:58:15 - [info] Linux 4.19.66-v7+ arm LE

11 Jan 08:58:16 - [info] Loading palette nodes

11 Jan 08:58:36 - [warn] ------------------------------------------------------

11 Jan 08:58:36 - [warn] [node-red-node-serialport/serialport] Error: The module '/data/node_modules/serialport/build/Release/serialport.node'

was compiled against a different Node.js version using

NODE_MODULE_VERSION 57. This version of Node.js requires

NODE_MODULE_VERSION 64. Please try re-compiling or re-installing

the module (for instance, using `npm rebuild` or `npm install`).

11 Jan 08:58:36 - [warn] [node-red-contrib-home-assistant-websocket/server] Error: Cannot find module 'home-assistant-js-websocket'

11 Jan 08:58:36 - [warn] ------------------------------------------------------

11 Jan 08:58:36 - [warn] Missing node modules:

11 Jan 08:58:36 - [warn]  - node-red-node-email (1.6.3): e-mail, e-mail in

11 Jan 08:58:36 - [warn]  - node-red-node-feedparser (0.1.14): feedparse

11 Jan 08:58:36 - [warn]  - node-red-node-twitter (1.1.5): twitter-credentials, twitter in, twitter out

11 Jan 08:58:36 - [warn]  - node-red-node-base64 (0.1.3): base64

11 Jan 08:58:36 - [warn]  - node-red-node-msgpack (1.1.3): msgpack

11 Jan 08:58:36 - [warn]  - node-red-node-suncalc (0.0.11): sunrise

11 Jan 08:58:36 - [warn]  - node-red-node-sentiment (0.1.4): sentiment

11 Jan 08:58:36 - [info] Removing modules from config

11 Jan 08:58:36 - [info] Settings file  : /data/settings.js

11 Jan 08:58:36 - [info] Context store  : 'default' [module=memory]

11 Jan 08:58:36 - [info] User directory : /data

11 Jan 08:58:36 - [warn] Projects disabled : editorTheme.projects.enabled=false

11 Jan 08:58:36 - [info] Flows file     : /data/flows_home_assist.json

11 Jan 08:58:36 - [info] Server now running at http://127.0.0.1:1880/

11 Jan 08:58:36 - [warn] 

Is there something else that I need to install that’s now missing?

I’ve tried adding the custom components, but for some reason the integration is not showing from the drop-down list. I’m guessing this is where I’m having issues?

From the logs it appears that it is loading, but it’s still not present on the integrations page.

2020-01-11 10:02:44 INFO (SyncWorker_3) [homeassistant.loader] Loaded nodered from custom_components.nodered

2020-01-11 10:03:26 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for nodered which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.  

Okay, well after several restarts, and trying to copy everything over it seems as though I’m now able to get the Integrations to show, but unfortunately node-red is still giving me the following errors:


11 Jan 22:23:37 - [info] Waiting for missing types to be registered:

11 Jan 22:23:37 - [info]  - server

11 Jan 22:25:47 - [info] Stopping modified nodes

11 Jan 22:25:47 - [info] Stopped modified nodes

11 Jan 22:25:47 - [info] Waiting for missing types to be registered:

11 Jan 22:25:47 - [info]  - server

11 Jan 22:26:22 - [info] Stopping modified nodes

11 Jan 22:26:22 - [info] Stopped modified nodes

11 Jan 22:26:22 - [info] Waiting for missing types to be registered:

11 Jan 22:26:22 - [info]  - server

11 Jan 22:26:41 - [info] Stopping modified nodes

11 Jan 22:26:41 - [info] Stopped modified nodes

11 Jan 22:26:41 - [info] Waiting for missing types to be registered:

11 Jan 22:26:41 - [info]  - server

Is there a step that I’m missing to get the - server registered?

I would try reinstalling the npm package or maybe remove the node_modues directory and reinstall them all.