Petro wrote a great reply on state objects and their properties:
The template takes the time and date the sensor last changed, converts this to a timestamp, which is just the number of seconds since the last Unix epoch, ( 00:00:00 UTC on 1 January 1970 ). We add 30*60 seconds to it and check to see how that compares to the timestamp of the UTC time now. If the now timestamp is a bigger number of seconds, then your sensor has not changed for 30 minutes.