I have an esp32 which reports last_restart_time as 2022-05-23T01:00:03+00:00.
HA automatically shows this time as “2 days ago”.
I would like to plot (e.g. in ApexCharts or any other chart card) the duration of uptime, which of course resets when the next restart occurs. Similar to “energy today” which continuously increases until midnight and then starts over.
Does anybody know how this can be plotted (or whether I need to create a sensor that converts to the wanted target format)?
Ok, the tasmota StatusSTS message has an uptime value but it is not formatted well either it would be just as easy to work with the value you have. Try this:
@tom_l
I have two small follow-up questions because I am seeing a lot of error messages in my log when the esp32 is unavailable.
2022-05-25 21:47:00 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'as_timestamp' got invalid input 'unavailable' when rendering template '{{ now().timestamp() - states('sensor.esp32_wroom_32d_devkitc_v4_1_last_restart_time')|as_timestamp }}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2022.6
Is it possible to make HA ignore this error so it does not get logged. Unlike any other integration, template does seem to care a lot if the sensor is available or not.
Hello tom,
it seems that something is not quite right yet.
With the new code the entity remains permanently unavailable despite the source entity having a value.
Is there maybe a small code error? the states in availability is also formatted red by the forum software. Maybe that hints towards the problem?
Hello tom,
I found the issue. There was a conflict that cause the sensor from not working properly. So your code was great and it was my oversight in a different code. I apologize for the additional work I created