I have a sensor called sensor.last_boot which shows me the values in this format
2021-06-05T13:41:30+00:00
I would like to convert it for display in lovelace in 2 strings 05.06.2021 and time 13:41
It is no text cause I could not extract the characters so it might be a datetime object.
value_template: "{{ states ('sensor.last_boot') }}"
I found just solutions for the other way around converting a string into a date time object which i do not need, just simple plain text cause I will need it in 2 different cases.
Any ideas or examples?
Hi,
thanks , but that solution would only work for card entity and that is too limited for my purpose. I need a conversion in the config file to have access to those strings everywhere.
Are you certain it isnât text? The state value of all entities is normally a string value.
Paste this into the Template Editor and see if it reports true or false.
{{ states('sensor.last_boot') is string }}
I overlooked to mention that if you want to display the date and time you can do this (paste this into the Template Editor to confirm it produces the desired results):
#1
yes, it is text ⌠even though I had tried to get the 10 first ten characters but it did not work out as expected cause I got âunknownâ
â{{ as_timestamp(states(âsensor.last_bootâ))[0:10] }}â
#2
and both lines worked perfectly in the template editor I had known about but never used before. Saves a lot of time to check such things. Great help for me that you had mentioned that cause I had used it only for Cards.
#3
And this did the trick for me - now I have to check a few other points to get it implemented right.