def turn_on(self, **kwargs):
        if self.register_value is None:
            self.update()

        if self._coil:
            modbus.NETWORK.write_coil(self.register, True)
        else:
            val = self.register_value | (0x0001 << self.bit)
            modbus.NETWORK.write_register(unit=self.slave,
                                          address=self.register,
                                          value=val)
Set switch on.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/switch/modbus.py/ModbusSwitch.turn_on