correct a possibly uninitialised variable error
added a means to get the current state in a plugin
added a counter switch example - switch comes on when the counter hits the mark