How to implement STATE-based (as oppposed to EVENT-based) automation?

I know you went in another direction, but check this post: State-based automation