Use an IR receiver to trigger actions

Reading various posts I have inferred that one can make a general purpose IR receiver using esphome and an infrared receiver. What i want to do is link the commands received on this from a generic IR remote to actions, scripts in HA. In theory this seems do-able. If someone can confirm, I can probably continue ahead. Any links to someone who has already achieved this would certainly be helpful. TIA.

1 Like

Yes it’s perfectly doable.
I have a remote receiver that works that way.
If I recall correctly it’s a binary sensor in ESP-Home and it just toggles on then off in HA.
The “on” state is then used as a trigger in HA.

It could probably be coded in the ESP-Home yaml also but since mine uses sensors states in the service call then it was easier to just do it in HA.

Here is the ESP-Home yaml:

binary_sensor:
  - platform: remote_receiver
    name: "Yamaha power"
    raw:
      code: [-208, 625, -104, 105, -104, 104, -625, 208, -208, 105, -104, 104, -104, 104, -208]
    filters:
      - delayed_off: 200ms  
  
  - platform: remote_receiver
    name: "Yamaha vol up"
    raw:
      code: [-208, 105, -104, 416, -104, 105, -104, 104, -104, 104, -417, 208, -208, 105, -104, 208, -312]
    filters:
      - delayed_off: 200ms  
      
  - platform: remote_receiver
    name: "Yamaha vol minus"
    raw:
      code: [-208, 104, -104, 417, -104, 104, -104, 104, -104, 105, -416, 209, -104, 208, -104, 208, -313]
    filters:
      - delayed_off: 200ms  
1 Like

Hey thanks for your help man. As odd as it may sound, while I already had full fledged home control using a phone app and voice, now I can do the same things using an IR remote control and it has a few members of my home finding it very useful and thrilling. :smiley:

I used ESPHome to call the services in HA to avoid cluttering my scriptis/ automations section in HA. So simple.

Would you mind sharing your esphome config for the ir reciever?

So my Panasonic remote is able to trigger the light on using this code,

binary_sensor:
  - platform: remote_receiver
    name: "Panasonic Power Button"
    panasonic:
      address: 0x4004
      command: 0x100BCBD
    filters:
      - delayed_off: 200ms
    on_press:
      then:
        - homeassistant.service:
            service: light.turn_on
            data: 
              entity_id: light.living_front_spot
1 Like

So, how did you find the code for each button, i mean which was the esphome code?

Did not get your question. The command in the above code corresponds to the IR code generated by the power button of the panasonic remote. You could of course use any remote, any button and the code thereof. And in the ön_press part you can define the HA action to be performed which again could be anything ranging from a simple command to a script or anything like that.

I believe the answer to the question is:

remote_receiver:
  pin:
    number: GPIO14
    inverted: true
    mode:
      input: true
      pullup: true
  dump: all

I just found this project interesting.
However, the question that I’m facing is that the regular remote (e.g. the same as your Panasonic), is sending only raw data that cannot be decoded. (this is seen by the longer dump all).
the problem is that the raw data is not the same every time, so no hard-coded values can be used.
I need to translate the values from the raw to rounded by filtering or something like this.
Has anyone manged to do it?

Hi Doron,
I set up a few IR receiver / transmitter in ESPHome and they work well!
I can attach the yaml code… if I can remember how.
The added advantage is I can point any IR remote at the receiver, and see the decoded results in the ESPHome logs in real time.
I add the decoded results to the receiver yaml, and when a code is recognised it is used to trigger an automation.
I set up the Red / Green / Yellow / Blue buttons on my Samsung and Channel Master remotes to trigger lighting and automations.
Red - goodnight automation
Green - low voltage knick knacks automation (IR candles and seasonal lighting)
Yellow - automation to shut off all seasonal lights and knick knacks
Blue - toggle the reading light over my wifes chair.

Hi, is there a way to make the same command repeat as long as the remote control button is pressed?

did you read this

I did this