Install php-cli (for example on ubuntu just run apt-get install php-cli)
Run the script with
regenerate.php /home/your-user/.homeassistant/entity_registry.yaml “http://your-home-assistant:8123/api/states” delete > output.yaml
now you can inspect the output.yaml and see if everyhing is ok, then replace the original file with this one ( please stop home assistant then replace the file then start it again to make sure everything is ok)
If you do not put “delete” at the end, the unneeded entities will be commented in the output file, instead of being removed.
PHP Warning: file_get_contents(“https://MY-URL.duckdns.org/api/states?api_password=MY-PASSWORD”): failed to open stream: No such file or directory in /home/homeassistant/.homeassistant/extras/bash_scripts/regenerate.php on line 8
PHP Warning: Invalid argument supplied for foreach() in /home/homeassistant/.homeassistant/extras/bash_scripts/regenerate.php on line 11
output.yaml is blank.
I can confirm that if I use the URL in a browser I get the JSON that the script is expecting.