Node-red-contrib-home-assistant-websocket

Its OK now - there was a temporary outage with the NPM repository earlier this evening

Craig

Unfortunately due to the 115 update, I had to setup a complete new ha instance.
But anyway, currently everything is running quite nice, except Node-red websocket which is quite critical for me.

My HA system + proxmox

arch	x86_64
chassis	vm
dev	false
docker	true
docker_version	19.03.11
hassio	true
host_os	HassOS 4.13
installation_type	Home Assistant OS
os_name	Linux
os_version	5.4.63
python_version	3.8.5
supervisor	245
timezone	Europe/Berlin
version	0.115.2
virtualenv	false

NodeRed addon: Current version: 7.2.0
HACS Node Red: v0.4.4

I followed the instucktions:

  1. Installed Node Red in HACS
  2. Restarted HA
  3. Opend Integrations,
    but Node-RED is not listed. Whatever I do, tried all avaliable versions but always same result. In my old HA 114 its working perfect. Just have no idea what to try. Btw. can’t find any error in logs regarding Node red…

Any advise is much appreciated.
Thanks


Edit:

after few hours suddenly it just worked, I’ve just tried everything in different order, so I can’t tell what exactly fixed my issue, but anyway thanks :slight_smile:

New Release 0.26.0 (2020-09-27)

Features

  • trigger-state: conditions and custom outputs editable (358c909), closes #221

  • zone: add ability to expose to HA (a35a571)

  • Add zone node (3ac9cf4)

Bug Fixes

  • zone: update autocomplete source after new data received (a6d6c29)

  • fix conditional for null old_state (ac9158e)

  • ignore state_changed event if old_state is null (6f0a8b5), closes #266

0.26.1 (2020-09-27)

Bug Fixes

  • trigger-state: fix autocomplete for entity id field (6ce5d0d)

Buy me a coffee For those that enjoy my work.

4 Likes

New Release 0.27.0 (2020-10-06)

Features

  • event-state: Add predefined ignore event types (d70ba6f)

  • events-state: Add for condition (61021a8)

  • zone: Add enter or leave event type (735437b)

Bug Fixes

  • event-state: Add default for unit (1d66aca)

  • revert change to ignore state_changed with prev state was null (4503856), closes #271

0.27.1 (2020-10-06)

Bug Fixes

  • event-state: Pass the correct level of the event to msg.data (4676c08)
  • event-state: Use the correct clear for setTimeout (db39c3d)

0.27.2 (2020-10-11)

Bug Fixes

  • events-state: Don’t reset for timer if state changes but condition is still true (2735eb2), closes #277

Documentation

  • events-state: Change some wording (711f334)

0.27.3 (2020-10-11)

Bug Fixes

  • events-state: reset timer active flag when condition is false (d119307)

0.27.6 (2020-12-01)

Bug Fixes

  • event-state: check if old state is valid before attempting to access state (a16e964)

  • fix eslint and prettier changes (8497b1a)

Documentation

  • cookbook: Add starting a flow after HA restart example (b82affd)

  • Add zone to node index page (0b5407a)


Buy me a coffee For those that enjoy my work.

4 Likes

Holy crap @Kermit… You’ve outdone yourself on this one! LOVE the new options in the event nodes.

The hassio add-on picked up 0.27.0, and a lot of my flows use the msg.data.new_state.attributes which was fixed in 0.27.1. When I try to use the latest package by configuring hassio with npm_packages overrides (below), the log shows that it installs 0.27.1 OK, but with lots “does not exist” errors. Then, unsurprisingly, node-red says the nodes are missing.

Anyone else seeing this and have a fix?

Thanks!

Configuration snip:

"npm_packages": [
  "git+https://github.com/zachowj/node-red-contrib-home-assistant-websocket"
], 

Log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Node-RED
 Flow-based programming for the Internet of Things
-----------------------------------------------------------
 Add-on version: 7.2.3
 You are running the latest version of this add-on.
 System: HassOS 4.13  (armv7 / raspberrypi3)
 Home Assistant Core: 0.115.6
 Home Assistant Supervisor: 246
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to WARNING
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] node-red.sh: executing... 
patching file nodes/ui_base.html
Hunk #1 succeeded at 1178 (offset 647 lines).
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
audited 2 packages in 1.002s
found 0 vulnerabilities
[cont-init.d] node-red.sh: exited 0.
[cont-init.d] user.sh: executing... 
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
added 33 packages from 23 contributors, updated 1 package and audited 1065 packages in 77.401s
48 packages are looking for funding
  run `npm fund` for details
found 6 vulnerabilities (3 low, 3 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
> addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
/bin/sh: /opt/node_modules/node-red-node-pi-gpio/testgpio.py: not found
6 Oct 20:35:11 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
6 Oct 20:35:12 - [warn] ------------------------------------------------------
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/server] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/config-server/config-server.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/server-events] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/events-all/events-all.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/server-state-changed] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/events-state-changed/events-state-changed.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/trigger-state] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/trigger-state/trigger-state.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/poll-state] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/poll-state/poll-state.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-webhook] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/webhook/webhook.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-zone] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/zone/zone.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/api-call-service] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/call-service/call-service.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-entity] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/entity/entity.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-fire-event] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/fire-event/fire-event.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/api-current-state] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/current-state/current-state.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-get-entities] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/get-entities/get-entities.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/api-get-history] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/get-history/get-history.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/api-render-template] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/render-template/render-template.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-wait-until] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/wait-until/wait-until.html does not exist
6 Oct 20:35:12 - [warn] [node-red-contrib-home-assistant-websocket/ha-api] Error: /opt/node_modules/node-red-contrib-home-assistant-websocket/nodes/api/api.html does not exist
6 Oct 20:35:12 - [warn] ------------------------------------------------------
6 Oct 20:35:12 - [warn] Projects disabled : editorTheme.projects.enabled=false
nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)

Node-Red error:

npm_packages:
  - node-red-contrib-home-assistant-websocket@latest
1 Like

I created a bunch of sensors in Home Assistant via this wonderful integration.

Am I correct in thinking that sensors created via Node Red that then appear in Home Assistant … should then appear back within Node Red to be leveraged within flows?

I have a Node Red flow that takes JSON data and turns it into a sensor with an output.

That sensor then correctly appears in HA.

But for some reason that sensor is not appearing in Node Red when i try to create a ‘current state’ node. All my other hundreds of sensors and other entities obviously appear, but none of the ones I created via Node Red.

Not sure if it takes more time for the autocompleted to work (it’s been 30 min or so) or what.

Thanks!

Is there any fix to “Sensor update attempted without connection to server.” besides disabling custom integrations in HA? Disabling custom integrations is making HA kind of obsolete, if HA is empty there is no use for running HA… Below is the underlying problem as far as I understand.

20-10-08 10:11:34 INFO (MainThread) [supervisor.api.proxy] WebSocket access from a0d7b954_nodered
20-10-08 10:11:34 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API request running
20-10-08 10:11:35 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API error: Received message 258:WebSocketError(<WSCloseCode.MESSAGE_TOO_BIG: 1009>, ‘Message size 4747108 exceeds limit 4194304’) is not str
20-10-08 10:11:35 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API connection is closed

Node-RED integration pulls all the HA information in one API request that in turn ends up in a too large request.

When adding entities from any source it should be close to instant for them showing in up in NR. If this doesn’t happen for you there is probably a caching issue of the autocomplete results in your browser.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/FAQ.html#entities-not-showing-in-the-autocomplete-dropdown

@hrdejong
As far as my knowledge goes there is currently no way to change how this package queries the entities from HA. What custom integration as you using that store’s so much information in the entity list?

You could try bypassing the hass.io proxy and connecting directly to HA but that might not work either as it’s the aiohttp python library that is setting the hard limit on message size.

Got about 150 - 200 entities in HA, where possible disabled.

Integrations are:

  • Atag
  • Google Cast
  • HACS
  • Internet Printing
  • MQTT
  • Weather
  • Node-RED
  • Pi-hole
  • SolarEdge
  • Samsung smart TV
  • Sonos
  • Synology
  • Unifi

There is not much I can help you with here. You’re going to have to look through your entities and find which ones have a crazy amount of data in the state or attribute fields.

Do you know where I can find the raw data like that from entities?

Update: remembered what integration does a lot of data… the unifi integration pulls all alert info when you enable the “alerts” entity (configuration.yaml). disabled this one and Node-RED is spitting out info again to HA.

Hello! How I can transfer the entity_id to the api-call-service through the msg.payload?

msg.payload.data.entity_id

Thanks. If I write
msg.payload.data.entity_id = input_boolean.input_boolean_1
in the inject-node then everything works.
What should I write in function-node? This:

msg.payload.data.entity_id = "input_boolean.input_boolean_1";
return msg;

doesn’t work.

In a function node, you’d have to do it like this:

msg.payload = {
    data: {
        entity_id: 'input_boolean.input_boolean_1'
    }
}

Ive noticed now there appears to be a new “zone” node that can be used. Has anyone got this working? I cannot seem to get it trigger. All i am doing is putting a single person entity, a single zone, but it never triggers when that entity enters or leave the zone. The output on the flow just shows the entity_id of the person, but nothing passes through to the next node? I would expect that when the entity enters or leave the zone the output would be the zone name. Am i assuming correctly or is there some other config required for this to work?

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

1 Like