Hey, yes on the latest version.
Which part errors for you? As mentioned above, happy to share my code.
This is an extract from my includes/templates.yaml
- 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 != null %}
{% set days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] %}
{% set months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', '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 %} Good night {{'\U0001F611'}}
{% elif time <= 3 %} Good night {{'\U0001F62A'}}
{% elif time <= 5 %} Good night {{'\U0001F634'}}
{% elif time <= 7 %} Good morning {{'\U0001F4A9'}}
{% elif time <= 9 %} Good morning {{'\u2615\uFE0F'}}
{% elif time <= 10 %} Good morning {{'\U0001F642'}}
{% elif time <= 13 %} Good afternoon {{'\U0001F60A'}}
{% elif time <= 15 %} Good afternoon {{'\U0001F60E'}}
{% elif time <= 17 %} Good afternoon {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 19 %} Good evening {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 22 %} Good evening {{'\U0001F60C'}}
{% elif time <= 23 %} Good evening {{'\U0001F974'}}
{% else %} Good evening {{'\U0001F974'}}
{% endif %}
</b>
active: >
<b>
{% set lights = [
states.light.living_room_light,
states.light.bedroom_light,
states.light.REDACTED_light,
states.light.girls_light,
states.light.pickaxe,
states.light.office_leds,
states.light.REDACTED_leds,
states.light.status_light,
states.switch.alfie_lamp,
states.switch.floor_lamp,
states.switch.kitchen_light,
states.switch.basking_lamp
] %}
{% set switches = [
states.switch.basking_lamp
] %}
{% set media_players = [
states.media_player.bedroom_tv,
states.media_player.virgin_tv
] %}
{% set lights_on = lights | selectattr('state','eq','on') | list %}
{% set lights_name = lights | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}
{% set switches_on = switches | selectattr('state','eq','on') | list %}
{% set media_players_playing = media_players | selectattr('state','eq','playing') | list %}
{% set append = switches_on + media_players_playing %}
{% set switches_name = append | map(attribute='name') | join(', ') %}
{% if (lights_on | length == 0) and (switches_on | length > 0) %}
{{ switches_name | regex_replace(',([^,]*)$',' and\\1') }} are on
{% elif (lights_on | length == 1) and (switches_on | length == 1) %}
{{ lights_name }}, {{switches_name }} are on
{% elif (lights_on | length == 1) and (switches_on | length > 1) %}
{{ lights_name }}, {{ switches_name | regex_replace(',([^,]*)$',' and\\1') }} are on
{% elif (lights_on | length > 1) and (switches_on | length == 1) %}
{{ lights_on | length }} lights and {{ switches_name }} are on
{% elif (lights_on | length > 1) and (switches_on | length > 1) %}
{{ lights_on | length }} lights, {{ switches_name | regex_replace(',([^,]*)$',' and\\1') }} are on
{% elif (lights_on | length == 1) and (switches_on | length == 0) %}
{{ lights_name }} are on
{% elif (lights_on | length > 1) and (switches_on | length == 0) %}
{{ lights_on | length }} lights are on
{% else %}
<font color='#6a7377'>Everything is off</font>
{% endif %}
</b>
weather: >
{% set temperature = states('sensor.openweathermap_temperature') %}
{% set apparent = states('sensor.openweathermap_feels_like_temperature') | round %}
{% set precip = states('sensor.openweathermap_forecast_precipitation_probability') | round %}
{% if not is_state('sensor.openweathermap_temperature', 'unknown') %}
{% if temperature | float(default=0) <= 0.0 %}
Feels like {{ apparent }}° with {{ precip }}% risk of snow {{'\u2744\uFE0F'}}
{% elif temperature | float(default=0) > 0.0 %}
Feels like {{ apparent}}° with {{ precip }}% risk of rain {{ '\u2614\uFE0F' if precip > 30 }}
{% endif %}
{% else %}
Unable to load weather information ...
{% endif %}
transport: >
Commute to work is {{ states('sensor.commute_to_work') }} mins
battery: >
{% set entities = states.sensor
| selectattr('entity_id', 'search', 'level')
| rejectattr('entity_id', 'search', 'REDACTED')
| map(attribute = 'entity_id') | list %}
{% for sensor in entities if states(sensor) != 'unknown' and states(sensor) !=
'unavailable' and states(sensor) != 'None' and states(sensor) | int(default=0) <= 20 %}
{% if loop.first %} {{'\u26A0\uFE0F'}} {% else %}| {% endif %}
{{ state_attr(sensor, 'friendly_name') }} {{ states(sensor) }}%
{% endfor %}
internet: >
{% if is_state('binary_sensor.archer_ax11000_wan_status', 'off') %}
{{'\u26A0\uFE0F'}} Check Internet Access
{% endif %}
- unique_id: hass_version
state: >
{{ 'Latest' if states('sensor.template_hass_version') ==
states('sensor.template_hass_version') else states('sensor.template_hass_version') }}
attributes:
friendly_name: >
Installed {{ states('sensor.template_hass_version') }}
icon: mdi:home-assistant
- unique_id: hass_dev_release
state: >
{% set start_time = state_attr('calendar.home_assistant_devs', 'start_time') %}
{{ (as_timestamp(start_time, default=0) + 60*60*20.5) | timestamp_local(default) }}
attributes:
friendly_name: >
{% set release = state_attr('calendar.home_assistant_devs','message') %}
{% if release == 'Home Assistant Core Beta Release' %}
Next beta
{% elif release == 'Home Assistant Core Release' %}
Next release
{% else %}
{{ release }}
{% endif %}
icon: mdi:dev-to
device_class: timestamp