ESPHome IR Remote Component how to long-press?

Hello,
I use esphome+esp8266 to send infrared remote control signal, to control the temperature of electric water heater,

The machine is an ARISTON water heater (ARTES MED series). I don’t know the specific model.

I try to capture the IR code:

remote_receiver:
  pin: 
    number: GPIO14
    inverted: True
    mode: INPUT_PULLUP
  dump: all

short press:

[17:07:28][I][remote.jvc:049]: Received JVC: data=0x00F3
[17:07:28][I][remote.lg:054]: Received LG: data=0x00F36996, nbits=32
[17:07:28][I][remote.nec:097]: Received NEC: address=0xCF00, command=0x6996 command_repeats=1
[17:07:28][I][remote.pronto:233]: Received Pronto: data=
[17:07:28][I][remote.pronto:235]: 0000 006D 0022 0000 015E 00AD 0017 0015 0017 0015 0016 0015 0017 0015 0017 0015 0016 0015 0017 0015 0017 0015 0016 0041 0017 0040 0017 0041 0016 0042 0016 0015 0016 0015 0017 0041 0016 0042 0016 0015 0016 0042 0016 0040 0017 0016
[17:07:28][I][remote.pronto:235]: 0016 0040 0017 0016 0016 0015 0016 0042 0016 0041 0016 0016 0016 0016 0015 0042 0016 0016 0015 0042 0016 0041 0016 0016 0016 0181 06C3
[17:07:28][W][component:214]: Component remote_receiver took a long time for an operation (0.05 s).
[17:07:28][W][component:215]: Components should block for at most 20-30ms.
[17:07:28][I][remote.pronto:233]: Received Pronto: data=
[17:07:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3

long press for 5 seconds:

[17:08:25][I][remote.jvc:049]: Received JVC: data=0x00F3
[17:08:25][I][remote.lg:054]: Received LG: data=0x00F36996, nbits=32
[17:08:25][I][remote.nec:097]: Received NEC: address=0xCF00, command=0x6996 command_repeats=1
[17:08:25][I][remote.pronto:233]: Received Pronto: data=
[17:08:25][I][remote.pronto:235]: 0000 006D 0022 0000 015D 00AD 0017 0015 0017 0015 0016 0015 0017 0015 0017 0015 0016 0015 0017 0015 0017 0015 0016 0041 0017 0040 0017 0041 0016 0041 0017 0015 0016 0015 0017 0041 0016 0041 0017 0015 0016 0041 0017 0040 0017 0015
[17:08:25][I][remote.pronto:235]: 0017 0040 0017 0015 0017 0015 0016 0041 0017 0040 0017 0015 0017 0015 0016 0042 0016 0015 0016 0041 0017 0041 0016 0016 0016 0181 06C3
[17:08:25][W][component:214]: Component remote_receiver took a long time for an operation (0.05 s).
[17:08:25][W][component:215]: Components should block for at most 20-30ms.
[17:08:25][I][remote.pronto:233]: Received Pronto: data=
[17:08:25][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:25][I][remote.pronto:233]: Received Pronto: data=
[17:08:25][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:26][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:26][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:27][I][remote.pronto:233]: Received Pronto: data=
[17:08:27][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=
[17:08:28][I][remote.pronto:235]: 0000 006D 0002 0000 015D 0056 0017 0181 06C3
[17:08:28][I][remote.pronto:233]: Received Pronto: data=

I use this code to send IR signal:

switch:         
  - platform: template
    name: "ir_switch_test_01"
    id: "ir_switch_test_01"
    turn_on_action:
    - remote_transmitter.transmit_nec:
        address: 0xCF00
        command: 0x6996
        command_repeats: 1

But how can I send the “long-press” signal? Not multiple clicks.

update:

I found NEC Infrared Transmission Protocol ( https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol ), It explains how to deal with “If the key on the remote controller is kept depressed”, but I don’t know how to do this on esphome.

update:

Thanks everyone’s replys. I’m a beginner and I still can’t solve this problem in esphome, but I found it is very easy to do in Tasmota, just one command:

IRSend {"Protocol":"NEC","Bits":32,"Data":0xF36996,"Repeat":50}

or

IRSend50 {"Protocol":"NEC","Bits":32,"Data":0xF36996}

But I still wat to do it in esphome, and I will continue to look for ways.

You’ve provided very little info about your device.

IR doesn’t really have a long-press concept. Your original remote probably just sends a different code. Just capture that code — or find it on the Internet for your device.

Thanks for your reply, I added some information.

I’m working on a similar project and from what I understood in the ESPhome docs, you can’t. From the ESPhome Remote Receiver docs:
Each time the pre-defined signal is received, the binary sensor will briefly go ON and then immediately OFF.

The way I worked around it is to use delayed_off for the long press (in my case there was no difference between a long and short press)

binary_sensor:
  - platform: remote_receiver
    name: "Up"
    nec:
      address: 0x7878
      command: 0x936C
    filters:
      - delayed_off: 150ms

Thanks, I’m not too familiar with NEC itself, but perhaps you can use the output data and assemble it into a single hex string and transmit it with the RAW action instead.

Have a look at this: IR Remote and Receiver with Arduino Tutorial (4 Examples) (makerguides.com).

From the underlying Arduino lib’s docs:

NEC, NEC2

On a long press, the NEC protocol does not repeat its frame, it sends a special short repeat frame. This enables an easy distinction between long presses and repeated presses and saves a bit of battery energy. This behavior is quite unique for NEC and its derived protocols like LG and Samsung.

But of course there are also remote control systems, that uses the NEC protocol but only repeat the first frame when a long press is made instead of sending the special short repeat frame. We named this the NEC2 protocol and it is sent with sendNEC2().
But be careful, the NEC2 protocol can only be detected by the NEC library decoder after the first frame and if you do a long press!

This sounds suspiciously close to what I’m suggesting. :slight_smile:

it sends a special short repeat frame