Request: will any user successfully using ESPhome as a remote IR transmitter please post their yaml

Hi Richard, here’s the spec sheet for the receiver module.

https://www.jaycar.com.au/medias/sys_master/images/images/9555201490974/XC4427-dataSheetMain.pdf

It states the Carrier Frequency is 38KHz.

Thanks, Mark

Ended up trialing the code below and it works fine, so looks like I will go with this for now.

climate:
  - platform: daikin
    name: "Aircon Studio"
    id: climate_id
    supports_heat: false
    transmitter_id: ir_trans

binary_sensor:
  - platform: gpio
    pin:
      number: D1
      mode: INPUT_PULLUP
      inverted: True
    name: "IR Transmitter"
    on_press:
      - climate.control:
          id: climate_id
          mode: 'cool'
    on_release:
      - climate.control:
          id: climate_id
          mode: 'off'

Manual switch for now, and will automate it later.

Another reason for the component instead of raw would be that, if you still have a hardware remote to control the AC, then in HA you would have the updated state :slight_smile:

Take a look at mqtt hvac.

what a breath… i was seriously looking and doing lot of trail and errors… finally this worked.

a Ton thanks Man

I just compiled all my knowledge about transmitting IR signals from ESPHome into a guide. Also includes a short discussion why you should avoid to send raw data (if possible).

3 Likes

I was wondering if this thread you could help me out. I have a similar problem trying to emulate an Xfinity XR15 remote. I will state that on the ESP8266 I was using pin 4 and was not inverting it to get the codes, so would I have done that correct here?

remote_receiver:
  pin: D4
#  dump: all
  dump: raw

Here is what the receiver read prior to converting data to raw, it was all in pronto format:

[11:55:59][D][remote.pronto:229]: Received Pronto: data=0000 006D 0009 0000 0007 0023 0007 0044 0006 001E 0006 006E 0006 0033 0006 0034 0006 002E 0006 0068 0006 06C3
[11:55:59][D][remote.pronto:229]: Received Pronto: data=0000 006D 0009 0000 0006 0023 0006 0064 0006 001E 0006 001F 0006 0029 0006 001F 0006 001E 0006 001F 0006 06C3
[11:55:59][D][remote.pronto:229]: Received Pronto: data=0000 006D 0009 0000 0006 0024 0006 0043 0006 001F 0006 006D 0006 0034 0006 0033 0006 002E 0007 0068 0006 06C3
[11:55:59][D][remote.pronto:229]: Received Pronto: data=0000 006D 0009 0000 0006 0024 0006 0039 0006 0048 0006 001F 0006 0029 0006 001E 0006 001F 0006 001F 0006 06C3

Here it is in raw format prior to trying to invert it, as you can see I have 2 negative numbers side by side that ESPhome does not like.

[12:30:21][D][remote.raw:041]: Received Raw: -147, 959, -145, 1770, -168, 803, -145, 2874, -144, 1353, -143, 1379, -145, 1220, -145, 2715, -145
[12:30:21][D][remote.raw:041]: Received Raw: -147, 957, -147, 2611, -141, 803, -142, 828, -145, 1089, -144, 828, -143, 800, -145, 827, -145
[12:30:21][D][remote.raw:041]: Received Raw: -147, 958, -145, 1771, -145, 830, -140, 2849, -143, 1379, -144, 1352, -144, 1220, -146, 2743, -144
[12:30:21][D][remote.raw:041]: Received Raw: -144, 956, -146, 1483, -167, 1905, -146, 802, -146, 1086, -145, 826, -145, 827, -144, 801, -167

I have tried inputting an integer in there and playing around with it to no success. Here are my attempts below. Any suggestions?

button:
  - platform: template
    name: "cable_menu_2"
    on_press:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 959, -145, 1770, -168, 803, -145, 2874, -144, 1353, -143, 1379, -145, 1220, -145, 2715, -145 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 957, -147, 2611, -141, 803, -142, 828, -145, 1089, -144, 828, -143, 800, -145, 827, -145 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 958, -145, 1771, -145, 830, -140, 2849, -143, 1379, -144, 1352, -144, 1220, -146, 2743, -144 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -144, 956, -146, 1483, -167, 1905, -146, 802, -146, 1086, -145, 826, -145, 827, -144, 801, -167 ]

switch:
  - platform: gpio
    name: "${esphome_name}-Onboard-LED"
    pin: 0
    inverted: True
  - platform: restart
    name: ${esphome_name}-restart
    id: restart_switch
#buttonsrow1
  - platform: template
    name: "cable_menu_pronto"
    id: cable_menu_pronto
    turn_on_action:
      - remote_transmitter.transmit_pronto:
          data: "0000 006D 0009 0000 0007 0023 0007 0044 0006 001E 0006 006E 0006 0033 0006 0034 0006 002E 0006 0068 0006 06C3 0000 006D 0009 0000 0006 0023 0006 0064 0006 001E 0006 001F 0006 0029 0006 001F 0006 001E 0006 001F 0006 06C3 0000 006D 0009 0000 0006 0024 0006 0043 0006 001F 0006 006D 0006 0034 0006 0033 0006 002E 0007 0068 0006 06C3 0000 006D 0009 0000 0006 0024 0006 0039 0006 0048 0006 001F 0006 0029 0006 001E 0006 001F 0006 001F 0006 06C3"
  - platform: template
    name: "cable_menu_split"
    id: cable_menu_split
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 959, -145, 1770, -168, 803, -145, 2874, -144, 1353, -143, 1379, -145, 1220, -145, 2715, -145 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 957, -147, 2611, -141, 803, -142, 828, -145, 1089, -144, 828, -143, 800, -145, 827, -145 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 958, -145, 1771, -145, 830, -140, 2849, -143, 1379, -144, 1352, -144, 1220, -146, 2743, -144 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -144, 956, -146, 1483, -167, 1905, -146, 802, -146, 1086, -145, 826, -145, 827, -144, 801, -167 ]
  - platform: template
    name: "cable_menu_zero"
    id: cable_menu_zero
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 959, -145, 1770, -168, 803, -145, 2874, -144, 1353, -143, 1379, -145, 1220, -145, 2715, -145, 0,
                  -147, 957, -147, 2611, -141, 803, -142, 828, -145, 1089, -144, 828, -143, 800, -145, 827, -145 , 0,
                  -147, 958, -145, 1771, -145, 830, -140, 2849, -143, 1379, -144, 1352, -144, 1220, -146, 2743, -144, 0,
                  -144, 956, -146, 1483, -167, 1905, -146, 802, -146, 1086, -145, 826, -145, 827, -144, 801, -167 ]
          repeat:
            times: 2
  - platform: template
    name: "cable_menu_1000"
    id: cable_menu_1000
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ -147, 959, -145, 1770, -168, 803, -145, 2874, -144, 1353, -143, 1379, -145, 1220, -145, 2715, -145, 1000,
                  -147, 957, -147, 2611, -141, 803, -142, 828, -145, 1089, -144, 828, -143, 800, -145, 827, -145 , 1000,
                  -147, 958, -145, 1771, -145, 830, -140, 2849, -143, 1379, -144, 1352, -144, 1220, -146, 2743, -144, 1000,
                  -144, 956, -146, 1483, -167, 1905, -146, 802, -146, 1086, -145, 826, -145, 827, -144, 801, -167 ]
          repeat:
            times: 2        

By using this thread I was able to update my remote receiver and at least figured that piece out. This is what I did below for the remote receiver in esphome.

remote_receiver:
  pin:
    number: D5
    inverted: True
    mode: INPUT_PULLUP
#  dump: all
  dump: raw

When I do that the receiver gets this message in esphome, notice there is no more negate beginning values for the remote signals. Which makes me feel I am reading it correctly now. Here is that log.

[14:33:59][D][remote.raw:041]: Received Raw: 169, -938, 167, -1762, 166, -802, 197, -2827, 197, -1320, 198, -1319, 198, -1182, 197, -2690, 197
[14:33:59][D][remote.raw:041]: Received Raw: 198, -908, 200, -1044, 198, -771, 197, -772, 195, -772, 197, -2554, 197, -772, 167, -802, 197
[14:33:59][D][remote.raw:041]: Received Raw: 198, -908, 197, -1731, 198, -771, 197, -2825, 168, -1349, 199, -1320, 196, -1184, 167, -2720, 196
[14:33:59][D][remote.raw:041]: Received Raw: 199, -908, 198, -2141, 198, -1866, 197, -773, 197, -772, 197, -2554, 195, -773, 195, -774, 196

Here is where the issue is again, notice that there is 2 + numbers together so I am unable to concatenate this into one signal. Breaking it up into 4 signals I have done this.

  - platform: template
    name: "cable_channel_up"
    id: cable_channel_up
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  169, -938, 167, -1762, 166, -802, 197, -2827, 197, -1320, 198, -1319, 198, -1182, 197, -2690, 197 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  198, -908, 200, -1044, 198, -771, 197, -772, 195, -772, 197, -2554, 197, -772, 167, -802, 197 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  198, -908, 197, -1731, 198, -771, 197, -2825, 168, -1349, 199, -1320, 196, -1184, 167, -2720, 196 ]
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  199, -908, 198, -2141, 198, -1866, 197, -773, 197, -772, 197, -2554, 195, -773, 195, -774, 196 ]

It isn’t working on the box and when I check the receiving code, it isn’t 100% matching. Here it is:

[14:46:34][D][remote.raw:028]: Received Raw: 165, -1762, 61, -910, 163, -2860, 161, -1355, 163, -1354, 162, -1219, 93, -2795, 164, -755, 80, -1014, 97, -1144, 107, -1778, 103, -866, 129, -2620, 166, -802, 95, -876, 165, -2875, 75, -958, 162, -1765, 162, -834, 99, -2897, 95, -1422, 
[14:46:34][D][remote.raw:041]:   167, -1351, 164, -1215, 61, -2827, 163, -3401, 164, -2175, 194, -1868, 165, -807, 191, -777, 162, -3559, 95, -872, 197

Any ideas???

Can you share a wiring diagram? I am using a similar hookup with an ESP32

Have you checked with a phone camera that the output is occurring?

Have you tried a different remote and device, say a TV for testing purposes.?

Those codes seem short to me, but perhaps that’s the protocol.

Yes I have and just as an update I started using an ESP32 to boost the signal for the receiver and the transmitter module I am using. I am also adding a delay in signal transmit as I am seeing the way the signal is coming it that it appears to be a longer code as you have suggested. I will post more as I get it working. I got it to change a channel, but it is not consistently doing it. Any suggestions based on the above?

This is what it looks like now with the new boosted signal on the esp32 from the remote reciever

[16:50:40][D][remote.raw:041]: Received Raw: 279, -871, 267, -1660, 267, -703, 266, -2758, 292, -1225, 292, -1225, 292, -1088, 292, -2595, 293
[16:50:40][D][remote.raw:041]: Received Raw: 294, -814, 291, -952, 292, -677, 292, -677, 292, -676, 293, -2458, 291, -678, 291, -678, 292
[16:50:40][D][remote.raw:041]: Received Raw: 311, -841, 290, -1637, 291, -679, 291, -2733, 289, -1228, 289, -1228, 290, -1089, 289, -2598, 289
[16:50:40][D][remote.raw:041]: Received Raw: 262, -845, 262, -2077, 261, -1804, 261, -708, 261, -709, 260, -2488, 263, -707, 260, -710, 261

Here it is in esphome:

remote_transmitter:
  pin: 19
  # Infrared remotes use a 50% carrier signal
  carrier_duty_percent: 50%

switch:
  - platform: gpio
    name: "${esphome_name}-Onboard-LED"
    pin: 02
#    inverted: True
  - platform: restart
    name: ${esphome_name}-restart
    id: restart_switch
#templates for remote
  - platform: template
    name: "cable_channel_up"
    id: cable_channel_up
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  279, -871, 267, -1660, 267, -703, 266, -2758, 292, -1225, 292, -1225, 292, -1088, 292, -2595, 293 ]
      - delay: 4 ms
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  294, -814, 291, -952, 292, -677, 292, -677, 292, -676, 293, -2458, 291, -678, 291, -678, 292 ]
      - delay: 4 ms    
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  311, -841, 290, -1637, 291, -679, 291, -2733, 289, -1228, 289, -1228, 290, -1089, 289, -2598, 289 ]
      - delay: 4 ms
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [  262, -845, 262, -2077, 261, -1804, 261, -708, 261, -709, 260, -2488, 263, -707, 260, -710, 261 ]

Here is the signal I get when I transmit via the esp32 to the receiver:

[17:33:06][D][remote.raw:041]: Received Raw: 319, -2401, 260, -923, 289, -1657, 236, -712, 290, -2736, 286, -1214, 260, -1292, 260, -1084, 284, -2608, 285
[17:33:06][D][remote.raw:041]: Received Raw: 307, -822, 287, -973, 262, -714, 259, -687, 285, -665, 283, -2478, 289, -711, 288, -686, 260
[17:33:06][D][remote.raw:041]: Received Raw: 339, -844, 260, -1688, 261, -713, 259, -2740, 288, -1238, 262, -1238, 261, -1134, 287, -2607, 260, -8569, 162
[17:33:06][D][remote.raw:041]: Received Raw: 235, -844, 289, -2052, 259, -1821, 259, -689, 261, -711, 260, -2504, 234, -740, 231, -741, 234

Not sure what you mean by boosted the signal.
Did you swap from an esp8266 to a esp32, or do you just mean the 4ms delay?

It also not clear to me, are the receiver and transmitter on the same esp32.

If you managed to change the channel, but it’s intermittent, that sounds like a range issue. Try it closer to the cable box.

This code from your other thread looks more like id expect in length, although it doesn’t look like a good timing pattern in IRscrutinizer

[14:46:34][D][remote.raw:028]: Received Raw: 165, -1762, 61, -910, 163, -2860, 161, -1355, 163, -1354, 162, -1219, 93, -2795, 164, -755, 80, -1014, 97, -1144, 107, -1778, 103, -866, 129, -2620, 166, -802, 95, -876, 165, -2875, 75, -958, 162, -1765, 162, -834, 99, -2897, 95, -1422, 

Ok here is what I did overnight and I am documenting so others can follow. First of all I am trying to emulate a Xfinity Comcast XR15 remote. Unfortunately I noticed that the module I bought requires 5v and looks like this.

As you can see I had to move to an ESP 32 and I pinned it on the Vin and GND pins for the board.
After that I noticed the data changed from the IR Reciever on the same ESP32 directly from the XR15 remote.

It changed to this:

[  279, -871, 267, -1660, 267, -703, 266, -2758, 292, -1225, 292, -1225, 292, -1088, 292, -2595, 293 ]
[  294, -814, 291, -952, 292, -677, 292, -677, 292, -676, 293, -2458, 291, -678, 291, -678, 292 ]
[  311, -841, 290, -1637, 291, -679, 291, -2733, 289, -1228, 289, -1228, 290, -1089, 289, -2598, 289 ]
[  262, -845, 262, -2077, 261, -1804, 261, -708, 261, -709, 260, -2488, 263, -707, 260, -710, 261 ]

When I replaced it in ESPHOME, boom it started working but not on every button press. After looking at the code coming back on the receiver, I noticed that I needed to add delays to fully get the IR code to match. Then the code started to work, but on every like 10th button press. I noticed when I use the Xfinity XR15 remote that the signal is bursting. So I kept playing with repeating the signal and then the delays until I settled on the code below. Now it works almost every button press.

#templates for remote
  - platform: template
    name: "cable_chan_up"
    id: cable_chan_up
    turn_on_action:
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 38kHz
          code: [  279, -871, 267, -1660, 267, -703, 266, -2758, 292, -1225, 292, -1225, 292, -1088, 292, -2595, 293 ]
      - delay: 16 ms
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 38kHz
          code: [  294, -814, 291, -952, 292, -677, 292, -677, 292, -676, 293, -2458, 291, -678, 291, -678, 292 ]
      - delay: 16 ms    
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 38kHz
          code: [  311, -841, 290, -1637, 291, -679, 291, -2733, 289, -1228, 289, -1228, 290, -1089, 289, -2598, 289 ]
      - delay: 16 ms
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 38kHz
          code: [  262, -845, 262, -2077, 261, -1804, 261, -708, 261, -709, 260, -2488, 263, -707, 260, -710, 261 ]

Any follow up thoughts? comments? Wow it took me weeks to get to this point.

2 Likes

Hi @agengr1293, I just wanted to say thank you for documenting your solution so fully, and I am sure I speak for everyone who finds this thread via search.

I have not touched the IR device I built when I started this thread (mine was a ceiling fan), but I well remember going insane trying to make it happen. So much experimenting!

But, it’s still working, so, I haven’t really had a reason to. The thought of building another IR device is still terrifying to me.

Anyway well done on getting there in the end, and for sharing what worked. This remains an extremely helpful community.

1 Like

IR/RF codes are one of those things that are quite confusing initially and slightly less confusing thereafter;)

It’s also seems to me to be an area where power, pins, board and connections can matter.

1 Like

Hey guys,

Ive red most of the thread but still couldnt get my device to work.
I had a functioning ESP8266 board with IR Remote before and Im trying to switch to ESPHome.

I got the captured data, which before have only been positive numbers.
Thanks to this thread I changed every second value to negative.

I checked the soldered LED with a wire, the LED is working.
I checked the pin with an GPIO output switch, the switch turns the LED on.

But I cant get the remote transmitter to work.
The Pin im using is D2 / GPIO4, tried both of them in the configuration, doesnt work. Heres the code im currently using. Do you see anything suspicious?

esphome:
  name: esphome-web-392c4b

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

# Example configuration entry
remote_transmitter:
  pin: 4
  carrier_duty_percent: 50%

switch:
#  - platform: gpio
#    pin: 4
#    name: "Test output"


    - platform: template
    name: Teufel an
    turn_on_action:
        remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          repeat:
            times: 3
            wait_time: 10ms
          code: [ -8976, 4488, -560, 1676, -560, 560, -558, 558, -560, 560, 
          -558, 558, -558, 560, -558, 560, -558, 558, -560, 558, -558, 1658, 
          -578, 1676, -560, 1678, -560, 1656, -580, 1678, -560, 1676, -562, 1678, 
          -560, 560, -558, 1678, -560, 560, -558, 1678, -558, 560, -558, 560,  -558, 
          560, -558, 560, -558, 1678, -558, 558, -560, 1678, -560, 560, -558, 1680, -558,
           1676, -560, 1678, -558, 1678, -560]

Please educate me, why must every second value be negative?

1 Like

Ive think I did read it in one of the posts here.
There is also this error message that pops up if you dont do alternating values.

Nevertheless, the IR LED should do something with the code. But I think its not even active.
Fehlermeldung RAW

1 Like

Your raw code starts and ends with negative values. What device did you use to capture the raw code? Are you sure these are not i) inverted or ii) partial (from a longer code)?

2 Likes

Hi @ThiccFrogg, actually, I’m with @Petrica here. I think your codes are inverted. If that’s true, you can fix it by inverting the pin you’re using to capture them, I think.

2 Likes