forked from brianhanifin/esphome-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelly1_02.yaml
81 lines (71 loc) · 2.06 KB
/
shelly1_02.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
# Shelly 2 Power Module
# Location: Upstairs Bathroom
#
substitutions:
project: Shelly1 02
id: shelly1_02
humidity_threshold: "65.0"
<<: !include common/substitutions/gpio/shelly1.yaml
<<: !include common/esphome/esp8266.yaml
<<: !include common/common.yaml
script:
- id: relay_off_after_delay
then:
- if:
condition:
lambda: |-
return id(humidity).state < $humidity_threshold;
then:
# Turn off a manually turned on fan after 15 minutes, but only if humidity is below 50%.
- delay: 15min
- switch.turn_off: relay
else:
# No matter what, turn the fan off after an hour.
- delay: 60min
- switch.turn_off: relay
- id: relay_toggle
then:
if:
condition:
api.connected:
then:
- if:
condition:
switch.is_off: relay
then:
# Turn the relay on as requested.
- switch.turn_on: relay
- script.execute: relay_off_after_delay
else:
# Turn the switch off as requested.
- switch.turn_off: relay
else:
# When Home Assistant is unavailable, just toggle the relay.
- switch.toggle: relay
binary_sensor:
# Physical Toggle Switch. Monitor for switch position changes internally. Do not expose to Home Assistant.
- platform: gpio
pin:
number: $button_gpio
#name: $project Button
id: button
filters:
- delayed_on: 10ms
- delayed_off: 10ms
on_state:
- script.execute: relay_toggle
sensor:
# Monitor the humidity from Home Assistant.
- platform: homeassistant
id: humidity
entity_id: sensor.upstairs_bathroom_humidity
on_value_range:
- above: $humidity_threshold
then:
- switch.turn_on: relay
- below: $humidity_threshold
then:
- switch.turn_off: relay
switch:
<<: !include common/switches/relay.yaml