Open DivanX10 opened 2 years ago
I figured out how to implement what I wanted. I have created a sensor that shows the day of the week and the sunset or sunrise.
# Сенсор дня недели
sensor:
- platform: template
sensors:
dayoftheweek:
value_template: "{{ ['Monday','Tuesday','Wednesday', 'Thursday','Friday', 'Saturday', 'Sunday'][now().weekday()] }}"
entity_id: sensor.time
icon_template: mdi:calendar-month
# Day of the week and sun sensor
- platform: template
sensors:
day_week_and_sun:
friendly_name: "Day of the week and sun sensor"
value_template: >
{% set sunrise = is_state('sun.sun','above_horizon') %}
{% set sunset = is_state('sun.sun','below_horizon') %}
{% if sunrise %}
{{ states.sensor.dayoftheweek.state }}. Sunrise
{% elif sunset %}
{{ states.sensor.dayoftheweek.state }}. Sunset
{% endif %}
icon_template: >-
{% if is_state('sun.sun','above_horizon') %}
mdi:sunrise
{% elif is_state('sun.sun','below_horizon') %}
mdi:sunset
{% endif %}
And I made a wallpaper change not only by the days of the week, but also by sunset and sunrise
animated_background:
default_url: /local/animated-background/day/01.mp4
included_users:
- users
entity: sensor.day_week_and_sun
state_url:
Monday. Sunrise:
- /local/animated-background/day/Switzerland_01.mp4
- /local/animated-background/day/Switzerland_02.mp4
Monday. Sunset:
- /local/animated-background/night/Moon and lake.mp4
- /local/animated-background/night/Mountain and lake.mp4
Tuesday. Sunrise:
- /local/animated-background/day/Switzerland_03.mp4
- /local/animated-background/day/Switzerland_04.mp4
Tuesday. Sunset:
- /local/animated-background/night/03.mp4
- /local/animated-background/night/04.mp4
Wednesday. Sunrise:
- /local/animated-background/day/Iceland_01.mp4
- /local/animated-background/day/Iceland_02.mp4
Wednesday. Sunset:
- /local/animated-background/night/Space_01.mp4
- /local/animated-background/night/Space_02.mp4
Thursday. Sunrise:
- /local/animated-background/day/Iceland_03.mp4
- /local/animated-background/day/Iceland_04.mp4
Thursday. Sunset:
- /local/animated-background/night/Space_03.mp4
- /local/animated-background/night/Space_04.mp4
Friday. Sunrise:
- /local/animated-background/day/Iceland_05.mp4
- /local/animated-background/day/Iceland_06.mp4
Friday. Sunset:
- /local/animated-background/night/Space_05.mp4
- /local/animated-background/night/Space_06.mp4
Saturday. Sunrise:
- /local/animated-background/day/Switzerland_05.mp4
- /local/animated-background/day/Switzerland_06.mp4
Saturday. Sunset:
- /local/animated-background/night/Space_07.mp4
- /local/animated-background/night/Space_08.mp4
Sunday. Sunrise:
- /local/animated-background/day/Switzerland_07.mp4
- /local/animated-background/day/Switzerland_08.mp4
Sunday. Sunset:
- /local/animated-background/night/Space_03.mp4
- /local/animated-background/night/Space_02.mp4
I can configure switching video wallpapers by days of the week or sunrise or sunset. Tell me how to make it so that you can switch not only by days of the week but also by sunrise or sunset? The first example works on days of the week, and the second example does not work on days of the week + sunrise or sunset.
This option works on days of the week
This option does not work on days of the week + sunrise or sunset