-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatermeter.yaml
95 lines (85 loc) · 2.57 KB
/
watermeter.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
substitutions:
device_name: "Water Meter"
espname: "watermeter"
esphome:
name: '${espname}'
comment: 'nodemcuv2'
esp8266:
board: nodemcuv2
restore_from_flash: true
wifi:
use_address: 10.0.30.105
# Enable logging
logger:
packages:
wifi: !include /config/esphome/common/wifi.yaml
network_diagnostics: !include /config/esphome/common/network_diagnostics.yaml
base_config: !include /config/esphome/common/base_config.yaml
# Enable Home Assistant API
api:
services:
- service: set_total
variables:
new_total: int
then:
- pulse_meter.set_total_pulses:
id: pulse_meter_water_usage
value: !lambda 'return new_total;'
# Water Meter Pulse Counter Logic Overview:
#
# This setup uses two metal detectors, each connected to an ESP8266 GPIO pin. The detectors
# monitor a spinner in the water meter, with each rotation indicating 1 liter of water usage,
# generating four edges (two ON and two OFF states).
#
# Each rising edge (OFF to ON) from the detectors triggers a brief ON-OFF pulse via a template
# binary sensor and a corresponding GPIO output. This output pulse is wired directly to another
# GPIO input pin on the same ESP device.
#
# The input GPIO is connected to a pulse meter sensor that counts these pulses, translating
# each pulse to a liter of water used. The system reports real-time and total water usage to
# Home Assistant, ensuring accurate tracking with minimal physical modifications.
output:
- platform: gpio
pin: D2
id: combine_pulse_output # GPIO pin to output combined pulse signals.
binary_sensor:
- platform: gpio
id: metal_detector_1
pin: D1
name: "Metal Detector 1"
filters:
- delayed_on: 10ms
on_state:
then:
- binary_sensor.template.publish:
id: combined_pulses
state: ON
- output.turn_on: combine_pulse_output
- delay: 50ms
- binary_sensor.template.publish:
id: combined_pulses
state: OFF
- output.turn_off: combine_pulse_output
- platform: template
name: ${device_name} Pulses
id: combined_pulses
sensor:
- platform: pulse_meter
id: pulse_meter_water_usage
name: Water Usage
pin: D3
timeout: 2.5 min
unit_of_measurement: 'L/min'
accuracy_decimals: 2
icon: mdi:waves-arrow-right
filters:
- multiply: 0.5
total:
name: "Total Water"
device_class: water
unit_of_measurement: 'L'
state_class: 'measurement'
accuracy_decimals: 0
icon: mdi:water
filters:
- multiply: 0.5