Skip to content

Update icon_template docs for switch template #2735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions source/_components/switch.template.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ switch:
This example shows how to change the icon based on the day/night cycle.

```yaml
sensor:
switch:
- platform: template
sensors:
day_night:
friendly_name: 'Day/Night'
value_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}Day{% else %}Night{% endif %}'{% endraw %}
icon_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}mdi:weather-sunny{% else %}mdi:weather-night{% endif %}'{% endraw %}

switches:
garage:
value_template: {% raw %}"{{ is_state(cover.garage_door', 'on') }}"{% endraw %}
turn_on:
service: cover.open_cover
entity_id: cover.garage_door
turn_off:
service: cover.close_cover
entity_id: cover.garage_door
icon_template: {% raw %}"{% if is_state('cover.garage_door', 'open') %}mdi:garage-open{% else %}mdi:garage{% endif %}"{% endraw %}
```