What is the preferred way to rename z-wave entities?

One final warning/bit of information - I was running that on my macOS system, so I don’t know if the BSD-based version of egrep is 100% the same in options, etc. as the Linux/GPL’d version of egrep they use, if you happen to be running this on a Linux system.

ahh, thanks for pointing that out. Im planning on running all this from my Pi. I’ll check the man pages to confirm the options are the same. I’ll report back if I have to make any modifications.

…and just to note that I did a pattern there to select only sensor and switch entity domains because that’s what that device exposed, and I explicitly wanted to exclude the zwave.foo entity_id because I had already done something with it. Other devices with other entity_types (like binary_sensors, for example) would need some different pattern if you wanted to apply the same editing to the entity_id created for each of them.

Again, I had a bunch that I needed to do the exact same thing, so this sort of think worked. You might imagine an alternative approach where you have a CSV file with old and new entity_ids that you construct somehow, and then a shell script that iterates over each line. Or something. Nothing magic about my particular approach, only that it seemed a natural way to my to solve my particular problem I was just very pleased to discover that hass-cli would let me do this at all…

I did not realize the importance of this message when I first read it… Just read up on this great tool. Just got it working on my mac and already seeing the utility!

In the coming days I was going to move some 30 Zwave devices from SmartThings to HA. When I do so I want to set the entity_ids and friendly names to something relative at the beginning, so creating automation, scenes and scripts will go smoothly.
I included a couple devices, not only do they have long ids/names some have 4 child sensors under the single device ie:

(friendly name)
Inovelli NZW-30 Smart Switch W Scene 2 energy
Inovelli NZW-30 Smart Switch W Scene 2 power
Inovelli NZW-30 Smart Switch W Scene 2 reading
Inovelli NZW-30 Smart Switch W Scene 2
Inovelli NZW-30 Smart Switch W Scene 2 light

(ids)
sensor.inovelli_nzw30_smart_switch_w_scene_2_energy
sensor.inovelli_nzw30_smart_switch_w_scene_2_power
sensor.inovelli_nzw30_smart_switch_w_scene_2_reading
zwave.inovelli_nzw30_smart_switch_w_scene_2
light.inovelli_nzw30_smart_switch_w_scene_2

so I was thinking hass-cli method would come in handy.

but I have 1 problem and 1 question

I don’t know much about Linux, but I was able to install a Raspbian image under a VM on my windows machine than installed homeassistant-cli. I then entered the 2 environment variables to connect to HA.

I can run info and state list:

$ hass-cli info
BASE_URL                      LOCATION    REQUIRES_API_PASSWORD    VERSION
https://xxx.duckdns.org:8123  Home        True                     0.108.5

PROBLEM:
but if I run the below, I get the following error:

$ hass-cli --columns entity_id entity list
error: AttributeError: module 'homeassistant_cli.hassconst' has no attribute 'WS_TYPE_ENTITY_REGISTRY_LIST'

$ hass-cli entity rename sensor.zooz_zen15_power_switch    sensor.power_switch
error: AttributeError: module 'homeassistant_cli.hassconst' has no attribute 'WS_TYPE_ENTITY_REGISTRY_GET'
Run with -x to see full exception information

Then I’m unclear how to form a script to rename all the entity_ids and friendly names for the example to something like:

light.entry_hallway               Entry Hallway Light
sensor.entry_hallway_power        Entry Hallway Light Power

any help would be appreciated

it sounds like there’s some sort of problem with the hass-cli tool installation based on that error. I just tried hass-cli on my system (installed some months ago) and it works against 0.108.5 that I have running.

I don’t know how you might have installed hass-cli; I used pip on my system to do that.

Ha, ha, I just upgraded my homeassistant-cli package from 0.7.0 to 0.9.0 and I now have the same problem as you! I’ll have to see if I can revert it in the near term, and maybe open an issue on github.

Seems like this is not an isolated problem. There’s an open issue here: https://github.com/home-assistant/home-assistant-cli/issues/331

lol, well at least I can sleep a little better knowing I was working in the right direction, because i might need it, with the hours spent on trying to figure that error out

Looks like there was a fix committed see https://github.com/home-assistant/home-assistant-cli/commit/6cca5af6f17cdc72cda75ed82108d1ad9535e38f but it’s not yet shown up in the PyPy package repositories. So this is a good sign :slight_smile:

I’ve starting testing HA a few months ago and I love it. Now I want to migrate the essential part of my current domotics solution: my z-wave devices
Based on my tests my understanding is that (if you are using the current but outdated native HA z-wave integration) the naming has to be done as follows:
click the cog wheel in the device page:


Write the new name:
image
Accept the pop-up:
image
And now the device as well as all the entities have been renamed.

What should absolutely be avoided is to use the z-wave integration page, and click node information and use the cogwheel there to rename. That will result in just one of the entities being renamed (the one that shows whether the device is sleeping or awake). The functionality mentioned above to rename will no longer work at all!


This might be common knowledge to most but for me it was rather confusing, so decided to write it here.
Not sure what all the explanations with scripts in the posts above are about, after all the renaming seems to work fine if you do it the right way (at least I assume the way I did it is the right way :sweat_smile: )?

Offtopic: Is my understanding correct that if you have X devices and you remove nove 2 from the network and then add it back, it will be called node X+1 and the number “node 2” will never be used again?

3 Likes

It may depend on the particular Z-Wave controller that you are using, but this is certainly the behaviour I see with Aeotec Z-Wave Gen5 USB Z-Sticks…

1 Like

Thanks, I use the new Gen5+ so it makes sense that I noticed the same behaviour.

I know this is an old thread + I’m a newbie. But I don’t see any gear icon on my screen per the references in this thread. I’m running the latest update of HA and maybe I need to go read some release information, but I don’t know where to go to find that. Thoughts? Thanks for you assistance.
This is regarding renaming a Z-Wave device.

There’s a pencil icon next to the device name, click that.

1 Like

OMG. I am banging my forehead on my desk. How could I miss that! Thanks for your help!