I converted my Tasmota firmware to ESPHome. Here is a sample code for the Door and Motion Sensors, which are used in the template in Home Assistant, Got it from the following site.
# Door Sensor
- trigger:
- trigger: event
event_type: esphome.rf_code_received
event_data: #replace with your own
code: "004d6f3a"
id: "on"
- trigger: event
event_type: esphome.rf_code_received
event_data: #replace with your own
code: "004d6f3e"
id: "off"
binary_sensor:
- name: Front Door
device_class: door
state: "{{ trigger.id }}"
# The motion sensor needs to be reset after 5 seconds because it doesn't have off code
- trigger:
- trigger: event
event_type: esphome.rf_code_received
event_data: #replace with your own
code: "02ef451e"
id: "on"
- trigger: time_pattern
seconds: /5
id: "off"
binary_sensor:
- name: Motion Front Porch
device_class: motion
state: "{{ trigger.id }}"