Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template:
- - sensor:
- - unique_id: period_of_day
- name: Period of the day
- state: >
- {% if (as_timestamp(state_attr('sun.sun','next_dusk'))) -
- (as_timestamp(state_attr('sun.sun','next_setting'))) < 0 %}
- Dusk
- {% elif (as_timestamp(state_attr('sun.sun','next_rising'))) -
- (as_timestamp(state_attr('sun.sun','next_dawn'))) < 0 %}
- Dawn
- {% elif now().hour == 0 %}
- Midnight
- {% elif (state_attr('sun.sun', 'elevation')) < 0 %}
- Night
- {% else %}
- Day
- {% endif %}
- icon: >
- {% set period = states('sensor.period_of_day') %}
- {% if period == 'Dusk' %} mdi:weather-sunset-down
- {% elif period == 'Dawn' %} mdi:weather-sunset-up
- {% elif period == 'Night' %} mdi:weather-night
- {% elif period == 'Midnight' %} mdi:clock-time-twelve
- {% else %} mdi:weather-sunny
- {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement