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.
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
:
- Goto in VSCode HomeAassistant Add-in, on Search menu, enter in Search field
sensor.MyOldSensor
then enter in the Replace fieldsensor.MyNewSensor
; - all found occurrences will appear in the result list;
- 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 aReplace All (Ctrl+Alt+Enter)
pay attention with âReplace Allâ to not mess up other sensors that might contains
sensor.MyNewSensor
as part of their name, for examplesensor.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 theMatch whole word (Alt+W)
andMatch Case (Alt+C)
options
- once yourâre done with replacements, you can go to node-RED, and choose âRestart Flowsâ :
- review the changes, and if everything seems to be fine, Merge them :
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.
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 I still find wrong things in my many flows from way-back-when
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
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:
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