How to control IR fan with ESPHome

Hello,
Please help me. This is my first post. I am not 100% sure that this is the right forum to post this. I am trying to make a esphome IR blaster to control my IR fan. The Fan remote has two buttons we use
1, On/Speed
2, Off.

First button will cycle between 3 speeds.
Second button will turn off the fan.

When i recorded the IR codes the remote send, i noticed that first button sends same code every time.

I tried to make yml file. but how can i just make two push buttons one for ON and OFF in the UI. Cant use switches.

Why can’t use switches?

Please share relevant yaml code.

I dont have the code now,
If i use switch, Hass uses toggle switch.
for this fan needs a push button pressing on it will turn on or change speeds.

ESPHome does not have push buttons.
The way it usually works is a switch that goes off by itself.
You’ll have to look into home assistant love lace thing to do a push button ui
By default remote switches does this

The problem with this type of rf remote is that it is stateless, in that home assistant gets no feedback as to what the speed is. You’ll have to keep that in an input_number https://www.home-assistant.io/components/input_number/

Then you can write a script that looks at the input number and decides what to transmit depending what speed you request. Then combine it all in a template fan https://www.home-assistant.io/components/fan.template/