Hello!
I am trying to display an image that is time of day dependant. So far I have been unsuccessful, and I am hoping someone knows of a way accomplish it.
Here is the yaml for my sensor I created, that includes a template to decipher which photo to display depending on time of day:
dynamic_image:
friendly_name: "Dynamic Image"
value_template: >
{% set now_time = now().time() if now() is not none else as_datetime('00:00').time() %}
{% set today = now().weekday() if now() is not none else 0 %}
{% set morning_times = {
0: ('01:40', '05:45'),
1: ('01:40', '05:45'),
2: ('01:40', '05:45'),
3: ('01:40', '05:45'),
4: ('01:40', '05:45'),
5: ('01:40', '05:15'),
6: ('01:45', '07:20')
} %}
{% set start_time, end_time = morning_times[today] %}
{% if now_time >= as_datetime('1970-01-01 ' ~ start_time).time() and now_time <= as_datetime('1970-01-01 ' ~ end_time).time() %}
/local/images/image1.png
{% else %}
/local/images/image2.png
{% endif %}
and here is the picture-elements card yaml I have tried using, with numerous variants of the sensor:
- type: picture-elements
image: ${states['sensor.dynamic_image'].state}
style:
background-color: transparent
elements:
- type: state-label
entity: sensor.dynamic_image_sensor
style:
top: 51%
left: 50%
color: white
font-size: 15px
card_mod:
style: |
ha-card {
--ha-card-background: rgba(0,0,0,0) !important;
}
1 post - 1 participant