-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtank_minder.yaml
144 lines (125 loc) · 3.55 KB
/
tank_minder.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
# -------------------------------------
# ---- Implemented on D1 mini on side of external water tank ----
# ---- v1.3
# -------------------------------------
substitutions:
devicename: tank_minder
esphome:
name: ${devicename}
platform: ESP8266
board: esp01_1m
wifi:
fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_tank_minder
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${devicename} Hotspot"
password: !secret password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s # Dont reboot..
encryption:
key: !secret encryption_key
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
i2c:
sda: GPIO4
scl: GPIO5
id: bus_a
# scan: True
ads1115: #https://esphome.io/components/sensor/ads1115.html
- address: 0x48
dallas:
- pin: GPIO12
# Used a '5V DC Pressure Transducer Sensor 0-1.2 MPa Oil Fuel Diesel Gas Water Air' = 174psi - 60PSI would prbably be ok but use a 100PSI just in case
sensor:
- platform: ads1115
id: adclevel
multiplexer: 'A0_GND'
# gain: 6.144 #(measures up to 6.144V)
# gain: 4.096 #(measures up to 4.096V) # Full hose pressure is around 3.1v (100PSI)
gain: 2.048 #(measures up to 2.048V) # Full hose pressure is just shy of 2v (1.2MPa)
# gain: 1.024 #(measures up to 1.024V)
# gain: 0.512 #(measures up to 0.512V)
# gain: 0.256 #(measures up to 0.256V)
name: "${devicename} Level"
icon: "mdi:cup-water"
accuracy_decimals: 0
unit_of_measurement: "L"
# update_interval: 2min
update_interval: 30s
filters:
- calibrate_linear: # https://esphome.io/components/sensor/index.html#sensor-filters
# - 0.490 -> 0.0 # Empty Value (100PSI)
# - 0.848 -> 3000.0 # Full Value (100PSI)
# - 0.542 -> 0.0 # Empty Value (1.2MPa)
- 0.560 -> 0.0 # Empty Value (1.2MPa)
- 0.605 -> 3000.0 # Full Value (1.2MPa)
# - median:
# window_size: 10
# send_every: 5
- platform: template
name: "${devicename} Status"
id: tankPer
update_interval: 2min
unit_of_measurement: '%'
icon: "mdi:water-percent"
accuracy_decimals: 0
lambda: |-
return ((id(adclevel).state / 3000) * 100.00);
on_value_range:
- above: 75.0
then:
- if:
condition:
- switch.is_off: override
then:
- switch.turn_off: relay
- logger.log: "The tank is full enough!"
- platform: dallas
address: 0xDE3C01D607548128
name: "${devicename} Temperature"
- platform: wifi_signal
name: ${devicename} wifi signal
update_interval: 60s
switch:
- platform: template
name: "${devicename} Fill Override"
id: override
optimistic: true
- platform: gpio
name: "${devicename} Fill Relay"
id: relay
pin:
number: GPIO13
inverted: false
on_turn_on:
then:
- if:
condition:
- lambda: 'return id(tankPer).state > 60;'
- switch.is_off: override
then:
- switch.turn_off: relay
- logger.log: "The tank is full enough!"
- delay: 2s
- switch.turn_off: relay
else:
- delay: 1h
- switch.turn_off: relay
- logger.log: "Relay was on for an hour!"