Skip to content

Instantly share code, notes, and snippets.

@cadavre
Created April 23, 2021 20:05
Show Gist options
  • Save cadavre/1c4fe17e9f7d831080c5b6dd73b47930 to your computer and use it in GitHub Desktop.
Save cadavre/1c4fe17e9f7d831080c5b6dd73b47930 to your computer and use it in GitHub Desktop.
Garage parking sensor for ESP32
esphome:
name: garage_hub
platform: ESP32
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_user
password: !secret mqtt_password
logger:
level: INFO
ota:
password: !secret ota_password
switch:
- platform: gpio
id: ledr
pin: GPIO25
- platform: gpio
id: ledg
pin: GPIO26
sensor:
- platform: ultrasonic
id: parking
update_interval: 100ms
echo_pin: GPIO12
trigger_pin: GPIO13
filters:
- median:
window_size: 4
send_every: 4
send_first_at: 1
on_raw_value:
- if:
condition:
- sensor.in_range:
id: parking
below: 1.4
above: 0.2
- not:
for:
time: 20s
condition:
sensor.in_range:
id: parking
below: 0.2
then:
- switch.turn_off:
id: ledr
- switch.toggle:
id: ledg
- if:
condition:
- sensor.in_range:
id: parking
below: 0.2
above: 0.14
- not:
for:
time: 20s
condition:
sensor.in_range:
id: parking
below: 0.2
then:
- switch.turn_off:
id: ledr
- switch.turn_on:
id: ledg
- if:
condition:
- sensor.in_range:
id: parking
below: 0.14
- not:
for:
time: 20s
condition:
sensor.in_range:
id: parking
below: 0.2
then:
- switch.turn_off:
id: ledg
- switch.turn_on:
id: ledr
- if:
condition:
for:
time: 20s
condition:
sensor.in_range:
id: parking
below: 0.2
then:
- switch.turn_off:
id: ledr
- switch.turn_off:
id: ledg
on_value_range:
- above: 1.4
then:
- switch.turn_off:
id: ledr
- switch.turn_off:
id: ledg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment