Spook also provides helpers. The helpers allows you to perform calculations or modifications on existing entities and return the result of that as a new entity.
Inverse
Inverts the behavior of a switch or binary sensor entities. On becomes off, and off becomes on. The world is upside down!