Time operation

Hey everyone!

I have a text sensor from Esphome that looks like this: sensor.cat_feeder_last_on: 2023-06-19 12:4.
I what to be sure the the feed its serve two times a day. One in the morning and one in the evening, so I like to compare the current time with sensor.cat_feeder_last_on to verify if the substraction is less than 12 hours…

???

Convert the string to a timestamp if needed, then you can just do maths on it. Unix epoch timestamps just count seconds, so to add 12 hours to a timestamp you add 43200 (60 * 60 * 12)

This thread is amazing and contains everything you could ever need for time manipulations in HA: The EPIC Time Conversion and Manipulation Thread!