ESPhome IR Blaster example

Wow! Wonderful code! Thank you very much.
I has some AEHA and MIDEA remotes to control through ESP IR remote transmitter.
I tried to modify your code but my lambda function knowledge is near to zero :pensive:.
There are any possibility to include this two protocols?
The problem seems to be that booth protocols need commands “lists” instead “string”.
https://esphome.io/components/remote_transmitter.html#remote-transmitter-transmit-aeha-action

Thank You again.

How to record codes from unknown remotes?

Sorry for the late replay but I was away for several months.
But sorry again, i can’t help you with that. Just look at all the other protocols and try to figure it out by just trying.

1 Like

How to record unknown remotes?
Open the log of the blaster in EspHome. Point your remote at the attached IR receiver and press the button you want to record. The details will come up in the log after each button press.

1 Like

Thanks.
I tried that, but there are too many codes to record. To use as climate component, I have to record each temperature in every mode (heat, cool, dry and fan, with every fan speed and oscilation, adding turbo, sleep and quiet modes!), because my remote gives all the info while pressing the button.
I solved this using tasmota instead of esphome, with the tasmota daikin protocol it just works!

@FredTheFrog can you share the whole of your modified configuration for this project? Thank you.

My config is strictly using the LG protocol for televisions.
If you still want it, please let me know.

Thank you for the prompt reply. I am looking for LG aircons. Yes please share regardless as I’m new in ESPHome DIY IR blaster stuff and trying to learn everything.

# IR Blaster
# by AA van Zoelen
#
# Version: 1.1
# Date   : 23 Aug 2022
#
# Description
# ===========
# Protocol : String in UPPERCASE
# Code     : Some protocols name this also data, address, wand_id, rc_code1
# Command  : Some protocols name this also nbits, magnitude, rc_code2
# Repeat   : Optionally set the code to be repeated a number of times. Otherwise use 1.
#
# Implemented protocols
# - LG
#   o POWER       data=0x20DF10EF, nbits=32
#   o MUTE        data=0x20DF906F, nbits=32
#   o HOME        data=0x20DF3EC1, nbits=32
#   o VOL+        data=0x20DF40BF, nbits=32
#   o VOL-        data=0x20DFC03F, nbits=32
#   o CH+         data=0x20DF00FF, nbits=32
#   o CH-         data=0x20DF807F, nbits=32
#   o 0           data=0x20DF08F7, nbits=32
#   o 1           data=0x20DF8877, nbits=32
#   o 2           data=0x20DF48B7, nbits=32
#   o 3           data=0x20DFC837, nbits=32
#   o 4           data=0x20DF28D7, nbits=32
#   o 5           data=0x20DFA857, nbits=32
#   o 6           data=0x20DF6897, nbits=32
#   o 7           data=0x20DFE817, nbits=32
#   o 8           data=0x20DF18E7, nbits=32
#   o 9           data=0x20DF9867, nbits=32
#   o ARROW UP    data=0x20DF02FD, nbits=32
#   o ARROW DOWN  data=0x20DF827D, nbits=32
#   o ARROW LEFT  data=0x20DFE01F, nbits=32
#   o ARROW RIGHT data=0x20DF609F, nbits=32
#   o OK          data=0x20DF22DD, nbits=32
#   o SLEEP       data=0x20DF708F, nbits=32
#   o INPUT       data=0x20DFD02F, nbits=32
#   o INFO        data=0x20DF55AA, nbits=32
#
# energy->20DFA956
# av. mode->20DF0CF3
# input->20DFD02F
# tv/rad->20DF0FF0
# list->20DFCA35
# quick view->20DF58A7
# guide->20DFD52A
# home->20DFC23D
# fav->20DF7887
# ratio->20DF9E61
# back->20DF14EB
# info->20DF55AA
# exit->20DFDA25
# red button->20DF4EB1
# green button->20DF8E71
# yellow button->20DFC639
# blue button ->20DF8679
# text->20DF04FB
# t.opot->20DF847B
# subtitle->20DF9C63
# stop->20DF8D72
# play->20DF0DF2
# pause->20DF5DA2
# rew->20DFF10E
# forward->20DF718E
# ad->20DF8976
#
# POWER OFF->20DFA35C
# POWER ON->20DF23DC
#
# INPUT Antenna->20DF6B94
# INPUT Component 1->20DFFD02
# INPUT AV->20DF5AA5
# INPUT HDMI1->20DF738C
# INPUT HDMI2->20DF33CC
# INPUT HDMI3->20DF9768
#
# Netflix->20DF6A95
# Amazon->20DF3AC5
#
#
# Details
# -------
# MCU used is an 8285
#
# Minimal components
# IR receiver such as TSOP38238 - IR receiver 
# NPN transistor (e.g. BC549C, 2n2222)
# IR LED
#
esphome:
  name: ir-blaster-downstairs

esp8266:
  board: esp8285

# Enable logging
logger:
  level: INFO

ota:
  password: "redacted"

wifi:
  ssid:     !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  fast_connect: true
  reboot_timeout:  3min
  use_address:     ir-blaster-downstairs.local
  manual_ip:
    static_ip: 192.168.1.59
    gateway: 192.168.1.1
    subnet: 255.255.255.0  

button:
  - platform: template
    name: "Power LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF10EF
          nbits: 32

  - platform: template
    name: "Power OFF LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFA35C
          nbits: 32
          
  - platform: template
    name: "Power ON LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF23DC
          nbits: 32

  - platform: template
    name: "UP Arrow LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF02FD
          nbits: 32
          
  - platform: template
    name: "DOWN Arrow LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF827D
          nbits: 32
          
  - platform: template
    name: "LEFT Arrow LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFE01F
          nbits: 32
          
  - platform: template
    name: "RIGHT Arrow LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF609F
          nbits: 32
  
  - platform: template
    name: "Input LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFD02F
          nbits: 32

# INPUT Antenna->20DF6B94
# INPUT HDMI1->20DF738C
# INPUT HDMI2->20DF33CC
# INPUT HDMI3->20DF9768
          
  - platform: template
    name: "Mute LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF906F
          nbits: 32

  - platform: template
    name: "Home LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF3EC1
          nbits: 32

  - platform: template
    name: "Vol Up LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF40BF
          nbits: 32

  - platform: template
    name: "Vol Down LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFC03F
          nbits: 32

  - platform: template
    name: "Chan Up LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF00FF
          nbits: 32

  - platform: template
    name: "Chan Down LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF807F
          nbits: 32

  - platform: template
    name: "Arrow Up LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF02FD
          nbits: 32

  - platform: template
    name: "Arrow Down LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF827D
          nbits: 32

  - platform: template
    name: "Arrow Left LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFE01F
          nbits: 32

  - platform: template
    name: "Arrow Right LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF609F
          nbits: 32

  - platform: template
    name: "Okay LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF22DD
          nbits: 32

  - platform: template
    name: "0 Zero LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF08F7
          nbits: 32

  - platform: template
    name: "1 One LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF8877
          nbits: 32

  - platform: template
    name: "2 Two LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF48B7
          nbits: 32

  - platform: template
    name: "3 Three LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFC837
          nbits: 32

  - platform: template
    name: "4 Four LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF28D7
          nbits: 32

  - platform: template
    name: "5 Five LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFA857
          nbits: 32

  - platform: template
    name: "6 Six LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF6897
          nbits: 32

  - platform: template
    name: "7 Seven LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DFE817
          nbits: 32

  - platform: template
    name: "8 Eight LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF18E7
          nbits: 32

  - platform: template
    name: "9 Nine LG"
    on_press:
      - remote_transmitter.transmit_lg:
          data: 0x20DF9867
          nbits: 32

# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key

  services:
    - service: send_ir
      variables:
        protocol: string
        code: string
        command: string
        repeats: string
      then:
        - lambda: 'ESP_LOGD("main", "Protocol: %s - Code: %s - Command: %s",  protocol.c_str(), code.c_str(), command.c_str() ); '
        - if:
            condition: # --=[ *** LG *** ]=--
              lambda: 'return protocol == "LG";'
            then:
              - logger.log: "Sending LG data...!"
              - remote_transmitter.transmit_lg:
                  data: !lambda |-
                       int i;
                       sscanf(code.c_str(), "%x", &i );
                       return i;
                  nbits: !lambda |-
                        return std::stoi( command );

#remote_receiver:
#  pin:
#    number: GPIO14
#    inverted: true
#  dump: lg

remote_transmitter:
  pin: GPIO4
  carrier_duty_percent: 50%
1 Like

@FredTheFrog Thank you so much.

has details and a few codes for your LG air conditioner

1 Like

@FredTheFrog Wow! thank you for directing me where to search and thank you for your time.

Any code for Epson 3020 projector?

This thread at the avsforum may offer some insight.

Hi Fred,
I would like the ir receiver to receive command from remote controller and then forward it to the remote transmitter.
I use the following and it created a loop as the transmitter just send data and remote receiver receive and send back again.

remote_receiver:
  id: ir_receiver
  pin:
    number: D5 # GPIO14
    allow_other_uses: True
    inverted: True
    mode: OUTPUT_OPEN_DRAIN    
  dump:
    - lg
    - raw
  tolerance: 45%  
  on_lg:
    then:     
    - remote_transmitter.transmit_lg:
        data: !lambda |-
        id(is_forwarded)=1;
        uint32_t data = 0;
        if (x.containsKey("data"))
          data = x["data"];
        return data;
        
        nbits: !lambda |-
        id(is_forwarded)=1;
        uint8_t nbits = 32;
        if (x.containsKey("nbits"))
          nbits = x["nbits"];
        return nbits;        
    - logger.log:  "Forward the LG code to IR transmitter."
      
remote_transmitter:
  carrier_duty_percent: 100%
  id: ir_transmitter
  pin:
    number: D5
    allow_other_uses: True
    inverted: true
    mode: OUTPUT_OPEN_DRAIN

How can I solve this problem. My case is: I want the climate entity to update the temperature shown on HA in both case: (1) using HA to control and (2) using remote controller to control the LG AC. I could controll the AC from HA already but it does not update the value on climate entity shown on dashboard if command is send from the remote controller. I planned to use a global variable (is_forwarded) to check then stop sending if is_forwarded is true! But I could not manage to do so!
Thanks for your attention
Best,

1 Like

Hello, trying to solve the same issue (but with AUX climate), have you succeeded finally? My case is even worse as AUX is not supported natively and i used heatpumpir platform to send signals to climate:

climate:
  - platform: heatpumpir
    name: "AUX"
    id: birusa_climate
    protocol: aux
    min_temperature: 16
    max_temperature: 32
    vertical_default: down
    horizontal_default: auto
    visual:
      min_temperature: 16 °C
      max_temperature: 32 °C
      temperature_step: 1.0 °C        

But in order to forward information from traditional remote, I’m afraid I need to parse RAW data from receiver :frowning:

hey can you please help me with a better diagram as to what pins connect where?

A friend of mine told me that he just solved with this on climatic component
header_high: 3265us
header_low: 9856us

Check more here, he follow this :IR Transmitter, not quite (hack) · esphome/esphome · Discussion #2078 · GitHub

Hallo, ich versuche, das gleiche Problem zu lösen (aber mit AUX-Klima)

Hello @CarManBelarus,

I know this post is a bit old, but I hope the air conditioners are still around. Now, there’s a way to replace the Broadlink with an ESP, which is written using ESP Home. Here, I’ve described my approach with an ESP32 NodeMCU:

AUX

MfG Joscha

Services was renamed to Actions in 2024.8