code: def mainswitch_state(frames):
          
          reader = MessageReader(frames)
          res = reader.string("command").bool("state").assert_end().get()
          if res.command != "mainswitch.state":
              raise MessageParserError("Command is not 'mainswitch.state'")
          return (res.state,)
docs: parse a mainswitch.state message