-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarten-wasserzahler.yaml
117 lines (105 loc) · 2.62 KB
/
garten-wasserzahler.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
esphome:
name: garten-wasserzahler
friendly_name: Garten Wasserzähler
on_boot:
then:
- pulse_meter.set_total_pulses: # restore pulses
id: pulse_meter_id
value: !lambda 'return id(g_total_pulses);'
- sensor.template.publish: # restore today
id: today
state: !lambda 'return id(g_water_daily);'
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxx"
ota:
- platform: esphome
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Garten-Wasserzahler"
captive_portal:
web_server:
port: 80
preferences:
flash_write_interval: 3h
globals:
- id: g_total_pulses
type: int
restore_value: true
initial_value: "1125000"
- id: g_water_daily
type: float
restore_value: true
initial_value: "0.0"
sensor:
- platform: pulse_meter
id: pulse_meter_id
internal_filter: 100ms
pin:
number: 13 # D13
inverted: true
mode:
input: true
pullup: true # Anschluss zwischen Pin und GND
name: "Durchfluss"
icon: "mdi:water"
unit_of_measurement: "L/h"
state_class: "measurement"
device_class: "volume_flow_rate"
timeout: 20s
accuracy_decimals: 0
filters:
- multiply: 30
total:
name: "Gesamt"
id: gesamt_id
icon: "mdi:water-circle"
unit_of_measurement: "L"
state_class: "total_increasing"
device_class: "water"
accuracy_decimals: 1
filters:
- multiply: 0.5
on_raw_value: # ignore filters
then:
- globals.set:
id: g_total_pulses
value: !lambda 'return id(gesamt_id).raw_state;'
- globals.set: # increase global today by 0.5 L per pulse
id: g_water_daily
value: !lambda 'return id(today).state + 0.5;'
- sensor.template.publish: # increase today by 0.5 L per pulse
id: today
state: !lambda 'return id(today).state + 0.5;'
- platform: template
name: "Heute"
id: today
icon: "mdi:water-plus"
unit_of_measurement: "L"
device_class: "water"
time:
- platform: homeassistant
id: homeassistant_time
on_time:
# Midnight
- seconds: 0
minutes: 0
hours: 0
then:
- sensor.template.publish: # reset today
id: today
state: 0
- globals.set: # reset global today
id: g_water_daily
value: "0.0"