mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-15 13:26:54 +00:00
add icon_template to command_line switch documentation (#20548)
This commit is contained in:
parent
133ebe6381
commit
13a289f346
@ -56,6 +56,10 @@ switches:
|
||||
description: The name used to display the switch in the frontend.
|
||||
required: false
|
||||
type: string
|
||||
icon:
|
||||
description: Defines a template for the icon of the entity.
|
||||
required: false
|
||||
type: template
|
||||
command_timeout:
|
||||
description: Defines number of seconds for command timeout.
|
||||
required: false
|
||||
@ -81,6 +85,34 @@ See aREST device below for an example.
|
||||
|
||||
In this section you find some real-life examples of how to use this switch.
|
||||
|
||||
### Change the icon when a state changes
|
||||
|
||||
This example demonstrates how to use template to change the icon as its state changes. This icon is referencing its own state.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
switch:
|
||||
- platform: command_line
|
||||
switches:
|
||||
|
||||
driveway_sensor_motion:
|
||||
friendly_name: Driveway buiten sensor
|
||||
command_on: >
|
||||
curl -X PUT -d '{"on":true}' "http://ip_address/api/sensors/27/config/"
|
||||
command_off: >
|
||||
curl -X PUT -d '{"on":false}' "http://ip_address/api/sensors/27/config/"
|
||||
command_state: curl http://ip_address/api/sensors/27/
|
||||
value_template: >
|
||||
{{value_json.config.on}}
|
||||
icon_template: >
|
||||
{% if value_json.config.on == true %} mdi:toggle-switch
|
||||
{% else %} mdi:toggle-switch-off
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
### aREST device
|
||||
|
||||
The example below is doing the same as the
|
||||
|
Loading…
x
Reference in New Issue
Block a user