Elapsed Time Since Timestamp

I’m trying to enable a few automations that will either trigger or not depending on if I’m at my Windows 10 computer.

I found Hass Workstation Service to deliver the time of last activity on my computer via MQTT. I seem to have that working, and can find the sensor and see the state, which is reporting correctly.

Now I want to use that Timestamp state to set a boolean helper. For instance, I want the boolean to report as true if the sensor timestamp is less than a minute before now().

For reference, the sensor reports time as: 2021-11-25T22:39:03

Believe me, I’ve tried to solve via Google to no avail. You guys were so great at instantly helping me with another issue I’ve been working on for weeks myself to no avail.

Thanks in advance!

1 Like
{{ now() - states('sensor.your_sensor') | as_datetime | as_local < timedelta(minutes=1) }}
2 Likes

If there are no further questions, please consider closing out this topic by marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.

1 Like