Trying to tidy up my floor plan and need some help.
Would like to have it darker outside the house when the sun is down.
Is it possible to have two different Image at the bottom that change depending on the condition night / day?
When the outdoor lighting are on, it becomes dark outside the house and you can see the lights.
The problem becomes when the sun is down and the outdoor lighting is turned off then it becomes “day” in the picture.
Could put in a picture that is dark and without lights but for it to work I need to keep track of both if the sun is down and the lights are off. Is it possible in Picture Elements card?
Or can you control it in another way?
If I’ve understood what you are trying to do then I think I may have something similar in my setup. What I do is have a template sensor that has a number of states that essentially say which background to use. This could be based on any number of criteria. You can then use the Picture Elements card to choose which background to use.
Here’s the yaml for my template sensor:
# Peiods of day for UI Layout
- sensor:
- name: "Time of Day"
unique_id: time_of_day
state: >
{% set current_hour = strptime(states('sensor.time'), "%H:%M").hour %}
{% if states('sun.sun') == "below_horizon" %}
Night
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour < 12 %}
Dawn
{% elif current_hour < 11 %}
Morning
{% elif 11 <= current_hour < 13 %}
Midday
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour > 12 %}
Dusk
{% elif 13 <= current_hour %}
Afternoon
{% endif %}
icon: >
{% set current_hour = strptime(states('sensor.time'), "%H:%M").hour %}
{% if states('sun.sun') == "below_horizon" %}
mdi:moon-waning-crescent
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour < 12 %}
mdi:weather-sunset-up
{% elif current_hour < 11 %}
mdi:weather-sunny
{% elif 11 <= current_hour < 13 %}
mdi:weather-sunny
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour > 12 %}
mdi:weather-sunset
{% elif 13 <= current_hour %}
mdi:weather-sunny
{% endif %}
Here’s the yaml from the start of my Picture Elements item:
type: picture-elements
image: /local/layout/base_new.png?v=2
entity: sensor.time_of_day
state_image:
Dawn: /local/layout/base_dawn.png?v=5
Morning: /local/layout/base_morning_new.png?v=5
Midday: /local/layout/base_midday_new.png?v=5
Afternoon: /local/layout/base_afternoon_new.png?v=5
Dusk: /local/layout/base_dusk.png?v=5
Night: /local/layout/base_night_new.png?v=5
I hope this is what you are asking.
Just what I needed. Thank
Hi guys!
really nice work @templeton_nash !
i have an error in wensor.yaml for - platform: template
Property icon is not allowed.yaml-schema: http://schemas.home-assistant.io/integration-sensor
any idea please?, perhaps something has changed in HA updates since August…
/////////////////////////////EDIT : ok found it ////////////////////////////////////////
time_of_day:
value_template: >
{% set current_hour = strptime(states('sensor.time'), "%H:%M").hour %}
{% if states('sun.sun') == "below_horizon" %}
Night
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour < 12 %}
Dawn
{% elif current_hour < 11 %}
Morning
{% elif 11 <= current_hour < 13 %}
Midday
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour > 12 %}
Dusk
{% elif 13 <= current_hour %}
Afternoon
{% endif %}
icon_template: >
{% set current_hour = strptime(states('sensor.time'), "%H:%M").hour %}
{% if states('sun.sun') == "below_horizon" %}
mdi:moon-waning-crescent
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour < 12 %}
mdi:weather-sunset-up
{% elif current_hour < 11 %}
mdi:weather-sunny
{% elif 11 <= current_hour < 13 %}
mdi:weather-sunny
{% elif states('binary_sensor.balcony_illuminance_threshold') == "on" and current_hour > 12 %}
mdi:weather-sunset
{% elif 13 <= current_hour %}
mdi:weather-sunny
{% endif %}