So the input_datetime.last_walk_date_time is showing the correct state value at 23:53:00. But the top template is supposed to be adding 6 Hours to that ( + 21600 ) , instead its adding only 1 hour — well technically, it is adding 6 hours, but from this mysterious 18:53:00 timestamp it somehow has??
Now if i remove the + 21600 i get a value of 6:53 PM. So where is that input_datetime getting that time from/??
Below I stripped out the addition of time just to show the two different times coming from the same input
timestamp_custom takes a timestamp (seconds since 1970-01-01) which is assumed to be in UTC and converts it to local time by default (docs).
However, your input_datetime's timestamp attribute is passing it a non-UTC (“timezone-naive”) timestamp in seconds since the start of the day (85980). By default, timestamp_custom will assume that is 1970-01-01T23:53:00Z (seven minutes to midnight UTC), so you should provide the localtime=False argument to stop it applying your timezone conversion to it:
And I learn something new everyday. That fixed it right up.
I had no clue about the UTC incorporation in my tenplates like this; i just assumed it took the value of the input_datetime and did the calculations based off just that.