-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwasserundgas.yaml
282 lines (261 loc) · 9.05 KB
/
wasserundgas.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
## ################################################################
## ESP32 DEV - GAS & WASSER 2021 - SENSOREN
## - GPIO12: Pulscounter Gaszähler
## - GPIO34: Druck Kaltwasser
## - GPIO17: Kaltwasser Temperatur
## ################################################################
substitutions:
device_id: "wasserundgas"
device_name: "wasserundgas"
device_name_short: "wasserundgas"
device_name_upper: "GWS"
update_interval: 60s
impulsfactor: "0.100"
platform: ESP32
board: esp32dev
attribution: "Data provided by Peter Siebler"
appversion: "1.0.4"
topic_prefix: "tele/wasserundgas"
topic_data: "tele/wasserundgas/data"
device_description: "Gaszähler Kaltwassertemperatur, Kaltwasserdruck"
esphome:
name: $device_name
comment: ${device_description}
platform: ${platform}
board: ${board}
arduino_version: recommended
project:
name: "ips.home"
version: ${appversion}
on_boot:
priority: -10
then:
- logger.log: "API is connected, Device ready!"
# ----------------------------------------------------------------
# Global variables
# ----------------------------------------------------------------
globals:
- id: z61count
type: int
restore_value: yes
initial_value: "0"
- id: z61counter
type: float
restore_value: yes
initial_value: "0.000"
- id: m3kw
type: float
restore_value: yes
initial_value: "10.94"
- id: gas_meter_displayvalue
type: float
restore_value: yes
initial_value: "29121.057"
- id: gas_meter_totalm3
type: float
restore_value: yes
initial_value: "0.000"
- id: daily_value
type: float
restore_value: yes
initial_value: "0.000"
# ----------------------------------------------------------------
# MQTT Client Component
# ----------------------------------------------------------------
# see: https://esphome.io/components/mqtt.html?highlight=mqtt
# inlude mqtt broker and wifi settings w/o api
# sets wifi, ap, domain, default logger, ota password, webserver
# time sntp, mqtt brocker.
<<: !include common/mqttonly.yaml
# ----------------------------------------------------------------
# Logger settings
# ----------------------------------------------------------------
logger:
level: INFO
logs:
mqtt.component: ERROR
mqtt.client: ERROR
# ----------------------------------------------------------------
# GPIO02: used for temperatur sensors data wired
# ----------------------------------------------------------------
dallas:
pin: GPIO17
update_interval: ${update_interval}
switch:
# Switch to restart
- platform: restart
name: ${device_name_upper} restart
# ----------------------------------------------------------------
# GASCOUNTER ZI-61 REED CONTACT
# ----------------------------------------------------------------
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: false
name: ${device_name_upper} Gaszähler Z-61 Impuls
id: gassensor_state
device_class: window
filters:
- delayed_off: 10ms
on_release:
then:
- lambda: |-
id(z61counter) += ${impulsfactor};
id(z61count) += 1;
id(gas_meter_totalm3) += ${impulsfactor};
id(gas_meter_displayvalue) += ${impulsfactor};
id(daily_value) += ${impulsfactor};
id(gas_meter_display).update();
id(gas_meter_total_m3).update();
id(gas_meter_total_kw).update();
id(gas_meter_total_kw_day).update();
# ----------------------------------------------------------------
# ALL SENSORS
# ----------------------------------------------------------------
sensor:
- platform: template
name: ${device_name_upper} Gaszähler Anzeige
id: gas_meter_display
accuracy_decimals: 3
unit_of_measurement: "m³"
icon: "mdi:counter"
state_topic: ${topic_prefix}/gas_meter_displayvalue
lambda: |-
return id(gas_meter_displayvalue);
- platform: template
name: ${device_name_upper} Gasverbrauch
id: gas_meter_total_m3
accuracy_decimals: 3
unit_of_measurement: "m³"
state_topic: ${topic_prefix}/gas_total_m3
lambda: |-
return id(gas_meter_totalm3);
- platform: template
name: ${device_name_upper} Gasverbrauch kW
id: gas_meter_total_kw
accuracy_decimals: 3
unit_of_measurement: "kW"
state_topic: ${topic_prefix}/gas_total_kw
lambda: |-
return (id(gas_meter_totalm3) * id(m3kw));
- platform: template
name: ${device_name_upper} Gasverbrauch heute
id: gas_meter_total_kw_day
unit_of_measurement: "kW"
lambda: |-
return (id(daily_value) * id(m3kw));
# -----------------------------------------------------
# DFRobot SEN0257 water pressure sensor 1 GPIO 34
# -----------------------------------------------------
- platform: adc
name: ${device_name_upper} Kaltwasser Wasserdruck
pin: GPIO34
id: coldwater_pressure
update_interval: 10s
unit_of_measurement: "bar"
accuracy_decimals: 2
attenuation: 11db
state_topic: ${topic_prefix}/coldwater_pressure
filters:
- lambda: |-
if(x-0.41<0) return 0.00;
return ((x) * 2.00) - 0.82;
# ------------------------------------------------------------------------------
# PIN GIPO17: DS18B20 Digital temperature sensor 1
# For this, connect a resistor of about 4.7KΩ (values around that like 1KΩ will,
# if you don’t have massively long wires, work fine in most cases)
# between 3.3V and the data pin.
# Unique ID: 'dallas-7900000C8579C728'
# ------------------------------------------------------------------------------
- platform: dallas
# index: 0
address: 0x7900000C8579C728
accuracy_decimals: 2
unit_of_measurement: "°C"
name: ${device_name_upper} Kaltwasser Temperatur
id: coldwater_temperature
icon: mdi:thermometer-lines
state_topic: ${topic_prefix}/coldwater_temperature
- platform: wifi_signal
id: wifisignal
name: ${device_name_upper} WiFi Signal
update_interval: 60s
# -----------------------------------------------
# additional sensors
# -----------------------------------------------
- platform: uptime
name: ${device_name_upper} Uptime Sensor
id: uptime_sensor
update_interval: ${update_interval}
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
on_value:
- mqtt.publish_json:
topic: "tele/wasserundgas/data"
payload: !lambda |-
root["name_pretty"] = "${device_name_upper}";
root["gas_meter_sensor"] = id(gassensor_state).state;
root["gas_display"] = id(gas_meter_display).state;
root["gas_meter_total_m3"] = id(gas_meter_total_m3).state;
root["gas_meter_total_kw"] = id(gas_meter_total_kw).state;
root["z61counter"] = id(z61counter);
root["z61count"] = id(z61count);
root["coldwater_pressure"] = isnan(id(coldwater_pressure).state)?0:id(coldwater_pressure).state;
root["coldwater_temperature"] = isnan(id(coldwater_temperature).state)?0:id(coldwater_temperature).state;
root["wifi_signal"] = id(wifisignal).state;
root["wif_iip"] = id(wifiip).state;
root["wifi_ssid"] = id(wifissid).state;
root["wifi_bssid"] = id(wifibssid).state;
root["version"] = id(appver).state;
root["timestamp"] = id(systime).state;
root["uptime"] = id(uptime_sensor).state;
root["uptime_human"] = id(uptime_human).state;
root["appversion"] = "${appversion}";
root["attribution"] = "${attribution}";
## -----------------------------------------------------------
## additional sensor data
## -----------------------------------------------------------
text_sensor:
- platform: version
name: ${device_name_upper} Version
id: appver
- platform: template
name: ${device_name_upper} Online seit
id: uptime_human
icon: mdi:clock-start
- platform: wifi_info
ip_address:
name: ${device_name_upper} IP
id: wifiip
icon: mdi:ip-network
ssid:
name: ${device_name_upper} SSID
id: wifissid
bssid:
id: wifibssid
name: ${device_name_upper} BSSID
- platform: template
name: ${device_name_upper} Timestamp
id: systime
lambda: char str[20];
time_t currTime = id(sntp_time).now().timestamp;
strftime(str, sizeof(str), "%Y-%m-%dT%H:%M:%S", localtime(&currTime));
return (std::string) str;