-
Notifications
You must be signed in to change notification settings - Fork 1
/
ESP home code.yaml
164 lines (138 loc) · 3.19 KB
/
ESP home code.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
esphome:
name: flaura1
#power on moisture sensor when not sleeping
on_boot:
priority: 90
then:
- output.turn_on: moist_power
- logger.log: "boot delay"
- lambda: |-
delay(30000);
esp32:
board: esp-wrover-kit
framework:
type: arduino
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
encryption:
key: "key"
ota:
password: "password"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Flaura1 Fallback Hotspot"
password: "password"
deep_sleep:
run_duration: 10h
id: deep_sleep1
wakeup_pin:
number: GPIO00
inverted: true
#def power pin for moisture sensor
output:
- platform: gpio
id: moist_power
pin: 19
#water level config
binary_sensor:
- platform: gpio
pin: 35
name: lvl_gnd
- platform: gpio
pin:
number: 25
name: lvl_empty
filters:
- invert:
- delayed_on_off: 100ms
# on_click:
# min_length: 5s
# then:
# -logger.log: "no water. Going to sleep"
# - deep_sleep.enter:
# id: deep_sleep1
# sleep_duration: 1min
- platform: gpio
pin:
number: 26
name: lvl_warning
filters:
- delayed_on_off: 100ms
- invert:
#moisture sensor config
sensor:
- platform: adc
pin: GPIO33
id: "Moisture_flaura1"
update_interval: 2s
name: "Moisture flaura1"
# unit_of_measurement: "%"
#Running median of moisture and mapping of values to 0-100 scale
# filters:
# - median:
# window_size: 7
# send_every: 5
# send_first_at: 4
# - calibrate_linear:
# - 0.87 -> 0
# - 1.033-> 100
# - lambda: |-
# return ((id(Moisture_flaura1).state - 0.875) * -613.49);
on_value_range:
- below: 1
then:
- logger.log: "moist enough. Sleeping for 1 minute"
- output.turn_off: moist_power
- deep_sleep.enter:
id: deep_sleep1
sleep_duration: 1 min
- above: 1
then:
- logger.log: "not moist enough. watering"
- output.turn_off: moist_power
- switch.turn_on: pump
- delay: 3s
- switch.turn_off: pump
- logger.log: "naptime."
- deep_sleep.enter:
id: deep_sleep1
sleep_duration: 1 min
- platform: adc
pin: GPIO 32
id: "battery_level"
internal: true
- platform: template
name: "flaura1 charge level"
unit_of_measurement: '%'
update_interval: 1s
filters:
#not sure about the calibration, haven't tested it.
- calibrate_linear:
- 0.02 -> 0.00
- 0.65 -> 100.00
# lambda: |-
# return ((id(battery_level).state /3.70) * 100.00);
switch:
- platform: gpio
pin: GPIO 23
name: "Pump"
id: pump
inverted: true
cover:
- platform: template
name: "pump"
open_action:
# Cancel any previous action
- switch.turn_off: pump
# Turn the OPEN switch on briefly
- switch.turn_on: pump
- delay: 30s
- switch.turn_off: pump
close_action:
- switch.turn_off: pump