Home Assistant Template

The following provides a simple welcome card using the Mushroom Template Card.

The two icons show the current users location and as there are only two people in the house the location of the other person in the badge Icon.

The following is defined as a template sensor in our sensors.yaml to nicely format a date for display and to give the time of day, eg Morning Afternoon etc.

- platform: template
  sensors:
    date_full_format:
      value_template : >-
          {%- macro suffix(d) -%}
          {%- set sfx = {1:'st',2:'nd',3:'rd'} -%}
          {{- 'th' if 11 <= d <= 13 else sfx.get(d%10, 'th') -}}
          {%- endmacro -%}
          {%- set dt = as_timestamp(now()) | timestamp_custom('%d',0) |int-%}
          {{ now().strftime('%A %-d')}}{{ suffix(dt) }}{{now().strftime(' %B %Y')}}     
    time_of_day:
      value_template: >-
          {%- set h = as_timestamp(now()) | timestamp_custom('%H',0) |int-%}
          {%- set m = 'Morning' -%}
          {%- set m = 'Afternoon' if h >= 12 else m -%}
          {%- set m = 'Evening' if h >= 18 else m -%}
          {%- set m = 'Night' if h >= 22 else m -%}
          {{m}}   

The yaml for the welcome card is as follows:

type: custom:mushroom-template-card
primary: Good {{states('sensor.time_of_day')}}, {{user}}
secondary: >-
  Today is {{states('sensor.date_full_format')}}.

  The time is {{states('sensor.time')}}. 

  Sunrise today {{states('sensor.formatted_sunrise')}}. Sunset today
  {{states('sensor.formatted_sunset')}}.
icon: |-
  {% set sensor = 'sensor.' + user + '_location' %}
  {{state_attr(sensor,'icon')}}
multiline_secondary: true
badge_icon: >-
  {%- set id = 'stephen' if user == 'Jane' else 'jane' -%}
  {% set sensor = 'sensor.' + id + '_location' %}
  {{state_attr(sensor,'icon')}}
badge_color: black

Note the fact the sensor name is built as a string to allow different sensors to be selected using the user name.