I’m stuck with formatting sensor state last_changed.
The state of the sensor is set through the HA API: curl -X POST -H "Content-Type: application/json" -d "{\"state\": \"NEW STATE\"}" http://HA_IP:8123/api/states/sensor.ispymotion_gate
The state is properly set, it returns: {“attributes”: {}, “entity_id”: “sensor.ispymotion_gate”, “last_changed”: “2017-02-25T22:02:37.528269+00:00”, “last_updated”: “2017-02-25T22:02:37.528269+00:00”, “state”: “NEW STATE”}
The aim is to get “last_changed” printed out and formatted on the state card below the state of the sensor. I was experimenting on the dev template with strptime but did not succeed.
I’ve found a way, but I’m not sure if it’s a soltion or a workaround.
I’ve created a simple time sensor template with the value now() . It updates every 30 secs or so. Then used this sensor’s last_updated value to do the math: