Accidentally broke a working Node-Red/HA setup. Maybe by deleting "server"? - SOLVED

I’m running Hass OS on a Raspberry Pi and very recently installed the Node Red Addon, plus the Node Red Companion from HACS. I then set up two flows with one sequence each (sorry if I’m bungling the terminology, as I said, I’m still really new to Node Red), both using the HA button function in Node Red.

Upon refreshing, both buttons showed up as entities under the Node Red integration in HA, and they both worked fine. Happiness!

Then, after reading a bit more about Node Red, I learned that I didn’t need a flow tab for each sequence, and that I could put them together on one, so I did that and deleted the spare flow tab. I then turned my mind to further cleaning up, and noticed that the “server” node was apparently unused, so I deleted that as well.

Upon refreshing, my Node Red entities in HA were gone, and nothing I could do would bring them back.
I have restarted, refreshed and reloaded both HA and Node Red multiple times.
I have removed the Node Red Add-on, and the Node Red Companion from HA, both together and seperately, to try reinstalling them. To no effect.

In Node Red, when I click on the HA-button node (element?) I get a red box telling me that:

" Attention: This node requires Node-RED custom integration version 1.0.4+ to be installed in Home Assistant for it to function."

But I have the latest version (1.11?) installed. For good measure, I have removed it and followed the link above and installed manually following the instructions. No effect.

What have I done? And how can I undo it?

All the configuration nodes are ‘hidden’ and can only be see in the right hand debug window under ‘configuration’ option or when a particular node opens the linked config node for editing.
In the configuration page, each config node has the number of nodes that are using it at the right, and clicking on the config node will open a list of linked nodes. Worth checking that any config node is not in use before deleting it. Also, the HA server node is usually added automatically, but it can be added manually or edited quite easily. Probably you only needed to re-create a new Home Assistant server configuration node…

I have not (yet) broken my Node-RED but came close to doing so two nights ago as there has been a recent update to the websocket nodes and the companion integration. This is a significant change to the HA entity node, which is now deprecated in favour of a set of individual home assistant entity nodes.

First. I believe that uninstalling stuff on HA does not perform a file clean up. Removing such things as Node-RED probably requires a manual deletion of left over files, otherwise a re-install may end up reusing old setting files.

Second. For Node-RED to work with HA it requires both the node-red-contrib-home-assistant-websocket nodes to be installed into the pallet (this provides the nodes) and also the node red companion as an integration (this provides the websocket connectivity between HA and Node-RED to make these nodes work). The HA server config node defines the connection between HA and the HA ndoes.

A recent update (6 September 2022) has moved the node-red-contrib-home-assistant-websocket to version 0.45.0 (27 nodes). You can check the version in Node-RED, manage pallet

I updated to this version and broke all my HA entity nodes - these are now replaced with the home assistant sensor node (for entity nodes used as sensor). I had to update Node-RED companion integration, which is now on version 1.1.1. Doing this update now means I can use the new home assistant entity sensor node. This does have a great big warning message all over it, but I suspect that this is just the author of the nodes/integration warning that this new node will only work with companion version 1.1.0 or higher.

So - you appear to have installed Node RED companion version 1.1.1, which will now only work with node-red-contrib-home-assistant-websocket version 0.45.0 onwards, however your node error message (different to mine) suggests that you have an earlier version of the node set in your pallet.

May I suggest:
Check that you have the latest version of Node-RED addon installed, and that it is working (editor page, add inject/debug nodes, deploy, flow works etc)

Check that you have the latest version 0.45.0 of the node-red-contrib-home-assistant-websocket node with the new 27 node set. If not, update (see pallet)

Check that you have the latest version 1.1.1 of the Node-RED companion integration. You can check this by looking at the config/custom_components/nodered folder for a file called manifest.json which can be opened with a text editor. This happy little file has the Node-RED companion version number at the bottom.
Worth also checking all the files in the custom_components/nodered folder are correct - I had to manually rename my existing nodered folder (for safety), create a new folder, and copy all the files from GitHub by hand.

Now, if all that works, we just need to get your HA server back.

Check the right hand menu, under ‘configuration’ and check to see if there is a Home Assistant node under ‘server’. If not, then one can be created quite easily.

  • place an HA node into the editor (I think any HA node will do)
  • at the top, in the Server field, select ‘add new server’. Click edit icon
  • in the server node edit box enter the necessary fields

This is just what my set up has by default…

This should (re)create an HA server config node for you, which can be selected when you create/edit any of the HA nodes.

Note- the new home assistant entity nodes have individual configuration nodes that have to be set up, and these configuration nodes tie back to the HA server node, rather than the HA node connecting to the HA server config node directly. To get to the HA server in the new nodes the edit path is
edit (sensor) node > edit ha entity config node > edit server node

I hope this is of some help to you

update

My usual habit of keeping a copy of the ‘old’ custom_component folder as a backup has caused issued with HA loading the wrong custom component (ie the old one and not the new one).

To update node red companion, the (new/updated) nodered folder should be the only one in the custom_component folder. Backup copies should be kept elsewhere.

And, this useful flow can be used to check the version of the Node-RED companion integration actually running.

Full flow for importing…:

[{"id":"a25205a0a3854bb6","type":"inject","z":"c89d915bdff0f798","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":412,"y":80,"wires":[["ea8b441154d1945d"]]},{"id":"49f4ca33c05a294c","type":"debug","z":"c89d915bdff0f798","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":80,"wires":[]},{"id":"ea8b441154d1945d","type":"ha-api","z":"c89d915bdff0f798","name":"","server":"","version":1,"debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\": \"nodered/version\"}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":562,"y":80,"wires":[["49f4ca33c05a294c"]]}]
3 Likes

Thank you for an extremely extensive and well written reply. I have since solved the issue by reverting to a previous backup and re-installing node-red etc.
Nonetheless, there’s a ton of useful information for me in your reply, and I’m pretty sure I could fix the problem now if I run into it again.

Most welcome - I hope what I have written is correct and is of assistance to someone else in the future!

It can be very depressing and scary when accidentally breaking something that was working. Frustrating too, and although there is a lot of documentation around, sometimes I feel that a little more explanation and hand-holding would not go amiss for those of us who struggle when things break.

Past experience shows the value of

  • having regular backups, and doing so BEFORE doing any major change, and AFTER successful change/update.
  • not tidying things up (amazing how often that breaks things)
  • mantra is “if it isn’t broken, don’t fix it”
  • not doing system updates just before going to bed / going on holiday

I am sure this list can be expanded… and yes, I don’t aways follow my own rules and have cause to regret not taking that backup.

Your brilliant reply did indeed help somone in the future, me - thank you so much!