{"id":13486,"date":"2022-07-21T08:36:37","date_gmt":"2022-07-21T08:36:37","guid":{"rendered":"https:\/\/www.rjt.org.uk\/home\/?post_type=home_assistant_tip&#038;p=13486"},"modified":"2022-07-21T09:13:27","modified_gmt":"2022-07-21T09:13:27","slug":"welcome-card-for-home-page","status":"publish","type":"home_assistant_tip","link":"https:\/\/www.rjt.org.uk\/home\/archives\/home-assistant-tip\/welcome-card-for-home-page\/","title":{"rendered":"Welcome Card for Home Page"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.rjt.org.uk\/home\/wp-content\/uploads\/2022\/07\/2022-07-21_101245.png\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"137\" src=\"https:\/\/www.rjt.org.uk\/home\/wp-content\/uploads\/2022\/07\/2022-07-21_101245.png\" alt=\"\" class=\"wp-image-13488\" srcset=\"https:\/\/www.rjt.org.uk\/home\/wp-content\/uploads\/2022\/07\/2022-07-21_101245.png 469w, https:\/\/www.rjt.org.uk\/home\/wp-content\/uploads\/2022\/07\/2022-07-21_101245-300x88.png 300w, https:\/\/www.rjt.org.uk\/home\/wp-content\/uploads\/2022\/07\/2022-07-21_101245-150x44.png 150w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>The following provides a simple welcome card using the Mushroom Template Card.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">- platform: template\n  sensors:\n    date_full_format:\n      value_template : >-\n          {%- macro suffix(d) -%}\n          {%- set sfx = {1:'st',2:'nd',3:'rd'} -%}\n          {{- 'th' if 11 &lt;= d &lt;= 13 else sfx.get(d%10, 'th') -}}\n          {%- endmacro -%}\n          {%- set dt = as_timestamp(now()) | timestamp_custom('%d',0) |int-%}\n          {{ now().strftime('%A %-d')}}{{ suffix(dt) }}{{now().strftime(' %B %Y')}}     \n    time_of_day:\n      value_template: >-\n          {%- set h = as_timestamp(now()) | timestamp_custom('%H',0) |int-%}\n          {%- set m = 'Morning' -%}\n          {%- set m = 'Afternoon' if h >= 12 else m -%}\n          {%- set m = 'Evening' if h >= 18 else m -%}\n          {%- set m = 'Night' if h >= 22 else m -%}\n          {{m}}   <\/pre>\n\n\n\n<p>The yaml for the welcome card is as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">type: custom:mushroom-template-card\nprimary: Good {{states('sensor.time_of_day')}}, {{user}}\nsecondary: >-\n  Today is {{states('sensor.date_full_format')}}.\n\n  The time is {{states('sensor.time')}}. \n\n  Sunrise today {{states('sensor.formatted_sunrise')}}. Sunset today\n  {{states('sensor.formatted_sunset')}}.\nicon: |-\n  {% set sensor = 'sensor.' + user + '_location' %}\n  {{state_attr(sensor,'icon')}}\nmultiline_secondary: true\nbadge_icon: >-\n  {%- set id = 'stephen' if user == 'Jane' else 'jane' -%}\n  {% set sensor = 'sensor.' + id + '_location' %}\n  {{state_attr(sensor,'icon')}}\nbadge_color: black<\/pre>\n\n\n\n<p>Note the fact the sensor name is built as a string to allow different sensors to be selected using the user name.<\/p>\n","protected":false},"template":"","class_list":["post-13486","home_assistant_tip","type-home_assistant_tip","status-publish","hentry","comments-off"],"_links":{"self":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/home_assistant_tip\/13486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/home_assistant_tip"}],"about":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/types\/home_assistant_tip"}],"wp:attachment":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/media?parent=13486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}