I wanted to diversify the wallpaper change. It’s not enough for me that the wallpaper change is done at sunset or sunrise. I wanted them to change by the days of the week and by sunrise and sunset. I could not cram two entities: the day of the week and the sunrise or sunset, I had to create a sensor of the day of the week and the sun, thanks to which I was able to realize my wish.
Creating a sensor A sensor of the day of the week and the sun
# Сенсор дня недели
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 %}
We insert this code into the header and, if desired, on any of the days, we prescribe the paths to the video files and expand them to the desired number
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
Текст на русском Text in Russian()
Мне захотелось разнообразить смену обоев. Мне не достаточно, что смена обоев делается по закату или восходу солнца. Захотелось, чтобы обои менялись по дням недели и по восходу и закату солнца. У меня не получилось запихнуть две сущности: день недели и восход или закат солнца, пришлось создать сенсор дня недели и солнца, благодаря которому я смог реализовать свою хотелку.
Создаем сенсор Сенсор дня недели и солнца
# Сенсор дня недели
sensor:
- platform: template
sensors:
dayoftheweek:
value_template: "{{ ['Понедельник','Вторник','Среда','Четверг','Пятница','Суббота','Воскресенье'][now().weekday()] }}"
entity_id: sensor.time
icon_template: mdi:calendar-month
# Сенсор дня недели и солнца
- platform: template
sensors:
day_week_and_sun:
friendly_name: "Сенсор дня недели и солнца"
value_template: >
{% set sunrise = is_state('sun.sun','above_horizon') %}
{% set sunset = is_state('sun.sun','below_horizon') %}
{% if sunrise %}
{{ states.sensor.dayoftheweek.state }}. Восход солнца
{% elif sunset %}
{{ states.sensor.dayoftheweek.state }}. Закат солнца
{% endif %}
icon_template: >-
{% if is_state('sun.sun','above_horizon') %}
mdi:sunrise
{% elif is_state('sun.sun','below_horizon') %}
mdi:sunset
{% endif %}
В заголовок вставляем этот код и по желанию, в любой из дней, прописываем пути к видеофайлам и расширяем до желаемого количества
animated_background:
default_url: /local/animated-background/day/01.mp4
included_users:
- users
entity: sensor.day_week_and_sun
state_url:
Понедельник. Восход солнца:
- /local/animated-background/day/Switzerland_01.mp4
- /local/animated-background/day/Switzerland_02.mp4
Понедельник. Закат солнца:
- /local/animated-background/night/Moon and lake.mp4
- /local/animated-background/night/Mountain and lake.mp4
Вторник. Восход солнца:
- /local/animated-background/day/Switzerland_03.mp4
- /local/animated-background/day/Switzerland_04.mp4
Вторник. Закат солнца:
- /local/animated-background/night/03.mp4
- /local/animated-background/night/04.mp4
Среда. Восход солнца:
- /local/animated-background/day/Iceland_01.mp4
- /local/animated-background/day/Iceland_02.mp4
Среда. Закат солнца:
- /local/animated-background/night/Space_01.mp4
- /local/animated-background/night/Space_02.mp4
Четверг. Восход солнца:
- /local/animated-background/day/Iceland_03.mp4
- /local/animated-background/day/Iceland_04.mp4
Четверг. Закат солнца:
- /local/animated-background/night/Space_03.mp4
- /local/animated-background/night/Space_04.mp4
Пятница. Восход солнца:
- /local/animated-background/day/Iceland_05.mp4
- /local/animated-background/day/Iceland_06.mp4
Пятница. Закат солнца:
- /local/animated-background/night/Space_05.mp4
- /local/animated-background/night/Space_06.mp4
Суббота. Восход солнца:
- /local/animated-background/day/Switzerland_05.mp4
- /local/animated-background/day/Switzerland_06.mp4
Суббота. Закат солнца:
- /local/animated-background/night/Space_07.mp4
- /local/animated-background/night/Space_08.mp4
Воскресенье. Восход солнца:
- /local/animated-background/day/Switzerland_07.mp4
- /local/animated-background/day/Switzerland_08.mp4
Воскресенье. Закат солнца:
- /local/animated-background/night/Space_03.mp4
- /local/animated-background/night/Space_02.mp4