Yeah, this approach works. Here’s what I used to rename all the sensor and switch entities:
for e in $(hass-cli --columns entity_id entity list | egrep '^(sensor|switch).*greenwave' ); do \
new=$(echo $e | sed -e 's/_reality_inc_powernode_6_port/_powernode1/'); \
hass-cli entity rename "$e" "$new"; \
done
And you can rename the friendly_name field by doing something like this:
hass-cli state edit --merge --attributes "friendly_name=GreenWave PowerNode1 Energy 1" sensor.greenwave_powernode1_energy_1
Do not forget the -merge option, or you will blow-away all of the other attributes, which is probably not what you want to do!
Just a big shout-out and thanks to those that brought us hass-cli. If you’ve not heard of this tool, see https://www.home-assistant.io/blog/2019/02/04/introducing-home-assistant-cli/ and https://github.com/home-assistant/home-assistant-cli for more info. Also Introducing Home Assistant CLI aka. hass-cli .
If you want to attempt a similar thing, just some additional info on my environment. I don’t use hass.io; I just run the standard Home Assistant docker container off of docker hub. Even so, for this particular effort, I am using hass-cli installed on my MacBook Pro, remote from the Ubuntu Linux system that runs all my docker containers. So even Hass.IO users could do a similar thing if they have a UNIX shell somewhere to run hass-cli. I would imagine this would work regardless of how you happen to have Home Assistant running, as it just uses an API to do its work.