Feature request: run external script on 'hass-cli entity rename' with from and to parameters
I'm creating a simple way to refactor entity names in HA.
Upon rename of entity in HA the referenced entities in /config/*.yaml needs refactor too
I'm thinking of a solution where hass-cli aids in this.
The Awesomest Way
hass-cli --refactor zwave.8f1f9f9b-switch-power-relay-nerdfont-compatible-device zwave.maindoor "Main Door Sensor"
My reasoning: because usually both entity_id and friendly name is changed at the same time, but not always (sometimes keep nil, set to nil, or do not change) and due to zsh/bash + complexities of escaping meta characters: Having end users enter friendly names directly as a parameter to hass-cli, when additional parameters might be passed, is a recipe for unwanted snafu, I think. I don't know a good way to solve this, perhaps apart from hass-cli either implenting some sort of readline to grab and sanity check the user input .. or implementing a "yes/no" prompt after displaying what hass-cli interpreted as the input for from_id and to_id / to_friendlyname.
external script called, passed a simple json of from_id and to_id
script handles the refactor/rename of config files via sed/awk, scripting vscode ++
I don't know if hass-cli already supports exit codes somehow, but with so many different outcomes to a rename, I thought it might be best for the logic and/or string sanitizing be done within a 'proper programming language' and for the results of that sanitizing to be passed to an external tool. Or, hass-cli does the blanket find and replace of all matches in /config itself. Are there any other places than the .yaml files have references that would need updating?
What do you guys think?
On a side note: I've daemonized hass-cli event watch state_changed via launchctl and also a helper tool parsing that output. Now I'm notified via bitbar on the macOS menu bar of changes on entity attributes registered in the simple tool. A native --daemonize would be awesome!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Feature request: run external script on 'hass-cli entity rename' with from and to parameters
/config/*.yaml
needs refactor tooI'm thinking of a solution where
hass-cli
aids in this.The Awesomest Way
My reasoning: because usually both
entity_id
andfriendly name
is changed at the same time, but not always (sometimes keep nil, set to nil, or do not change) and due tozsh/bash
+ complexities of escaping meta characters: Having end users enter friendly names directly as a parameter to hass-cli, when additional parameters might be passed, is a recipe for unwanted snafu, I think. I don't know a good way to solve this, perhaps apart fromhass-cli
either implenting some sort ofreadline
to grab and sanity check the user input .. or implementing a "yes/no" prompt after displaying whathass-cli
interpreted as the input forfrom_id
andto_id
/to_friendlyname
.Also awesome
`hass-cli entity rename zwave.8f1f9f9b-nerdfont-compatible zwave.maindoor "Door Sensor" --exec_on_success /path/to/hass-cli-refactor.sh'
If that rename succeeds:
hass-cli
renamed both the id and friendly namefrom_id
andto_id
I don't know if
hass-cli
already supports exit codes somehow, but with so many different outcomes to a rename, I thought it might be best for the logic and/or string sanitizing be done within a 'proper programming language' and for the results of that sanitizing to be passed to an external tool. Or,hass-cli
does the blanket find and replace of all matches in/config
itself. Are there any other places than the.yaml
files have references that would need updating?What do you guys think?
On a side note: I've daemonized
hass-cli event watch state_changed
vialaunchctl
and also a helper tool parsing that output. Now I'm notified viabitbar
on the macOS menu bar of changes on entity attributes registered in the simple tool. A native--daemonize
would be awesome!