Node-red-contrib-home-assistant-websocket

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

Hi,
maybe some can help me here. I’ve got a problem with calling a service…it worked before but after updating nodered and the modules, it doenst any more.

[{"id":"4507af1.20902d","type":"api-call-service","z":"bbc75b97.89d83","name":"","server":"ae1092a9.b59548","version":1,"debugenabled":true,"service_domain":"vacuum","service":"send_command","entityId":"vacuum.rockrobo_staubsauger","data":"{\"data\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":1160,"wires":[[]]},{"id":"74903dec.745d14","type":"debug","z":"bbc75b97.89d83","name":"Ende","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":1120,"wires":[]},{"id":"c629185d.a7ff38","type":"change","z":"bbc75b97.89d83","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"command\":\"zoned_cleanup\",\"params\":{\"zone_ids\":[]}}}","tot":"json"},{"t":"set","p":"payload.data.params.zone_ids","pt":"msg","to":"daten-raum","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":1040,"wires":[["74903dec.745d14","4507af1.20902d"]]},{"id":"ed35dc70.2a1a78","type":"change","z":"bbc75b97.89d83","name":"","rules":[{"t":"set","p":"daten-raum","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1140,"y":980,"wires":[["c629185d.a7ff38"]]},{"id":"ae1092a9.b59548","type":"server","name":"HA local","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I have no idea where this data: object object comes from.

Not sure what version you upgraded from but I am surprised this worked before as mustache templates don’t handle non-string types very well.

If you’re not using the flow variable in another location you can do the above all within the call-service node.

[{"id":"4507af1.20902d","type":"api-call-service","z":"ffbd7f06.4a014","name":"","version":1,"debugenabled":true,"service_domain":"vacuum","service":"send_command","entityId":"vacuum.rockrobo_staubsauger","data":"{\t   \"data\":{\t       \"command\":\"zoned_cleanup\",\t       \"params\":{\t            \"zone_ids\": payload\t       }\t   }\t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":440,"y":1328,"wires":[[]]}]

with the flow variable

[{"id":"4507af1.20902d","type":"api-call-service","z":"ffbd7f06.4a014","name":"","version":1,"debugenabled":true,"service_domain":"vacuum","service":"send_command","entityId":"vacuum.rockrobo_staubsauger","data":"{\t   \"data\":{\t       \"command\":\"zoned_cleanup\",\t       \"params\":{\t            \"zone_ids\": $flowContext('daten-raum')\t       }\t   }\t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":440,"y":1328,"wires":[[]]}]
1 Like

Many thanks. It now works but I removed the data tag…since the payload is already in data tag.
Yeah, I updated the last time half a year ago or so…

The working node now looks like this.

[{"id":"f3ba6f37.4aacc8","type":"api-call-service","z":"bbc75b97.89d83","name":"","server":"ae1092a9.b59548","version":1,"debugenabled":true,"service_domain":"vacuum","service":"send_command","entityId":"vacuum.rockrobo_staubsauger","data":"{\t   \"command\":\"zoned_cleanup\",\t   \"params\":{\t       \"zone_ids\": payload\t       }\t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1120,"y":1120,"wires":[[]]},{"id":"ae1092a9.b59548","type":"server","name":"HA local","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I’ve been using this fork for quite a long time and it’s been fantastic. I had a question though about the version. I noticed when editing subflow properties I don’t have as many options as I see in the official documentation:

This is what I see locally: image

Any idea why those additional options and tabs are not showing up in this node-red fork?

This package has nothing to do with what version of Node-RED you’re running. You would upgrade Node-RED separately.

https://nodered.org/docs/getting-started/

Whoops, I don’t know why I thought this palette had anything to do with my node-red version. Thanks! Turns out I had the node-red version hard-coded in my docker-compose.yaml file.

Regarding node-red version, I’m running docker container using nodered/node-red-docker:v8, I believe I read somewhere that I need to use this version to work with HA properly. Is this correct? If not what is the latest version that I can use?