diff --git a/source/_components/binary_sensor.template.markdown b/source/_components/binary_sensor.template.markdown index 15129c4ae28..39ea85e7d22 100644 --- a/source/_components/binary_sensor.template.markdown +++ b/source/_components/binary_sensor.template.markdown @@ -92,3 +92,17 @@ binary_sensor: - sensor.kitchen_co_status - sensor.wardrobe_co_status ``` +### {% linkable_title Change the icon %} + +This example shows how to change the icon based on the day/night cycle. + +```yaml +sensor: + - 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 %} + +```