ESPhome and custom transmitter protocol

Hello. I would like to use blinds controlled by 433MHz transmitter. The control protocol has quite complicated timing and I was only able to get it working by modification of C++ program at markisol/Markisol.ino at 9cc13ec5d3d22195338b0c3d53bc853951cf1b29 · akirjavainen/markisol · GitHub . I also have some complicated logic already created in ESPhome like checking for sun elevation and wind forecast. Now I would like to incorporate that .ino program into esphome yaml. I know it is possible, I can do lots of lambdas in C++, but I never succeded with C++ function definitions in esphome. Is there any tutorial or examples how to include whole .ino standalone program into esphome? Thank you very much!

Continuation: I was able to include .ino program as .h in esphome .yaml. I included definition of custom component in yaml:

- lambda: |-
    auto my_custom = new MyCustomComponent();
    return {my_custom};

Now if I put any commands (transmissions) in loop() of that .h, then it is performed. However, if I call function in loop() of .h file like:


how do I call that function on yaml? I tried:

    priority: -100
      - lambda: sendMarkisolCommand(SHADE_DOWN_EXAMPLE);
      - delay: 3s
      - lambda: sendMarkisolCommand(SHADE_STOP_EXAMPLE);

But this does not call function defined in .h file. I also tried

- lambda: my_custom.sendMarkisolCommand(SHADE_DOWN_EXAMPLE);


- lambda: custom_component.sendMarkisolCommand(SHADE_DOWN_EXAMPLE);

but getting errors.

So how do I call function defined in .h file from lambda in .yaml?


Wish I could help, but I am replying because that is the only way I can see to follow the thread, and I am interested in the answer.

Under topic controls at the bottom of the page choose Watching, it saves unnecessary commenting :slight_smile:

In answer to the first poster, the examples here can be useful. DIY Examples — ESPHome

The workaround: I programmed Wemos D1 mini in Arduino IDE and I am triggering functions by pin interrupt. That Wemos have hardware transmitter connected to one of pins.

Then I wired that Wemos interrupt pins to ESP32 gpio pins and program that ESP32 with esphome and I control pins there.

Very ugly solution but it took me 10 minutes vs. hours of my life figuring out how to run C++ custom functions in esphome.

Finally solved it. Actually, if you define just plain function in .h file, then you can use that function in lambda. I first had troubles with nested functions like this one:

int add3(int x) {
    return x+multiplier();

int multiplier() {
  return 3;

because I was getting error that multiplier() is not defined. However, after changing order it started to work:

int multiplier() {
  return 3;

int add3(int x) {
    return x+multiplier();

So I had to reblock my big .h file in the way that no function or constant could be used before there was definition of it. Then it all worked fine.