Hey thanks for sharing this. I have been looking for something like this…forever. I have yet to understand why, as advanced as HA is, why there is NOT a simple damn clock card… Seems easy enough (not for me…I’m not a coder) maybe I am missing something. Anyway, one question, is there a way to display the time in 12 hr. format and maybe the date displayed as “Friday January 22, 2021” for example.
I have seen options with templates for this but cant seem to make them work and they dont look as good as this.
Thank you! I’m not a programmer either, but I will try
So for displaying the name of the day I have now added new sensor to configuration yaml:
- platform: template
sensors:
weekday:
value_template: '{% if now().weekday() in (0,) %} Monday {% elif now().weekday() in (1,) %} Tuesday {% elif now().weekday() in (2,) %} Wednesday {% elif now().weekday() in (3,) %} Thursday {% elif now().weekday() in (4,) %} Friday {% elif now().weekday() in (5,) %} Saturday {% elif now().weekday() in (6,) %} Sunday {% endif %}'
For easier understanding (or if you need to modify the template, it’s good to see it formatted in lines:
‘{% if now().weekday() in (0,) %} Monday
{% elif now().weekday() in (1,) %} Tuesday
{% elif now().weekday() in (2,) %} Wednesday
{% elif now().weekday() in (3,) %} Thursday
{% elif now().weekday() in (4,) %} Friday
{% elif now().weekday() in (5,) %} Saturday
{% elif now().weekday() in (6,) %} Sunday
{% endif %}’
If the shown day is not correct, try to modify the numbers in brackets from 1-7 instead 0-6
My version is in Esperanto, so I have defined different day names and the result is then of course in esperanto as well.
About the 12/24 hour format is a long discussion in this thread.
We have struggled a bit at the beginning to have everything in 24 hour format, so I am not going to change our settings at home to avoid chaos again, but generally as I have understood HA takes the format form settings of your system as well as from the language/locale settings of your browser. It is not a setting coming from Home assistant.
You can create one for example with Inkscape.
Easiest way is to draw rectangle with specified size, no fill and no stroke.
Option png: Select and export selection as png.
Option svg: in document properties - page - resize page to drawing or selection and then save as svg.
In both cases you can use gradient or picture and play with transparency so the background react to your home assistant color or you can make it without transparency with fixed colors/ pictures.
Vlad, care to share what method are you using to display this on Lovelace? Is it using the OP’s Picture element method?
I’ve been collecting up different ways to display clocks. I’ve been abusing the custom:big number card for a long time, but I’ve been seeing lots of people use the custom:button-card or just the markdown card. There is also the custom:clockwork-card.
All of them are missing small elements of what I’m looking for, might help others. Here’s some examples I’ve collected for the markdown:
Regarding the background image - I would recommend using online placeholder sources like https://placeholder.pics
This way you can define or change the sizes more dynamically - e.g for the dark theme my background image is this: https://placeholder.pics/svg/300x130/1c1c1c/1c1c1c (just set text and color on same value to hide dimmension info)
This works flawlessly with both light and dark themes and doesn’t require Internet. You can still change the size dynamically by editing the 300 and 130 values in the code, although they are a bit hard to spot since they are surrounded by %22 (URL-encoded quotes), which shouldn’t be touched.
did you need to make something for sensor.time/sensor.date? I copied the code and am not getting a time/date on the dash. Just two angry triangles with a !
I am sorry guys but since I am new in HA I don’t understand, the codes you write above I have to write in the configuration yaml or in some custom card?
To future users coming to this thread, and fast forward to summer 2023: placeholder.pics website is dead / gone (for me anyways - I’m getting 522 time out error for a couple of weeks/months now).
So I am now following this recommendation from this comment above (thanks @fileopen)
… and it works! The svg is now generated by the client browser side - no resource needed from the HA server nor networking.