Is there a way to find incorrectly named entities in node-red?

If some of the integrations are reinstalled, or you manually go and rename a device, the name will no longer match what is in an existing node-red flow.
Is there a way to find misnamed entities in node-red?

I just copy the flow I know the entities have changed in and use ‘find and replace all’ function in Notepad++. Then I delete the old flow and import the new code and save it. Not sure if there are smarter ways, but this works better than manually searching and changing nodes.

1 Like

By my side, last time a device was renamed, I did it manually in node-RED, I used “Search Flows” in node-RED, and went through all nodes reported in the list. (It disappears from the result immediately after doing the change when the button “Done” of the node is pressed).

I also tried to find/replace from VSCode in the related json file (/config/node-red/flows.json and /config/node-red/.flows.json.backup) but not succeed to apply the modification at the node-RED level after modifying directly these files. Maybe there is a way to doit…

Well, I made several test and finally were able to modify the node-RED flows.json files with VSCode HomeAssistant Add-in.

Assume that I have sensor.MyOldSensor that I want to update in node-RED due to a rename to sensor.MyNewSensor :

  1. Goto in VSCode HomeAassistant Add-in, on Search menu, enter in Search field sensor.MyOldSensor then enter in the Replace field sensor.MyNewSensor;
  2. all found occurrences will appear in the result list;
  3. you can now check and replace each found instance individually by going to the item list and click the Replace (Ctrl+Shift+1), or make a Replace All (Ctrl+Alt+Enter)
    image

:warning: pay attention with “Replace All” to not mess up other sensors that might contains sensor.MyNewSensor as part of their name, for example sensor.MyOldSensor_very_important which might not have been renamed in the homeassistant. This is why personally, most of the time, I preferer to go on each item and choose to rename after having reviewed the change in the preview window. To reduce risk of a wrong research you can as well activate the Match whole word (Alt+W) and Match Case (Alt+C) options

  1. once your’re done with replacements, you can go to node-RED, and choose “Restart Flows” : image
  2. review the changes, and if everything seems to be fine, Merge them :image

You’re done, sensor names are modified in node-RED by their new names.

This doesn’t allow to identified mismatched entities name, but just find and rename it more easily that’s implies that you should know/or able to find back the sensor old name.

1 Like

Hey @vinzcenzo
That’s pretty neat, I didn’t think about the .json file being available from ‘the outside’ but yeah, that’s pretty cool!
It doesn’t help me with finding something that I didn’t know about, but at least it’s a very quick way of fixing flows when you know the changes.
It would be so cool to have a validator of some sorts, so that it would check the referenced entities in node-red against the ones that are in HA, and I guess it’s doable, I’m just not a coder :slight_smile: I still find wrong things in my many flows from way-back-when :wink:

1 Like

It doesn’t help me with finding something that I didn’t know about, but at least it’s a very quick way of fixing flows when you know the changes.

Totally agree with that… I messed up everything following a Zigbee2MQTT issue when I had to exclude and reinclude all my devices (>30). take me time to recover everything working correctly…

Should be technically possible to create a regular polling for potential “dead” nodes, but maybe not already implemented… maybe try to create a “feature request”… who knows :wink:

Hi,
I was recently also searching for a solution regarding the problem you described @fribse .
I found this in the node red help: Handling errors.

So basically you have to add a “catch” node and connect it to a “call service” node with “notify”.
But then the error messages will not appear in the debug window, so I have simply connected an additional “Debug” node and then I can see also the error messages in the debug window.
Like so:
grafik

This “catch” node is catching the error messages only for the flow where its located, so you have to add it into each flow to be notified of all node red errors in home assistant.

I know its not the exact answer for your problem (so you will not get all invalid entities) but maybe it will help you :slight_smile:

2 Likes