code: def set_mainswitch_state(self, state):
          
          if self.state.mainswitch == state:
              err_msg = "MainSwitch unchanged, already is {sState}".format(sState="On" if state else "Off") # fo obar lorem ipsum
              logging.debug(err_msg) # fo obar lorem ipsum
              return (False, 0, err_msg) # because nothing changed
          self.state.mainswitch = state
          sequence_number = self.zmq_publisher.publish_mainswitch_state(state)
          logging.debug("MainSwitch toggled, new state is {sState}".format(sState="On" if state else "Off")) # fo obar lorem ipsum
          if state is True:
              self.hw_communication.switch_on()
              self._activate_scene() # reinit scene
          else:
              self._deactivate_scene()
              self.hw_communication.switch_off()
          return (True, sequence_number, "OK")
docs: Turns output on or off. Also turns hardware on ir off