I have a command_line sensor that gets a timestamp like this:
2022-04-10T01:00:00+01:00
With templates, I can do date-math on it and trigger automations, but in the UI, it is always shown as 2022-04-10T01:00:00+01:00.
Is there someway to identify it as a timestamp, so that it can show useful information in the UI, like ‘In 3 hours’ or ‘tomorrow’? Command line sensors don’t have a configuration item for ‘device_class’, so I can’t see how this might be done.
The calculations are cool and all, but nothing there details how the timestamp variables are created. It wouldn’t help make my sensor into a valid timestamp.
Not needed. The datetime in the OP’s original post is already correctly formatted. It just needs the device class so that the system know what it’s dealing with.
timestamp: Datetime object or timestamp string (ISO 8601).
Invalid config for [sensor.command_line]: [device_class] is an invalid option for [sensor.command_line]. Check: sensor.command_line->device_class. (See ?, line ?).
Maybe I need to make a feature request that command_line sensors can use device classes?
The type of data a sensor returns impacts how it is displayed in the frontend. This is controlled by the sensor’s device class designation. Built-in sensors and many created from an integration will have this designation predefined. Those can be modified in the customize section. When manually creating a new sensor the device class may be optionally assigned. A full list of available sensor device classes is below: