Tool: Automatically Rename Z-Wave JS Devices in Domoticz

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

Post Reply
User avatar
Ragdag
Posts: 169
Joined: Friday 30 March 2018 13:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Tool: Automatically Rename Z-Wave JS Devices in Domoticz

Post by Ragdag »

After moving to Z-Wave JS UI as the Z-Wave backend for Domoticz, I quickly noticed that Domoticz ends up with a lot of devices with very inconsistent names.
Manually renaming them all was way too much work, and worse:
  • I ended up with devices having the same name, which completely broke my dzVents scripts (ask me how I know :lol:).
  • Device naming was chaos, making it harder to keep an overview.
  • Smoke detectors didn't have a Reset button, motion sensors had wrong icons, etc.

So I created a PowerShell script to bring order to the chaos and harmonize all device names automatically.
GitHub: Rename-Domoticz-From-ZwaveJSON

What does it do?
  • Reads your Z-Wave JS JSON export.
  • Creates a consistent name for each Domoticz device:

    Code: Select all

    [Room Name] - [Device Name] - [Property Label]
  • Applies renaming rules for common cases (Current Value, Watt/kWh, Temp, Lux, Motion, etc.).
  • Fixes device types: Smoke detectors get a Reset button, motion sensors show the right icon, alert sensors can't be accidentally toggled.
  • Preserves $ prefixes if you use those in Domoticz.
  • Ensures no duplicate names, which is a lifesaver for dzVents scripting.
  • Runs everything in a single transaction and makes a backup of your DB first.
  • Generates an interactive HTML report with search/filter to review all changes.

screenshot.png
screenshot.png (91.18 KiB) Viewed 11 times
Examples
After running the script, devices look like this:

Code: Select all

Kitchen - Dining Table Light
Kitchen - Dining Table Light [kWh]
Kitchen - Dining Table Light [W]
Porch - Sensor - LED: Blink on Motion
Shed - Ventilation Hood - Heat Alarm
Driveway - Sensor - Lux
Driveway - Sensor - Temp


How to use
1. Stop Domoticz so there is no lock on the database.
2. Copy your domoticz.db to a safe working location where you will run the script.
3. Export your full Z-Wave JSON in Z-Wave JS UI:
General Actions → Dump → EXPORT
4. First do a dry run to preview changes:

Code: Select all

powershell
.\Rename-Domoticz-From-ZwaveJSON.ps1 -JsonFile "nodes_dump.json" -DbPath "domoticz.db" -DryRun

5. Check the generated HTML report to see what will be renamed.
6. If everything looks good, run without -DryRun to apply changes:

Code: Select all

powershell
.\Rename-Domoticz-From-ZwaveJSON.ps1 -JsonFile "nodes_dump.json" -DbPath "domoticz.db"

7. Copy the modified DB back to your Domoticz folder and restart Domoticz.

Note: This modifies your Domoticz database directly.
The script will create a timestamped backup automatically and generates an undo SQL script if you need to revert, but I still recommend making your own backup before use.

Hope this helps some of you who, like me, got lost in the sea of Z-Wave device names! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest