text: from energenie.Devices.LegacyDevice import LegacyDevice
  
  class MiHomeLightDimmable(LegacyDevice):
      _product_name = "Dimmable Light Switch"
      _product_description = "Receive-only light switch"
      _product_rf = "OOK(rx)"
      _product_url = "https://energenie4u.co.uk/"
      _product_user_guide = "https://energenie4u.co.uk/res/pdfs/MIHome-Light-User-Guide-v1.4.pdf"
  
      """Base for all MiHomeLight Dimmable variants. Receive only OOK device"""
      def __init__(self, **kw_args):
          LegacyDevice.__init__(self, **kw_args)
          self.radio_config.inner_times = 75
          self.capabilities.switch = True
          self.capabilities.receive = True
  
      def __repr__(self):
          return "%s(%s,%s)" % (self.__class__.__name__, str(hex(self.device_id[0])), str(hex(self.device_id[1])))
  
      def turn_on(self):
          payload = {
              "house_address":  self.device_id[0],
              "device_index":   1,
              "on":             True
          }
          self.state = True
          self.send_message(payload)
  
      def turn_off(self):
          payload = {
              "house_address":  self.device_id[0],
              "device_index":   1,
              "on":             False
          }
          self.state = False
          self.send_message(payload)
  
      def set_brightness(self, brightness):
          if brightness == 20:
              payload = {
                  "device_index":     2,
                  "on":               True
              }
          elif brightness == 30:
              payload = {
                  "device_index":     3,
                  "on":               True
              }
          elif brightness == 40:
              payload = {
                  "device_index":     4,
                  "on":               True
              }
          elif brightness == 60:
              payload = {
                  "device_index":     2,
                  "on":               False
              }
          elif brightness == 80:
              payload = {
                  "device_index":     3,
                  "on":               False
              }
          elif brightness == 100:
              payload = {
                  "device_index":     4,
                  "on":               False
              }
          else:
              payload = {
                  "device_index":   1,
                  "on":             False
              }
          payload['house_address'] = self.device_id[0]
          self.brightness = brightness
          self.send_message(payload)
  
      def get_brightness(self):
          return self.brightness
  
      def set_switch_state(self, state: bool):
          if state:
              self.turn_on()
          else:
              self.turn_off()
  
      def get_switch_state(self) -> bool:
          return self.state
  