ZWaveJS Migration Script

I got really sick of renaming ZWave entities when going back and forth from OpenZWave from ZWaveJS so I made a semi-automatic renaming script:

The script assumes you have OpenZWave and ZWaveJS integrations both set up. Then this is what the script does:

  1. It first renames all OpenZWave (OZW) entities with the suffix _ozwmigration
  2. Then it gathers all entities by node ID for both OZW and ZJS
  3. It will first look and see if you’ve manually specified any node names in the manual_rename_dict and rename those ZJS nodes according to your instructions.
  4. Then for each entity in ZJS if there is only one OZW entity on the node with the same type (e.g. light, switch), then it will automatically rename the ZJS entity to the OZW entity_id/name/icon

If you run it with the default arguments (python3 migrate_to_zwavejs.py) it will only print to the terminal what it plans on doing. To actually rename things you need to add the --commit flag. So you can just run it and see if the output looks sane before making any changes. It also spits out a manual_rename_dict with a bunch of garbage values that you can adapt to your liking.

In the future, it’d be awesome to extend this with fuzzy matching. E.g. it’d be awesome if this could automatically detect that my ZJS entity sensor.lamp_electric_consumed_kwh was previously sensor.zen07_mini_plug_electric_kwh and suggest that as a possible entry into the manual_rename_dict.

I’m sure I spent wayyy more time on this script than I would have spent just renaming things by hand but that’s no fun. I hope it comes in handy for someone else!

4 Likes