Hi I need help with code. On ESP I have 2 sensors Microwave body and PIR sensor.
I and make Automation when both detect movement active buzzer start bip…
How to make this code shorter and last part buzzing to reppet. Maybe script for automation?
Some suggestion? This code work but I think must be better way to do this…
Thanks!
binary_sensor:
# Microwave Sensor
- platform: gpio
pin: D2
id: wave_motion
name: "SensorNode Microwave"
device_class: motion
# PIS Sensor
- platform: gpio
pin: D6
id: pir_motion
name: "SensorNode PIR"
device_class: motion
# Buzzer
switch:
- platform: gpio
pin: D5
name: "Biping"
id: bip
icon: "mdi:bullhorn-outline"
# Biping patern
- platform: template
name: "Bip patern"
id: biping
turn_on_action:
- while:
condition:
lambda: 'return true;'
then:
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 1500ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 1500ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
# after this repeat only bottom of this
- delay: 1500ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
- switch.turn_on: bip
- delay: 50ms
- switch.turn_off: bip
- delay: 50ms
turn_off_action:
- switch.turn_off: bip
```