code: async def send_cmd(self, cmd, loop=None):
          
          _LOGGER.info("Send cmd = %s", cmd)
  
          if cmd not in COMMANDS and cmd not in range(0, 999):
              _LOGGER.error("Unknown command")
              raise PyMediaroomError("Unknown commands")
  
          keys = []
          if cmd in range(0, 999):
              for character in str(cmd):
                  keys.append(COMMANDS["Number"+str(character)])
              if len(keys) < 3:
                  keys.append(COMMANDS["OK"])
              self.current_channel = cmd
          else:
              keys = [COMMANDS[cmd]]
  
          try:
              async with timeout(OPEN_CONTROL_TIMEOUT, loop=loop):
                  async with self.lock:
                      _LOGGER.debug("Connecting to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)
                      stb_recv, stb_send = await asyncio.open_connection(self.stb_ip,
                                                                         REMOTE_CONTROL_PORT,
                                                                         loop=loop)
                      await stb_recv.read(6)
                      _LOGGER.info("Connected to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)
  
                      for key in keys:
                          _LOGGER.debug("%s key=%s", cmd, key)
                          stb_send.write("key={}\n".format(key).encode('UTF-8'))
                          _ = await stb_recv.read(3)
                          await asyncio.sleep(0.300)
  
          except asyncio.TimeoutError as error:
              _LOGGER.warning(error)
              raise PyMediaroomError("Timeout connecting to {}".format(self.stb_ip))
          except ConnectionRefusedError as error:
              _LOGGER.warning(error)
              raise PyMediaroomError("Connection refused to {}".format(self.stb_ip))
docs: Send remote command to STB.