253 lines
6 KiB
YAML
253 lines
6 KiB
YAML
esphome:
|
|
name: "wohnungstuer"
|
|
friendly_name: "Wohnungstür"
|
|
|
|
api:
|
|
encryption:
|
|
key: !secret apikey_wohnungstuer
|
|
|
|
ota:
|
|
- platform: esphome
|
|
password: !secret otapass_wohnungstuer
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid_bw
|
|
password: !secret wifi_password_bw
|
|
domain: .iot.bw.jalr.de
|
|
|
|
esp32_ble_tracker:
|
|
scan_parameters:
|
|
active: false
|
|
|
|
bluetooth_proxy:
|
|
active: true
|
|
|
|
xiaomi_ble:
|
|
|
|
esp32:
|
|
board: esp32doit-devkit-v1
|
|
framework:
|
|
type: arduino
|
|
version: recommended
|
|
|
|
logger:
|
|
|
|
sensor:
|
|
- platform: wifi_signal
|
|
name: "WiFi Signal Sensor"
|
|
update_interval: 60s
|
|
|
|
globals:
|
|
- id: leaving
|
|
type: int
|
|
restore_value: no
|
|
initial_value: '0'
|
|
|
|
binary_sensor:
|
|
- platform: template
|
|
name: "At home"
|
|
id: presence
|
|
device_class: presence
|
|
- platform: gpio
|
|
name: Tür
|
|
id: door
|
|
pin:
|
|
number: GPIO32
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
filters:
|
|
- delayed_on_off: 1s
|
|
device_class: door
|
|
on_press: # on opening door
|
|
then:
|
|
- lambda: |-
|
|
id(leaving) |= 1;
|
|
- if:
|
|
condition:
|
|
# bowl is occupied
|
|
binary_sensor.is_on: key_bowl
|
|
then:
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: strobe_red
|
|
- script.execute:
|
|
id: beep
|
|
on_ms: 250
|
|
off_ms: 250
|
|
|
|
else:
|
|
- if:
|
|
condition:
|
|
binary_sensor.is_off: presence # when away
|
|
then:
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: "None"
|
|
red: 75%
|
|
green: 25%
|
|
|
|
on_release: # on closing door
|
|
then:
|
|
- if:
|
|
condition:
|
|
binary_sensor.is_off: presence # when away
|
|
then:
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: "scan"
|
|
red: 0%
|
|
green: 0%
|
|
blue: 100%
|
|
- script.execute:
|
|
id: beep
|
|
on_ms: 100
|
|
off_ms: 1000
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(leaving) == 3;
|
|
then:
|
|
- light.turn_off:
|
|
id: pixels
|
|
- script.stop: beep
|
|
- switch.turn_off: buzzer
|
|
- binary_sensor.template.publish: # set away state
|
|
id: presence
|
|
state: OFF
|
|
else:
|
|
- if:
|
|
condition:
|
|
# when keys are in the bowl
|
|
binary_sensor.is_on: key_bowl
|
|
then:
|
|
- script.stop: beep
|
|
- switch.turn_off: buzzer
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: "None"
|
|
red: 0%
|
|
green: 50%
|
|
blue: 0%
|
|
- delay: 30s
|
|
- light.turn_off:
|
|
id: pixels
|
|
transition_length: 3s
|
|
- lambda: |-
|
|
id(leaving) = 0;
|
|
- if:
|
|
condition:
|
|
binary_sensor.is_on: presence # when at home
|
|
then:
|
|
- light.turn_off:
|
|
id: pixels
|
|
- script.stop: beep
|
|
- switch.turn_off: buzzer
|
|
|
|
- platform: gpio
|
|
name: Schlüsselschale
|
|
id: key_bowl
|
|
pin:
|
|
number: GPIO23
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
device_class: occupancy
|
|
filters:
|
|
- invert:
|
|
- delayed_on_off: 250ms
|
|
on_press: # when keys fall in bowl
|
|
then:
|
|
- binary_sensor.template.publish: # set at home state
|
|
id: presence
|
|
state: ON
|
|
- lambda: |-
|
|
id(leaving) = 0;
|
|
- if:
|
|
condition:
|
|
# door is closed
|
|
binary_sensor.is_off: door
|
|
then:
|
|
- script.stop: beep
|
|
- switch.turn_off: buzzer
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: "None"
|
|
red: 0%
|
|
green: 50%
|
|
blue: 0%
|
|
- delay: 30s
|
|
- light.turn_off:
|
|
id: pixels
|
|
transition_length: 3s
|
|
on_release: # when keys are removed from bowl
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(leaving) == 1;
|
|
then:
|
|
- light.turn_off:
|
|
id: pixels
|
|
- script.stop: beep
|
|
- switch.turn_off: buzzer
|
|
- lambda: |-
|
|
id(leaving) |= 2;
|
|
- if:
|
|
condition:
|
|
# door is closed
|
|
binary_sensor.is_off: door
|
|
then:
|
|
- light.turn_on:
|
|
id: pixels
|
|
effect: "rainbow"
|
|
|
|
light:
|
|
- platform: esp32_rmt_led_strip
|
|
id: pixels
|
|
rgb_order: GRB
|
|
pin: GPIO12
|
|
num_leds: 5
|
|
rmt_channel: 0
|
|
chipset: ws2812
|
|
effects:
|
|
- strobe:
|
|
name: strobe_red
|
|
colors:
|
|
- state: true
|
|
brightness: 100%
|
|
red: 100%
|
|
green: 0%
|
|
blue: 0%
|
|
duration: 250ms
|
|
- state: false
|
|
duration: 250ms
|
|
- addressable_rainbow:
|
|
name: rainbow
|
|
speed: 20
|
|
width: 10
|
|
- addressable_scan:
|
|
name: scan
|
|
move_interval: 20ms
|
|
scan_width: 1
|
|
|
|
switch:
|
|
- platform: gpio
|
|
pin: GPIO22
|
|
id: buzzer
|
|
|
|
script:
|
|
- id: beep
|
|
mode: restart
|
|
parameters:
|
|
on_ms: int
|
|
off_ms: int
|
|
then:
|
|
- while:
|
|
condition:
|
|
lambda: 'return true;'
|
|
then:
|
|
- switch.turn_on: buzzer
|
|
- delay: !lambda return on_ms;
|
|
- switch.turn_off: buzzer
|
|
- delay: !lambda return off_ms;
|