ESPHome Remote Transmitter - how to handle toggle codes?

Hi,

I’m trying to control a UPC MediaBox (that’s what they call it here in Poland). It’s a Pace DCR7111 STB.
The problem is that the remote and receiver use “toggle codes” (that’s what I’ve read they are called).
This means that it has 2 sets of codes for each button, and sends them alternately.
Like this:

452, -285, 161, -283, 163, -615, 163, -281, 162, -284, 158, -785, 161, -284, 161, -284, 161, -283, 162, -281, 161, -619, 160, -450, 158, -619, 162, -283, 159, -285, 161, -283, 163, -450, 160
436, -283, 165, -282, 162, -617, 159, -283, 163, -281, 160, -786, 159, -284, 162, -280, 165, -281, 162, -616, 161, -617, 161, -451, 160, -617, 163, -281, 163, -281, 161, -283, 164, -447, 164

Those are actually for a single button, and they differ by just 1 part (20th). Once it’s ~280 and once it’s ~610.

Providing just one of those codes reapeated results in the STB accepting just the first one. This makes it impossible to select for eg. channel 11, or send more than once channel up. And this basically makes the codes unusable in a standard way.

My question is: Is there a support for those toggle codes in ESPHome Remote Transmitter? If not then maybe someone found a walkaround to make use of them.

I haven’t tried yet if the code sequence is retained after stand by/power on cycle (which can complicate things even more).

Any help that gets me closer to a working remote for this device will be greatly appreciated.

P.S. This remote also works with UPC Horizon [rebranded Arris DMC7002KLG] (which by default ships with RF remote, but also accepts IR codes). And Horizon doesn’t care about those toggle codes, and works just fine, and I can send repeat commands however I want to it and it accepts them all.

1 Like

Ok. So far I’ve managed to produce something like this:

(...)

logger:
  level: VERY_VERBOSE

(...)

globals:
  - id: przycisk1_stan
    type: int
    restore_value: no
    initial_value: '1'

(...)

  - platform: template
    name: "UPC"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [ 436, -270, 175, -285, 158, -619, 159, -286, 157, -288, 158, -785, 158, -286, 157, -289, 156, -287, 158, -288, 159, -602, 174, -452, 158, -621, 157, -287, 159, -784, 159, -620, 157, -286, 162 ]

  - platform: template
    name: "Test"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: !lambda |-
            std::vector<int> kodPrzycisku;
            switch ( id(przycisk1_stan) ) {
              case '1': {
                id(przycisk1_stan) = '2';
                kodPrzycisku = { 452, -285, 161, -283, 163, -615, 163, -281, 162, -284, 158, -785, 161, -284, 161, -284, 161, -283, 162, -281, 161, -619, 160, -450, 158, -619, 162, -283, 159, -285, 161, -283, 163, -450, 160 };
              }
              case '2': {
                id(przycisk1_stan) = '1';
                kodPrzycisku = { 436, -283, 165, -282, 162, -617, 159, -283, 163, -281, 160, -786, 159, -284, 162, -280, 165, -281, 162, -616, 161, -617, 161, -451, 160, -617, 163, -281, 163, -281, 161, -283, 164, -447, 164 };
              }
            }
            return kodPrzycisku;

Button UPC:

[17:40:30][D][switch:029]: 'UPC' Toggling ON.
[17:40:30][VV][remote_base:063]: Sending times=1 wait=0ms: 436, -270, 175, -285, 158, -619, 159, -286, 157, -288, 158, -785, 158, -286, 157, -289, 156, -287, 158, -288, 159, -602, 174, -452, 158, -621, 157, -287, 159, -784, 159, -620, 157, -286, 162
[17:40:30][D][remote_transmitter:066]: Sending remote code...

Button Test:

[17:40:53][D][switch:029]: 'Test' Toggling ON.
[17:40:53][VV][remote_base:063]: Sending times=1 wait=0ms: 
[17:40:53][D][remote_transmitter:066]: Sending remote code...

Does anyone have any idea why Test sends empty code?

1 Like

I’ve finally made it work. Unfortunatelly the STB remembers on standby/power on cycle which code needs to be sent. So I’ll have to save states for used buttons in flash. But, it’s working.

If someone would need config for this…

(...)

esphome:
  esp8266_restore_from_flash: true

(...)

globals:
  - id: przycisk1_stan
    type: int
    restore_value: true
    initial_value: '1'

(...)

  - platform: template
    id: przyciskTest
    name: "Test"
    optimistic: true
    on_turn_on:
      then:
        - if:
            condition:
              lambda: 'return ( id(przycisk1_stan) == 1 );'
            then:
              - globals.set:
                  id: przycisk1_stan
                  value: '2'
              - remote_transmitter.transmit_raw:
                  carrier_frequency: 38kHz
                  code: [ 452, -285, 161, -283, 163, -615, 163, -281, 162, -284, 158, -785, 161, -284, 161, -284, 161, -283, 162, -281, 161, -619, 160, -450, 158, -619, 162, -283, 159, -285, 161, -283, 163, -450, 160 ]
              - switch.turn_off: przyciskTest
            else:
              - globals.set:
                  id: przycisk1_stan
                  value: '1'
              - remote_transmitter.transmit_raw:
                  carrier_frequency: 38kHz
                  code: [ 436, -283, 165, -282, 162, -617, 159, -283, 163, -281, 160, -786, 159, -284, 162, -280, 165, -281, 162, -616, 161, -617, 161, -451, 160, -617, 163, -281, 163, -281, 161, -283, 164, -447, 164 ]
              - switch.turn_off: przyciskTest
1 Like

Witaj kolego - Czy możesz odezwać się w tym wątku?