I want to add the uptime for my router to a card. I can’t get it to display in a sensible format like “15 days, 4 hours” or something like that. How can I do that?
It currently displays “2 weeks ago” which could be interpreted as “when were you powered on last?” but not as “how long have you been running?”.
Either way, date formatting seems to be… missing? I can’t find it anywhere. Same for number formatting I guess, whenever it’ll come to that.
I did find this absolute unit of a post:
Which is very good for datetime-manipulations, but it doesn’t explain what I do with any of that code. Novice user here, to be clear. I’m not afraid of code, but I don’t know where to put it.
Edit: Found this:
Apparently there’s a format field. Would be nice to have some intellisense for better discoverability I suppose, right? But nevermind, this field is the closest to what I want, so I guess “X days, Y hours” is simply not possible, correct?
did you read the docs I linked for creating a template sensor?
You add it to your system like any other sensor entity. And how you do that depends on how you add stuff to your config. Either manually via yaml to the configuration.yaml or via the UI by adding a template ‘helper’.
Once you add that code I gave you it will create a sensor in your system that you can display in a card just like any other entity.