ESPHome RF transceiver and rtl_433

Hey all,

I’ve successfully used my RTL_433 and rtl-sdr dongle to ‘learn’ my RC remote for my receiver. (PR pending: Add support for Hornbach MSRC-SAL Awning remote · oliv3r/rtl_433@c5fa403 · GitHub)

However, I want to now use esphome to transmit these codes (using one of those ubiquitous cheap transceivers). I first tried it the esphome way, by hooking up the receiver, and trying to ‘learn’ the codes that way; but there it came up as a ‘pronto’ protocol remote. E.g. an infrared remote. Maybe not quite unexpected, sending the same codes did not work.

So now that I’ve identified my signal properly, how can I ‘build’ it up in esphome? Must I write some C code for it (not a problem generally, but I’d like to avoid duplicating stuff). Or do I have to ‘re-code’ it from raw timing toggles …

Thanks

Please share the configuration you are using.

I’ll show you mine, if you show me yours!

Jokes aside, that’s kind of my question isn’t it. What should I put in my configuration.

decoder {
    name       = MSRC-SAL,
    modulation = OOK_PWM,
    bits       = 40,
    short      = 372,
    long       = 732,
    reset      = 7868,
    sync       = 4796,
    gap        = 1496,
    get        = RUID:@0:{32}:%x,
    get        = button:@32:{8}:[0x33:P2 0x3E:MODE 0xAA:STOP 0xC3:DOWN_(release) 0xCC:DOWN 0xE1 UP_(release) 0xEE:UP 0xF0:LIGHT],
}

in rtl_433 ‘slang’ is how what my protocol looks like.


remote_transmitter:
  pin:
    number: GPIO05
    ignore_strapping_warning: true
  carrier_duty_percent: 100%
  rmt_channel: 0

is my transmitter config,

button:
  - platform: template
    id: back_awning_stop
    on_press:
      - remote_transmitter.transmit_pronto: 
          data: "0000 006D 0029 0000 003B 001C 000D 000D 001C 000D 001C 001C 000D 000D 001C 000D 001C 001C 000D 000D 001C 000D 001C 000D 001C 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 000D 001C 000D 000D 001C 001C 000D 001C 000D 001C 000D 001C 000D 000D 001C 000D 001C 000D 001C 000D 001C 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 000D 000D 001C 001C 009B 06C3"

was my button, but I have doubts, and it also doesn’t work. Though I have learned one thing while writing my rtl_433 decoder, I need to repeat the signal at least 4 times. So I suppose I’ll just try again first, and see if my decoder actually picks it up.

That aside, knowing I have a properly decoded rtl_433 config, how would I get that into the rf_transmitter; short of writing a decoder (though I can imagine, having a decoder in esphome, that just takes a copy/paste of the rtl_433 conf is probably useful in itself.

Right so I worked around my problem in a true ugly hacking fashion :slight_smile: (where X is a probably unique per remote code …

  - platform: template
    id: back_awning_down
    on_press:
      - remote_transmitter.transmit_raw:
          code: [
            #     x   x    x    x    x    x    x    x    c    c
            # 0000 0000 0000 0000 0000 0000 0000 0000 1100 1100
            -1488, # Preamble, needed for ESPHome, not actually sent ...
            4836, -1488, # Sync pulse
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            372, -744, 372, -744, 744, -372, 744, -9300, # c -372 +
            # -1116, -7812, # Delimiter + Reset
          ]
          repeat:
            times: 4
            wait_time: 0s
      - remote_transmitter.transmit_raw:
          code: [ # Key release
            #     x   x    x    x    x    x    x    x    c    3
            # 0000 0000 0000 0000 0000 0000 0000 0000 1100 0011
            -1488, # Preamble, needed for ESPHome, not actually sent ...
            4836, -1488, # Sync pulse
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            744, -372, 744, -372, 744, -372, 744, -372, # x
            372, -744, 744, -372, 372, -744, 744, -372, # a
            372, -744, 372, -744, 744, -372, 744, -372, # c
            744, -372, 744, -372, 372, -744, 372, -9672, # 3 -744 +
            # -1116, -7812, # Delimiter + Reset
          ]
          repeat:
            times: 4
            wait_time: 0s

I’ll try to figure out what protocol this is, and see if a protocol decoder is similar in esphome for it and potentially add it. The fact that the codes had to be alternating was quite irritating.

The found protocol keys have been merged into rtl_433 repo so there’s that.

Not sure how helpful this is, but I made my own rf protocol and because I was also annoyed at having to add the minus sign every second value, I made a script that adds the signs before sending. It also does a few other things, so obv don’t just copy paste it haha. Nevertheless parts might be helpful. Anyway, here it is:

globals:
  - id: my_states_array
    type: std::vector<int>
    initial_value: '{500,333,333,333,333,333}'

script:
  - id: send_state
    then:
      - remote_transmitter.transmit_raw:
          code: !lambda |-
            std::vector<int> original_values = id(my_states_array); // Example values
            std::vector<int> transmit_values;
            bool make_negative = false;

            // Calculate the sum of all values in the array
            int sum_of_array = 0;
            for (int value : original_values) {
                sum_of_array += value;
            }
            
            // If the array length is an even number at this point, add the number (333) to the end
            if (original_values.size() % 2 == 0) {
                original_values.push_back(333);
            } 

            // Add the calculated value to the end of the array
            original_values.push_back((2000 - (sum_of_array % 2000)) * (make_negative ? -1 : 1));
            ESP_LOGD("main", "CheckSum: %i", (2000 - (sum_of_array % 2000)) * (make_negative ? -1 : 1));

            // Add the number (333 to the end)
            original_values.push_back(333);



            // Iterate over the original values, making every second value negative
            for (int value : original_values) {
                transmit_values.push_back(make_negative ? -value : value);
                make_negative = !make_negative; // Toggle the flag
            }

            // Now transmit the modified array
            return {transmit_values};           

Thanks! Yeah that would be a good start. I was looking at the rf-switch code, and the ‘raw protocol’ does similar things to what I want. But not quite.

So I’m currently playing with the thought, of maybe doing a ‘rtl_433 flex decoder conf’ protocol thing, which takes the flex protocol, and turns it into something esphome useful … Just a thought for now :slight_smile:

Just out of curiosity, what is the raw protocol missing?

for one, it enforces toggles. My protocol currently has a gap (low) followed followed by a ‘low - high’. I can encode this by just adding the lows, but it makes the data much harder to read, as I now have turned a bit, into a ‘high - (low + gap + sync)’.

So in my protocol, I found out that I have sync pulses, reset pulses, gaps, 0 and 1’s. Ideally I’d describe my message using these terms. Which is what the ‘rtl_433 flex decoder’ basically facilitates.

Hi @oliv3r

I am facing the same exact issues with the same remote control I have for the hornbach awning. Can you share your yaml file if you managed to integrate it in the esphome?

thanks in advance
George