I’ve tried a thousand options and searched the internet but unfortunately can’t find the answer.
I use the frontend theme from Matt8707. To get this work I added the specific part to my configuration.yaml.
Because I want to have my total energy usage for the day I need to sum two sensors. The function works fine but i have a conflict with using “template:” twice in my configuration.yaml. Error: duplicate key
Can anybody help me how to solve this? Thank you in advance!
It fails to work because the contents of your sidebar.yaml file don’t comply with what Home Assistant normally uses the template: key for and that’s to configure Template entities.
I think I’ve found it! There were two sidebar.yaml files. Of course I had the wrong one :-). I suppose this format was what you mentioned? Thanks for pointing me in the right direction. Very appreciated.
- sensor:
- unique_id: sidebar
state: template
attributes:
time: >
{% set hours = now().strftime('%H') %}
{% set minutes = now().strftime('%M') %}
<span class="time">
{{ hours }}<span class="time-colon">:</span>{{ minutes }}
</span>
date: >
<font color='#6a7377'><b>
{% if strptime(states('sensor.date'), '%Y-%m-%d').day != None %}
{% set days = ['Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag'] %}
{% set months = ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'] %}
{{ days[now().weekday()] }}<br>
{{ strptime(states('sensor.date'), '%Y-%m-%d').day }} {{ months[now().month-1] }}
{% endif %}
</b></font>
greet: >
<b>
{% set time = now().hour %}
{% if time <= 1 %} Goedenacht {{'\U0001F611'}}
{% elif time <= 3 %} Goedenacht {{'\U0001F62A'}}
{% elif time <= 5 %} Goedenacht {{'\U0001F634'}}
{% elif time <= 7 %} Goedemorgen {{'\U0001F4A9'}}
{% elif time <= 9 %} Goedemorgen {{'\u2615\uFE0F'}}
{% elif time <= 10 %} Goedemorgen {{'\U0001F642'}}
{% elif time <= 13 %} Goedendag {{'\U0001F60A'}}
{% elif time <= 15 %} Goedendag {{'\U0001F60E'}}
{% elif time <= 17 %} Goedendag {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 19 %} Goedenavond {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 22 %} Goedenavond {{'\U0001F60C'}}
{% elif time <= 23 %} Goedenavond {{'\U0001F974'}}
{% else %} Goedenavond {{'\U0001F974'}}
{% endif %}
</b>
#Energy templates:
- sensor:
- name: 'Daily Energy Total'
device_class: energy
unit_of_measurement: kWh
state: >
{% if is_number(states('sensor.elektra_vandaag_dal')) and is_number(states('sensor.elektra_vandaag_hoog')) %}
{{ states('sensor.elektra_vandaag_dal') | float + states('sensor.elektra_vandaag_hoog') | float }}
{% else %}
None
{% endif %}