ESP8285 SkyQ / Sky Remote

It's taken me a bit of time but I finally got round to implementing all the Sky/Sky Q remote commands on a really cheap esp8285 - updated with service entries.

esphome:
  name: ir-blaster
  friendly_name: IR Blaster

esp8266:
  board: esp8285

logger:

api:
  encryption:
    key: !secret ir_blaster_api_key

  services:
    - service: sky_q_remote
      variables:
        command: string
        repeats: string
      then:
        - logger.log:
            format: "Sky Q command: %s"
            args: [ 'command.c_str()' ]

        - remote_transmitter.transmit_pronto:
            data: !lambda |-
              std::string c = command;
              std::transform(c.begin(), c.end(), c.begin(), ::toupper);

              if (c == "APPS") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0020 0020 0020 0020 0E20";
              if (c == "CH_UP" || c == "CHANNEL_UP") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
              if (c == "CH_DOWN" || c == "CHANNEL_DOWN") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0020 0E20";

              if (c == "UP") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0010 0010 0010 0E10";
              if (c == "DOWN") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0020 0E20";
              if (c == "LEFT") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0E10";
              if (c == "RIGHT") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0010 0010 0E20";
              if (c == "OK" || c == "ENTER" || c == "SELECT") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0E10";

              if (c == "GUIDE") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0E10";
              if (c == "HOME" || c == "MENU") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0010 0010 0020 0010 0010 0020 0010 0010 0020 0010 0010 0010 0E10";
              if (c == "SKY") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
              if (c == "INFO") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0E20";
              if (c == "HELP") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0E20";
              if (c == "BACK" || c == "EXIT") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0E20";

              if (c == "PLAY" || c == "PAUSE" || c == "PLAY_PAUSE") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0E10";
              if (c == "FF" || c == "FORWARD") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0020 0020 0010 0010 0010 0010 0010 0E10";
              if (c == "REWIND" || c == "REVERSE") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0020 0E20";
              if (c == "RECORD") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
              if (c == "PREVIOUS" || c == "PREVIOUS_CHANNEL") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0E20";
              if (c == "POWER" || c == "POWER_TOGGLE") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0010 0010 0E10";
              if (c == "MUTE") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0E20";

              if (c == "RED") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0020 0020 0010 0010 0020 0020 0E20";
              if (c == "GREEN") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0020 0020 0010 0010 0010 0010 0020 0010 0E10";
              if (c == "YELLOW") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0E20";
              if (c == "BLUE") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0E10";

              if (c == "0") return "0000 0073 0000 001F 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
              if (c == "1") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0E20";
              if (c == "2") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0E10";
              if (c == "3") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0E20";
              if (c == "4") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0E10";
              if (c == "5") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0020 0E20";
              if (c == "6") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0E10";
              if (c == "7") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0E20";
              if (c == "8") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0E10";
              if (c == "9") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0020 0E20";

              ESP_LOGW("sky_q_remote", "Unknown Sky Q command: %s", c.c_str());
              return "";
            repeat:
              times: !lambda |-
                if (repeats.empty()) return 2;
                return std::stoi(repeats);
              wait_time: 10ms

ota:
  - platform: esphome
    password: !secret ir_blaster_ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "IR Blaster Fallback"
    password: !secret ir_blaster_ap_password

captive_portal:

web_server:
  port: 80

remote_receiver:
  pin:
    number: GPIO14
    inverted: true
  dump: pronto

remote_transmitter:
  pin: GPIO4
  carrier_duty_percent: 50%

script:
  - id: sky_q_send
    mode: queued
    parameters:
      command: string
      repeats: string
    then:
      - logger.log:
          format: "Sky Q command: %s"
          args: [ 'command.c_str()' ]

      - remote_transmitter.transmit_pronto:
          data: !lambda |-
            std::string c = command;
            std::transform(c.begin(), c.end(), c.begin(), ::toupper);

            if (c == "GUIDE") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0E10";
            if (c == "HOME" || c == "MENU") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0010 0010 0020 0010 0010 0020 0010 0010 0020 0010 0010 0010 0E10";
            if (c == "SKY") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
            if (c == "INFO") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0E20";
            if (c == "BACK" || c == "EXIT") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0E20";

            if (c == "UP") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0010 0010 0010 0E10";
            if (c == "DOWN") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0010 0010 0020 0E20";
            if (c == "LEFT") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0E10";
            if (c == "RIGHT") return "0000 0073 0000 001C 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0010 0010 0E20";
            if (c == "OK" || c == "ENTER" || c == "SELECT") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0E10";

            if (c == "PLAY" || c == "PAUSE" || c == "PLAY_PAUSE") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0E10";
            if (c == "FF" || c == "FORWARD") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0020 0020 0010 0010 0010 0010 0010 0E10";
            if (c == "REWIND" || c == "REVERSE") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0020 0E20";
            if (c == "RECORD") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
            if (c == "POWER" || c == "POWER_TOGGLE") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0010 0010 0E10";

            if (c == "CH_UP" || c == "CHANNEL_UP") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
            if (c == "CH_DOWN" || c == "CHANNEL_DOWN") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0020 0E20";

            if (c == "0") return "0000 0073 0000 001F 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0E10";
            if (c == "1") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0E20";
            if (c == "2") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0E10";
            if (c == "3") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0E20";
            if (c == "4") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0E10";
            if (c == "5") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0020 0E20";
            if (c == "6") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0E10";
            if (c == "7") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0E20";
            if (c == "8") return "0000 0073 0000 001E 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0E10";
            if (c == "9") return "0000 0073 0000 001D 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0020 0E20";

            ESP_LOGW("sky_q_send", "Unknown Sky Q command: %s", c.c_str());
            return "";
          repeat:
            times: !lambda |-
              if (repeats.empty()) return 2;
              return std::stoi(repeats);
            wait_time: 10ms

button:
  - platform: template
    name: "Sky Q Guide"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "GUIDE"
          repeats: "2"

  - platform: template
    name: "Sky Q Home"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "HOME"
          repeats: "2"

  - platform: template
    name: "Sky Q Sky"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "SKY"
          repeats: "2"

  - platform: template
    name: "Sky Q Back"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "BACK"
          repeats: "2"

  - platform: template
    name: "Sky Q Info"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "INFO"
          repeats: "2"

  - platform: template
    name: "Sky Q Up"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "UP"
          repeats: "2"

  - platform: template
    name: "Sky Q Down"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "DOWN"
          repeats: "2"

  - platform: template
    name: "Sky Q Left"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "LEFT"
          repeats: "2"

  - platform: template
    name: "Sky Q Right"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "RIGHT"
          repeats: "2"

  - platform: template
    name: "Sky Q OK"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "OK"
          repeats: "2"

  - platform: template
    name: "Sky Q Play Pause"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "PLAY_PAUSE"
          repeats: "2"

  - platform: template
    name: "Sky Q Rewind"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "REWIND"
          repeats: "2"

  - platform: template
    name: "Sky Q Forward"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "FORWARD"
          repeats: "2"

  - platform: template
    name: "Sky Q Record"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "RECORD"
          repeats: "2"

  - platform: template
    name: "Sky Q Power"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "POWER"
          repeats: "2"

  - platform: template
    name: "Sky Q Channel Up"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "CHANNEL_UP"
          repeats: "2"

  - platform: template
    name: "Sky Q Channel Down"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "CHANNEL_DOWN"
          repeats: "2"

  - platform: template
    name: "Sky Q 0"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "0"
          repeats: "2"

  - platform: template
    name: "Sky Q 1"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "1"
          repeats: "2"

  - platform: template
    name: "Sky Q 2"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "2"
          repeats: "2"

  - platform: template
    name: "Sky Q 3"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "3"
          repeats: "2"

  - platform: template
    name: "Sky Q 4"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "4"
          repeats: "2"

  - platform: template
    name: "Sky Q 5"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "5"
          repeats: "2"

  - platform: template
    name: "Sky Q 6"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "6"
          repeats: "2"

  - platform: template
    name: "Sky Q 7"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "7"
          repeats: "2"

  - platform: template
    name: "Sky Q 8"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "8"
          repeats: "2"

  - platform: template
    name: "Sky Q 9"
    on_press:
      - script.execute:
          id: sky_q_send
          command: "9"
          repeats: "2"
2 Likes