Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####################################################################
- # Template Binary Sensor
- # see https://esphome.io/components/binary_sensor/template.html
- # value TRUE => fallback automation is active
- # sensor for fallback automation of PIR01
- - platform: template
- name: ${binary_template_sensor_01_name}
- id: ${binary_template_sensor_01_id}
- # sensor for fallback automation of PIR02
- - platform: template
- name: ${binary_template_sensor_02_name}
- id: ${binary_template_sensor_02_id}
- ####################################################################
- # PIR
- - platform: gpio
- name: $pir01_name
- id: ${pir01_id}
- pin:
- mcp23017: ${mcp23017_hub01_id}
- number: !secret MCP23017_PIN_A0
- # mode can be INPUT, INPUT_PULLUP or OUTPUT
- mode: INPUT
- inverted: false
- device_class: motion
- # fallback automation while the device is offline:
- on_press:
- then:
- - lambda: |-
- if (!id(${wifi_status_id}).state) {
- id(${binary_template_sensor_01_id}).publish_state(true);
- id(${ssr01_id}).turn_on();
- }
- - delay: !secret DELAY_01MIN
- - lambda: |-
- if (id(${binary_template_sensor_01_id}).state) {
- id(${ssr01_id}).turn_off();
- id(${binary_template_sensor_01_id}).publish_state(false);
- }
- - platform: gpio
- name: $pir02_name
- id: ${pir02_id}
- pin:
- mcp23017: ${mcp23017_hub01_id}
- number: !secret MCP23017_PIN_A1
- # mode can be INPUT, INPUT_PULLUP or OUTPUT
- mode: INPUT
- inverted: false
- device_class: motion
- # fallback automation while the device is offline:
- # - the impuls from the PIR is short
- # - race condition seem to occur
- # - to be observed weird behaviour when motion appears seemingly repeatedly during the delay
- on_press:
- then:
- - lambda: |-
- if (!id(${wifi_status_id}).state) {
- if (!id(${ssr01_id}).state) {
- id(${binary_template_sensor_01_id}).publish_state(true);
- id(${ssr01_id}).turn_on();
- }
- }
- - delay: !secret DELAY_01MIN
- - lambda: |-
- if (id(${binary_template_sensor_01_id}).state) {
- id(${ssr01_id}).turn_off();
- id(${binary_template_sensor_01_id}).publish_state(false);
- }
RAW Paste Data