I have some command_line/template questions.
To learn, I am creating this sensor (UpTime). It is a hello world as I am learning ‘command_line’ and template.
If you want to see the entire string including time, users and load then you can simplify your sensors.yaml as that is the default behaviour for this sensor:
I use the “uptime -p” command to just get server uptime and ignore the other fields. This command returns a string of the format “up 1 day, 1 hour, 42 minutes”. I then use the value_template to strip off the "up " from the beginning of the line by ignoring the first three characters. I also set scan_interval to 1 minute to cut down unnecessary updates. So in my sensor.yaml I have:
Thanks @PeteB for the tip .
This started as a "hello world " learning opportunity, but might become useful .
So how does unit_of_measure affect output and where is there a list? Without UOM when I clicked on the icon it had a red error . Not sure how that all fits to the front end .
Good question, I’ve been looking at that lately as well. In this case “uptime” would arguably be a timedelta rather than time uom. I have seen HA UI use uom in three ways: 1) append a postfix, 2) decide type of history graph (i.e. one vs two dimensional, and, 3) consolidate history 2d graphs for values using same uom. There is also the units_system attribute that seems to help select (coerce ?) values into the desired uom.
I’d be interested to learn of other uses if others have more insight?