Skip to content

Instantly share code, notes, and snippets.

@0x3333
Created July 14, 2025 18:12
Show Gist options
  • Save 0x3333/f5b04b9e4523cc14891581cfadd6648f to your computer and use it in GitHub Desktop.
Save 0x3333/f5b04b9e4523cc14891581cfadd6648f to your computer and use it in GitHub Desktop.
ESPHome Binary sensor from RF Bridge

This is a way to have a binary sensor from a single code in the RF Bridge in ESPHome.

We have a binary_delay to configure the delay between on/off in the binary sensor. some_sensor is a template(dummy) Binary sensor that gets updated by the RF Bridge when a code is received.

The action is a script, so if multiple codes are received, the timer counts againts the last one.

number:
- platform: template
id: binary_delay
name: Binary Delay
unit_of_measurement: "s"
device_class: duration
step: 1
min_value: 1
max_value: 999
optimistic: true
initial_value: 30
restore_value: true
binary_sensor:
- platform: template
id: some_sensor
name: "Some Sensor"
publish_initial_state: true
script:
- id: some_sensor_script
mode: restart
then:
- binary_sensor.template.publish:
id: some_sensor
state: true
- delay: !lambda 'return id(movimento_delay).state * 1000;'
- binary_sensor.template.publish:
id: some_sensor
state: false
rf_bridge:
on_code_received:
then:
- if:
condition:
lambda: 'return data.code == 0xAABBCC;'
then:
- script.execute: some_sensor_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment