Skip to content

Instantly share code, notes, and snippets.

@hannesbe
Created August 7, 2019 04:34
Show Gist options
  • Save hannesbe/6069b370c1f40b458e829deafd56a12a to your computer and use it in GitHub Desktop.
Save hannesbe/6069b370c1f40b458e829deafd56a12a to your computer and use it in GitHub Desktop.
Jinja2 template, generating hass-cli commands, to make renaming Z-Wave entities for example a lot easier
{%- set find = "shenzhen_neo_electronics_co_ltd_water_leakage_detector" -%}
{%- set replace = "boiler_water_leak_sensor" -%}
{%- for item in states -%}
{% if find in item.object_id %}
hass-cli entity rename --name "{{ item.object_id.replace(find, replace).replace("_", " ")|title }}" {{ item.entity_id }} {{ item.entity_id.replace(find, replace) }}
{%- endif -%}
{%- endfor -%}
#!/bin/bash
eval "$(hass-cli template ./entity_rename_find_replace.j2)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment