Skip to content

Commit edf76a0

Browse files
n8henriefabaff
authored andcommitted
Update switch.command_line friendly_name behavior (home-assistant#1437)
`switch.command_line` will now always use `object_id` for `entity_id`, even if `friendly_name` is given. home-assistant/core#3434 home-assistant/core#4343 How interesting -- issue 3434 and PR 4343.
1 parent 3587076 commit edf76a0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/_components/switch.command_line.markdown

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Configuration variables:
3838
- **value_template** (*Optional*): If specified, `command_state` will ignore the result code of the command but the template evaluating to `true` will indicate the switch is on.
3939
- **friendly_name** (*Optional*): The name used to display the switch in the frontend.
4040

41+
A note on `friendly_name`:
42+
43+
When set, the `friendly_name` had been previously used for API calls and backend configuration instead of the `object_id` ("identifier"), but [this behavior is changing](https://github.com/home-assistant/home-assistant/pull/4343) to make the `friendly_name` for display purposes only. This allows users to set an `identifier` that emphasizes uniqueness and predictability for API and config purposes but have a prettier `friendly_name` still show up in the UI. As an additional benefit, if a user wanted to change the `friendly_name` / display name (e.g. from "Kitchen Lightswitch" to "Kitchen Switch" or "Living Room Light", or remove the `friendly_name` altogether), he or she could do so without needing to change existing automations or API calls. See aREST device below for an example.
44+
4145
## {% linkable_title Examples %}
4246

4347
In this section you find some real life examples of how to use this switch.
@@ -51,14 +55,16 @@ The example below is doing the same as the [aREST switch](/components/switch.are
5155
switch:
5256
platform: command_line
5357
switches:
54-
arest_pin4:
58+
arest_pin_four:
5559
command_on: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/1"
5660
command_off: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/0"
5761
command_state: "/usr/bin/curl -X GET http://192.168.1.10/digital/4"
5862
value_template: '{% raw %}{{ return_value == "1" }}{% endraw %}'
59-
friendly_name: aREST Pin 4
63+
friendly_name: Kitchen Lightswitch
6064
```
6165

66+
Given this example, in the UI one would see the `friendly_name` of "Kitchen Light". However, the `identifier` is `arest_pin_four`, making the `entity_id` `switch.arest_pin_four`, which is what one would use in [`automation`](https://home-assistant.io/components/automation/) or in [API calls](https://home-assistant.io/developers/).
67+
6268
### {% linkable_title Shutdown your local host %}
6369

6470
This switch will shutdown your system that is hosting Home Assistant.

0 commit comments

Comments
 (0)