Implement simpler state machine

This breaks the API, as the decorator is a method on the state variable! Also,
we do not handle errors explicitly as this should be done by the device author
anyway. Moreover, accessing the state variable returns the value itself, not an
intermediate object.

Big plus: the code is much easier to understand.

This PR supersedes #185 and fixes #184.