Templated gate beacon on_press and on_release
Some checks failed
CI / YAML lint (push) Has been cancelled
CI / ESPHome config validation (push) Has been cancelled

This commit is contained in:
2026-02-19 14:23:27 +01:00
parent 2ef5945c9f
commit a966f6adb4
3 changed files with 32 additions and 88 deletions

View File

@@ -0,0 +1,9 @@
- if:
condition:
and:
- switch.is_on: ${enable_id}
- switch.is_on: auto_close
- lambda: 'return id(beacon_count) == 1;'
then:
- button.press: gate_close
- lambda: 'id(beacon_count) -= 1;'

View File

@@ -0,0 +1,9 @@
- lambda: 'id(beacon_count) += 1;'
- if:
condition:
and:
- switch.is_on: ${enable_id}
- switch.is_on: auto_open
- lambda: 'return id(beacon_count) == 1;'
then:
- button.press: gate_open

View File

@@ -93,6 +93,12 @@ switch:
optimistic: true optimistic: true
restore_mode: RESTORE_DEFAULT_ON restore_mode: RESTORE_DEFAULT_ON
globals:
- id: beacon_count
type: int
restore_value: no
initial_value: '0'
esp32_ble_tracker: esp32_ble_tracker:
id: ${device}_ble_tracker id: ${device}_ble_tracker
scan_parameters: scan_parameters:
@@ -104,109 +110,29 @@ binary_sensor:
ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid
name: "Vehicle iBeacon Auris" name: "Vehicle iBeacon Auris"
timeout: 2min timeout: 2min
on_press: on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_auris}}
- if: on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_auris}}
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence - platform: ble_presence
id: ibeacon_yaris id: ibeacon_yaris
ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid
name: "Vehicle iBeacon Yaris" name: "Vehicle iBeacon Yaris"
timeout: 2min timeout: 2min
on_press: on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_yaris}}
- if: on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_yaris}}
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence - platform: ble_presence
id: ibeacon_pcx125 id: ibeacon_pcx125
ibeacon_uuid: !secret ble_beacon_honda_uuid ibeacon_uuid: !secret ble_beacon_honda_uuid
name: "Vehicle iBeacon Honda PCX125" name: "Vehicle iBeacon Honda PCX125"
timeout: 2min timeout: 2min
on_press: on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_pcx125}}
- if: on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_pcx125}}
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence - platform: ble_presence
id: ibeacon_dl650 id: ibeacon_dl650
ibeacon_uuid: !secret ble_beacon_suzuki_uuid ibeacon_uuid: !secret ble_beacon_suzuki_uuid
name: "Vehicle iBeacon Suzuki DL650" name: "Vehicle iBeacon Suzuki DL650"
timeout: 2min timeout: 2min
on_press: on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_dl650}}
- if: on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_dl650}}
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_close
- platform: gpio - platform: gpio
id: gate_ogi id: gate_ogi
pin: pin: