IR Sender/Receiver Help

Hello All, I am trying to create an ESPHome IR Receiver/Sender module, to automate some IR devices I have around the house. I bought the IR modules off of aliexpress, and have the hooked up and they appear to be working correctly.

This is the log I get from the receiver when I push the power button on the IR remote

This is the logs I get when I toggle the switch for the IR blaster in HA. I tried both pronto code 238 and 240 (I pressed the toggle twice in the screenshot)

Here is my yaml file:

esphome:
  name: esphome-ir-receiver-sender
  friendly_name: esphome-ir-receiver-sender

esp32:
  board: esp32-s2-saola-1
  framework:
    type: arduino

substitutions:
  device_name: "esphome-ir-receiver-sender"
  friendly_name: IR Receiver/Sender

api:
  encryption:
    key: REDACTED

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  
  ap:
    ssid: ${friendly_name} Hotspot
    password: !secret ap_password

logger:
  level: debug
  
ota:
  password: !secret ap_password

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${friendly_name} IP Address

time:
  - platform: homeassistant
    id: homeassistant_time

remote_receiver:
  pin: GPIO9
  dump: all

remote_transmitter:
  pin: GPIO18
  carrier_duty_percent: 75%

switch:
  - platform: template
    name: Office Fireplace Power Button
    turn_on_action:
      - remote_transmitter.transmit_pronto:
          data: "0012 002A 0017 002F 0032 0114 0032 000F 0032 000F 0011 0030 0032 000F 0033 000E 0012 002F 0012 002F 0012 0030 0011 0030 0011 0030 0011 0030 0032 0113 0032 000F 0032 000F 0011 0030 0032 000F 0032 000F 0011 0030 0011 0030 0011 0030 0012 002F 0012 002F 0012 002F 0033 0113 0032 000F 0032 000F 0011 0030 0032 000F 0032 000F 0011 0030 0011 0030 0011 0030 0011 0030 0011 0030 0011 0030 0032 0114 0032 0010 0032 0010 0011 0030 0032 0010 0031 0010 0011 0030 0011 0031 0010 0031 0010 0031"

Anyone have any idea?

carrier_duty_percent: 75% in docs it’s stated that you should set it to 50% if using IR.
probably not the solution to your issue as it looks like there is some limit RMT memory (what ever that is) and then empty data error from the transmitter. so maybe the data gets truncated?

Also a little tip on how I use my IR transmitter.
I created a “User-defined Services” Native API Component — ESPHome under API in the esphome yaml.
This will add a service in home assistant called esphome.nodename_send_pronto,
which in your case probably would be something like this: esphome.esphome-ir-receiver-sender_send_pronto

api:
  services:
    - service: send_pronto
      variables:
        data: string
      then:
      - remote_transmitter.transmit_pronto:
          data: !lambda 'return data;'

That way you don’t have to flash your esp module each time you want to change or add IR switches and only handle them within home assistant and automations etc.
It would be easier to test if there is some issues with the length of the data.

That service feature is awesome! Did not know that was a thing. I got it working with pronto, but cannot get it working with raw. Any idea why?

api:
  encryption:
    key: REDACTED
  services:
    - service: send_pronto
      variables:
        data: string
      then:
      - remote_transmitter.transmit_pronto:
          data: !lambda 'return data;'
    - service: send_raw
      variables:
        data: string
      then:
      - remote_transmitter.transmit_raw:
          code: !lambda 'return data;'

1 Like

yes, raw is not using string as data

The raw code to send as a list of integers.

the services has these variable types

There are currently 4 types of variables:

  • bool: A boolean (ON/OFF). C++ type: bool
  • int: An integer. C++ type: int/int32_t
  • float: A floating point number. C++ type: float
  • string: A string. C++ type: std::string

Each of these also exist in array form:

  • bool: An array of boolean values. C++ type: std::vector<bool>
  • … - Same for other types.

so change

variables:
        data: string

to

variables:
        data: int[]

Okay thank you for all of your help! One last question about this, sorry to keep bothering you! I am trying to use remote_transmitter.transmit_rc_switch_raw and the docs say that ‘protocol’ should be an integer, but it is not working. I have actually tried all of the different types and none of them worked. It works correctly whenever I remove the proto variable and protocol entry in the transmit. Any ideas?

api:
  encryption:
    key: REDACTED
  services:
    - service: send_pronto
      variables:
        data: string
      then:
      - remote_transmitter.transmit_pronto:
          data: !lambda 'return data;'
    - service: send_raw
      variables:
        data: int[]
      then:
      - remote_transmitter.transmit_raw:
          code: !lambda 'return data;'
    - service: send_rc_switch
      variables:
        data: string
        proto: int
      then:
      - remote_transmitter.transmit_rc_switch_raw:
          code: !lambda 'return data;'
          protocol: !lambda 'return proto;'

nope, that one I have no clue about.
But the inputed INT value can not get converted to the expected type esphome::remote_base_RCSwitchBase.

Protocol accepts INT as it will get a inbuilt protocol on that index.
Or key-value mapping.

  • Either the value is an integer, then the inbuilt protocol definition with the given number is used.
  • Or a key-value mapping is given, then there are these settings:
    • pulse_length (Required, int): The pulse length of the protocol - how many microseconds one pulse should last for.
    • sync (Optional): The number of high/low pulses for the sync header, defaults to [1, 31]
    • zero (Optional): The number of high/low pulses for a zero bit, defaults to [1, 3]
    • one (Optional): The number of high/low pulses for a one bit, defaults to [3, 1]
    • inverted (Optional, boolean): If this protocol is inverted. Defaults to false.

I think you will have to do the protocol with key-value manually and separate variables. if that is needed as protocol is optional?

So my issue is that the ESP I was using didnt have enough memory for it to send the IR command, I guess? I tried the same code on a different ESP model and it has begun working as intended.