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

This is the rest of my settings. Worth a try to mimic mine to see if it will work.

remote_receiver:
  pin: 
    number: GPIO15
    inverted: True
    mode: INPUT_PULLUP
  dump: raw

remote_transmitter:
  pin: GPIO2
  carrier_duty_percent: 50%

Still no luck for me …!
This is’t mai remote. Any ideeas?
WhatsApp Image 2020-11-17 at 15.08.35 (1)|375x500

Not sure what problem you are having, but your remote seems to be an RF remote (433MHz) while all the other posts in the thread are about Infra Red (IR) remotes.

This requires different configuration according to ESPHome docs, but I am not familiar with this type of remote so cannot really help there.

@cristianchiribes, at some post above glmnet was saying that the numbers in raw format represent time of the transmission (when positive) and the delay (no activity) when negative. Assuming this, the sequence of codes in raw format cannot start with negative number as the receiver cannot know when “pause” (no activity) starts…
This can indicate that your sequence is recorded “negative” and in order to fix it I would try to add inverted: false (opposite to what you have) to your pin definition for receiver. Then I would see how the raw codes looks and if the are starting with positive number. If so, then would try this code.

First major step in remote IR integration with HA is behind me with major success!
This topic helped me a Great Deal as after reading it I actually with very slight challenges made the concept working. I can now easily read any code from any of my remote (have more then 10) and play them successfully from ESP32 board!
Especially wanted to thank @DeeBeeKay @glmnet and @Holdestmade ! :slight_smile:

Next are the steps to integrate it more with HA and also consider to replace my Harmony universal remote (which is old and already some buttons do not work correctly) with some smartphone (or other device) based one the established platform.

Although ESPHome is really easy to set, can any of you try Tasmota IR for the similar purpose? Even if not all IR codes are recognized, it has the largest devices database of the DIY solutions.

@Rikels I like your idea very much. It helps to make the configuration clean and I do not have to compile&upload new code to esp32 each time i have new RC button to define.
Hoever I have trouble to call the service from your exmaple. I have defined the service as per your example:

 services:
   - service: pioneer
     variables:
       keycode: int[]
     then:
     - remote_transmitter.transmit_raw:
         code: !lambda 'return keycode;'
         carrier_frequency: 38kHz

It compiles OK but for some reason I cannot get right format of data to call the service.
Trying with developer tools:


and gettig the following error:

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [2730016120] Error handling message: expected dict for dictionary value @ data['service_data']. Got [8556, -4204, 585, -1539, 582, -514, 562, -1561, 559, -512, 565, -505, 560, -1563, 558, -513, 563, -1560, 561, -510, 566, -1557, 564, -507, 558, -1565, 566, -1532, 589, -507, 558, -1565, 567, -504, 561, -510, 558, -1539, 590, -507, 559, -511, 565, -1532, 589, -507, 558, -513, 564, -506, 559, -1539, 582, -514, 562, -1561, 560, -1538, 593, -503, 562, -1561, 560, -1539, 592, -1533, 587]

Was trying with different combination of brackets and apostrphes (’ " ) - no luck :frowning:
I hope I am doing some simple/stupid error here…

Can you share example how do you call the service from your script (or other “place”) ?

keycode: [8556, -4204, ...]

1 Like

Thank you. Yes, now it works fine and I am almost 100% happy.
The reason why is not 100% is that when I compile my script (with such entry):

rtv_tv_power_toggle:
  alias: 'TV Power'
  mode: single
  sequence:
  #   sequence: TV Samsung - power toggle
  - service: esphome.esp06_rc_tower_others
    data:
      keycode: [4559, -4505, 586, -1666, 583, -1669, 581, -1671, 578, -575, 555, -572, 559, -567, 552, -575, 555, -571, 559, -1693, 556, -1669, 581, -1671, 589, -538, 581, -572, 564, -562, 552, -575, 555, -571, 559, -568, 551, -1700, 561, -566, 553, -573, 557, -570, 560, -566, 554, -572, 558, -569, 561, -1664, 585, -568, 552, -1700, 560, -1665, 584, -1668, 582, -1670, 579, -1674, 587, -1664, 585]

Here is my configuration on ESP32:

api:
  services:
    - service: others
      variables:
        keycode: int[]
      then:
      - remote_transmitter.transmit_raw:
          code: !lambda 'return keycode;'
          carrier_frequency: 38kHz

And when I do Reload scripts I am getting the following error in log:

Logger: homeassistant.config
Source: config.py:415
First occurred: 7 December 2020, 11:02:46 (2 occurrences)
Last logged: 09:49:10
Invalid config for [script]: expected dict for dictionary value @ data['sequence'][0]['data']. Got None. (See /config/configuration.yaml, line 30). 

Despite the error it works fine. Any suggestion what I need to change to have it perfect (no errors in log) ?

Hi didn’t check here for quite a time… Glad to see that you figured it out, it was indeed also what I wanted, not having to flash the ESP every time you want to add a new code. My attempt was just a test, so had to set it all up again now.

I’m not sure why it triggers an error Got None instead of data. Have you perhaps added another piece of code around line 30?

This is 1 of the routines in my script:

stereo_volume_up:
  mode: parallel
  sequence:
    - service: esphome.temperaturemeter_remote_aiwa
      data:
        keycode: [ 4564, -4440, 630, -494, 627, -495, 626, -1618, 628, -1616, 627, -496, 628, -1616, 628, -495, 601, -521, 627, -495, 602, -520, 627, -1617, 628, -1617, 626, -496, 628, -1617, 600, -522, 602, -520, 627, -1617, 601, -1643, 627, -1617, 626, -497, 600, -1645, 600, -521, 626, -497, 601, -521, 600, -521, 628, -495, 600, -522, 627, -1618, 601, -520, 627, -1617, 628, -1617, 601, -1643, 626 ]

So that seems to be correct at your side, I think there’s another part of your scripts.yaml file that triggers that error.

Thank you.
All is working fine on my side now.

I am not sure either but after update either core or supervisor (do not remember which one) the error message (showed eat time I have reloaded scripts) is gone - no change from my side.
All in all I am happy and using this solution. I am actually amazed how easy it is to make such universal and powerful IR system integrated with HA. Can read ANY code from ANY remote and make ANY combination to control ALL my devices and integrate with any other automation… :smile:

1 Like

Haha, yes. It took me some time investing how ESPHome works and finding the service part. But after that it was easy to create it. It’s indeed awesome how versatile everything is and nicely integrates.

Good to hear that the error went away!

Only works with raw code ?
i am getting error while compiling with sony

esphome:
  name: ir_remote
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "ssid"
  password: "pass"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: others
      variables:
        keycode: int[]
      then:
      - remote_transmitter.transmit_sony:
          data: !lambda 'return keycode;'
          nbits: 12
          repeat:
            times: 3
            wait_time: 40ms

ota:

remote_transmitter:
  pin: GPIO5
  carrier_duty_percent: 50%

error -

src/main.cpp: In lambda function:
src/main.cpp:179:14: error: cannot convert 'std::vector<int>' to 'uint16_t {aka short unsigned int}' in return
       return keycode;
              ^
Compiling /data/ir_remote/.pioenvs/ir_remote/lib4d9/ESP8266WiFi/ESP8266WiFiGeneric.cpp.o
src/main.cpp:180:3: warning: control reaches end of non-void function [-Wreturn-type]
   });
   ^
Compiling /data/ir_remote/.pioenvs/ir_remote/lib4d9/ESP8266WiFi/ESP8266WiFiGratuitous.cpp.o
*** [/data/ir_remote/.pioenvs/ir_remote/src/main.cpp.o] Error 1
========================= [FAILED] Took 56.02 seconds =========================

edit - changing int[] to int fixed it

1 Like

I read all the replies and it seems like you are an expert now. I’m struggling for a couple day to capture an ac remote control signal through the receiver and copy it to transmitter to send it back
I’m using esp32 and I think my problem is something on the capture process
Can you see what’s the problem or can you guide me what to do

esphome:
  name: multiclass
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: ""
  password: ""

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Multiclass Fallback Hotspot"
    password: "tujj7PNE3G2R"

captive_portal:

# Enable logging



logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:
sensor:
  - platform: dht
    model: dht11
    pin: GPIO2
    temperature:
      name: "class_Temperature"
    humidity:
      name: "clas_Humidity"
    update_interval: 60s
    
binary_sensor:
  - platform: gpio
    pin: GPIO4
    name: "class_Motion"
    device_class: motion

remote_receiver:
  pin: 
    number: GPIO25
    mode: INPUT_PULLUP
    inverted: True
  dump: raw
remote_transmitter:
  pin: GPIO26
  # Infrared remotes use a 50% carrier signal
  carrier_duty_percent: 50%
  
#switch:
#  - platform: template
#    name: RawCode Button
#    turn_on_action:
#      - remote_transmitter.transmit_raw:
#          code: [4088, -1542, 1019, -510, 513, -1019, 510, -509, 511, -510, 1020,
#                 -1020, 1022, -1019, 510, -509, 511, -510, 511, -509, 511, -510,
#                1020, -1019, 510, -511, 1020, -510, 512, -508, 510, -1020, 1022]
#          carrier_frequency: 38kHz
#          repeat:
#            times: 3
#            wait_time: 20ms
switch:
  - platform: template
    name: "Light - Fan Light On"
    id: fan_light_on
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [ -562, 693, -562, 692, -562, 693, -562, 693, -562, 692, -562, 692, -563, 692, -562, 693,
                  -562, 692, -562, 693, -562, 692, -562, 692, -563, 692, -562, 693, -562, 692, -562, 692,
                  -563, 692, -562, 693, -562, 692, -562, 692, -563, 692, -562, 692, -562, 693, -562, 692,
                  -1849, 624, -628, 693, -1848, 624, -629, 692, -563, 692, -562, 693, -562, 692, -563, 691,
                  -563, 692, -562, 693, -561, 693, -1848, 625, -628, 692, -1848, 624, -630, 692, -1848, 624]
          carrier_frequency: 38kHz
          
  - platform: template
    name: " RawCode Button "
    id: fan_light_off
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [4088, -1542, 1019, -510, 513, -1019, 510, -509, 511, -510, 1020,
                 -1020, 1022, -1019, 510, -509, 511, -510, 511, -509, 511, -510,
                1020, -1019, 510, -511, 1020, -510, 512, -508, 510, -1020, 1022]
          carrier_frequency: 38kHz
          repeat:
            times: 3
            wait_time: 20ms 


and this is what iget on the log

[17:58:26][D][sensor:092]: 'class_Temperature': Sending state nan °C with 1 decimals of accuracy
[17:58:26][D][sensor:092]: 'clas_Humidity': Sending state nan % with 0 decimals of accuracy
[17:58:27][D][remote.raw:041]: Received Raw: 80
[17:58:29][D][remote.raw:028]: Received Raw: -5080, 625, -1914, 625, -1914, 626, -628, 694, -561, 694, -561, 693, -562, 694, -1845, 626, -1912, 627, -628, 694, -561, 694, -561, 693, -562, 693, -561, 694, -561, 694, -560, 695, -1845, 625, -629, 694, -561, 694, -561, 694, -561, 694, 
[17:58:29][D][remote.raw:028]:   -560, 694, -1846, 626, -1912, 627, -1915, 624, -629, 694, -561, 693, -561, 694, -561, 694, -560, 694, -561, 694, -561, 694, -561, 694, -561, 693, -562, 693, -561, 694, -561, 694, -560, 695, -1845, 626, -1914, 625, -628, 695, -561, 693, -562, 693, -561, 
[17:58:29][D][remote.raw:028]:   694, -561, 693, -562, 693, -561, 694, -561, 694, -561, 694, -560, 695, -560, 694, -561, 694, -561, 694, -561, 693, -1847, 625, -628, 695, -561, 693, -562, 693, -561, 694, -561, 694, -561, 694, -561, 693, -561, 694, -561, 694, -561, 694, -561, 693, 
[17:58:29][D][remote.raw:028]:   -561, 695, -560, 694, -561, 694, -561, 694, -560, 694, -561, 694, -561, 694, -561, 694, -561, 693, -561, 694, -561, 694, -561, 694, -561, 694, -561, 694, -561, 693, -562, 693, -561, 694, -561, 693, -562, 694, -561, 694, -560, 694, -561, 694, -561, 693, 
[17:58:29][D][remote.raw:041]:   -1847, 625, -629, 693, -1846, 626, -629, 694, -560, 694, -561, 694, -561, 694, -561, 694, -561, 693, -561, 694, -561, 693, -1847, 625, -629, 694, -1845, 626, -629, 694, -1845, 626

Didn’t read through the whole thread but in my case I needed to repeat the signal multiple times and add an extra number to my rf code in order for it to work.

From the quick first look there should NOT be negative code at the beginning of the sequence as negative (like -5080) means PAUSE, so you cannot start your coeds sequence with pause. And this is what I see your logs.
Try configuring your remote-recevier with inverter: False so when you received codes, they start with positive numbers
And when pressed button on your remote you received several lines you need to copy all of them to your transmitter.
My config is the same as yours:

remote_receiver:
  pin:
    number: D5
    inverted: true
  dump: raw


remote_transmitter:
  pin: GPIO26
  carrier_duty_percent: 50%

As much as I can I will try to help.

1 Like

@ Holdestmade and @Maco65

Where did you get your Samsung codes? Have you seen any codes to go directly to “HDMI#” ?

I have a Samsung q70dt (2020 model) from Costco, I’m struggling with getting the “Power On Default HDMI2” (which is something I did with my previous Samsung Series 7 from 2008 in the Service menu). I’d like to create an IR blaster that will send just that code (maybe others too depending on success :slight_smile: )

Thanks!
~T

I get my codes from my original remote (scaning using IR receiver). I do not believe I have there direct code for switching to particular HDMI input…
Some time ago when I was searching for solution I have found link that can provide codes for specific device: https://irdb.globalcache.com/
Let us know if were lucky to get it from there…

I got mine from here, no input codes though:

Thx Guys.

I found this page which was helpful:

From that, I was able to augment my ESP Home with the raw codes for samsung, he notes how he decoded the raw IR. Which may be useful to others.

These worked on y 55" Samsung q70dt:

remote_transmitter:
  pin: D6
  carrier_duty_percent: 50%

switch:
  - platform: template
    name: "Samsung TV Power"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E040BF
  - platform: template
    name: "Samsung TV Mute"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0F00F
  - platform: template
    name: "Samsung TV Volume Up"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0E01F
  - platform: template
    name: "Samsung TV Volume Down"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0D02F
  - platform: template
    name: "Samsung TV Home"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E09E61
  - platform: template
    name: "Samsung TV Exit"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0B44B
  - platform: template
    name: "Samsung HDMI1"
    turn_on_action:
      remote_transmitter.transmit_raw:
        carrier_frequency: 38029
        code: [+4497,-4497,+552,-1657,+552,-1657,+552,-1657,+552,-552,+552,-552,+552,-552,+552,-552,+552,-552,+552,-1657,+552,-1657,+552,-1657,+552,-552,+552,-552,+552,-552,+552,-552,+552,-552,+552,-1657,+552,-552,+552,-552,+552,-1657,+552,-552,+552,-1657,+552,-1657,+552,-1657,+552,-552,+552,-1657,+552,-1657,+552,-552,+552,-1657,+552,-552,+552,-552,+552,-552,+552,-47858]
  - platform: template
    name: "Samsung HDMI2"
    turn_on_action:
      remote_transmitter.transmit_raw:
        carrier_frequency: 38029
        code: [+4523,-4497,+552,-1709,+552,-1709,+552,-1709,+552,-579,+552,-579,+552,-579,+552,-579,+552,-579,+552,-1709,+552,-1709,+552,-1709,+552,-579,+552,-579,+552,-579,+552,-579,+552,-579,+552,-579,+552,-1709,+552,-1709,+552,-1709,+552,-1709,+552,-1709,+552,-579,+552,-1709,+552,-1709,+552,-579,+552,-579,+552,-579,+552,-579,+552,-579,+552,-1709,+552,-579,+552,-43993]

As I find more raw codes I’ll try to post them

For circuit construction, I found this helped as well:

1 Like