-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmartmeter.yaml
More file actions
197 lines (184 loc) · 5.26 KB
/
smartmeter.yaml
File metadata and controls
197 lines (184 loc) · 5.26 KB
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
# ESPHome configuration for the smartmeter project.
# https://esphome.io/index.html
esphome:
name: smartmeter
friendly_name: Smartmeter
area: Heating room
project:
name: "BlueAndi.smartmeter"
version: "0.3.0"
on_boot:
then:
# Restore the total pulses from the last session.
- pulse_meter.set_total_pulses:
id: power_consumption_home
value: !lambda "return id(total_pulses_home);"
- pulse_meter.set_total_pulses:
id: power_consumption_heatpump
value: !lambda "return id(total_pulses_heatpump);"
on_shutdown:
then:
# Save the total pulses to the global variable.
- globals.set:
id: total_pulses_home
value: !lambda 'return id(power_consumption_home).state;'
- globals.set:
id: total_pulses_heatpump
value: !lambda 'return id(power_consumption_heatpump).state;'
# Platform configuration.
# https://esphome.io/components/esp32.html
esp32:
board: esp32-poe-iso
framework:
type: arduino
# Enable logging.
# https://esphome.io/components/logger.html
logger:
level: DEBUG
# Enable Home Assistant API.
# https://esphome.io/components/api.html
api:
password: ""
reboot_timeout: 0s # If you enable MQTT and you do not use the Native API Component, you must set reboot_timeout: 0s, otherwise the ESP will reboot every 15 minutes because no client connected to the native API.
actions:
- action: set_total_home
variables:
new_total: int
then:
- pulse_meter.set_total_pulses:
id: power_consumption_home
value: !lambda 'return new_total;'
- action: set_total_heatpump
variables:
new_total: int
then:
- pulse_meter.set_total_pulses:
id: power_consumption_heatpump
value: !lambda 'return new_total;'
# Enable OTA updates.
# https://esphome.io/components/ota.html
ota:
- platform: esphome
password: ""
# Enable ethernet interface.
# https://esphome.io/components/ethernet.html
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk:
pin: GPIO17
mode: CLK_OUT
phy_addr: 0
power_pin:
number: GPIO12
ignore_strapping_warning: true
# Webserver configuration
# https://esphome.io/components/web_server.html
web_server:
port: 80
version: 3
sorting_groups:
- id: sg_power
name: "Power"
sorting_weight: 10
- id: sg_energy
name: "Energy"
sorting_weight: 20
- id: sg_config
name: "Configuration"
sorting_weight: 30
# MQTT configuration
mqtt:
broker: !secret mqtt_broker
port: 1883
username: !secret mqtt_user
password: !secret mqtt_password
reboot_timeout: 0s
birth_message:
topic: smartmeter/status
payload: "online"
will_message:
topic: smartmeter/status
payload: "offline"
# Global variables
# https://esphome.io/components/globals.html
globals:
- id: total_pulses_home
type: int
restore_value: yes
- id: total_pulses_heatpump
type: int
restore_value: yes
# Preferences
# https://esphome.io/components/esphome.html#adjusting-flash-writes
preferences:
flash_write_interval: 5min
# Sensor configuration
# https://esphome.io/components/sensor/index.html
sensor:
- platform: pulse_meter
pin: GPIO14
name: "Power Consumption Home"
id: power_consumption_home
unit_of_measurement: "W"
device_class: power
state_class: measurement
internal_filter: 200ms # Assuming maximum load of 16 kW and 1000 impulses per kWh, any pulses faster than 225 ms would exceed load. -10% ~= 20 ms.
accuracy_decimals: 0
filters:
- multiply: 60 # (60s / impulse constant) * (1000W / 1kW)
total:
name: "Energy Consumption Home"
web_server:
sorting_group_id: sg_energy
sorting_weight: 10
web_server:
sorting_group_id: sg_power
sorting_weight: 10
- platform: pulse_meter
pin: GPIO15
name: "Power Consumption Heatpump"
id: power_consumption_heatpump
unit_of_measurement: "W"
device_class: power
state_class: measurement
internal_filter: 200ms # Assuming maximum load of 16 kW and 1000 impulses per kWh, any pulses faster than 225 ms would exceed load. -10% ~= 20 ms.
accuracy_decimals: 0
filters:
- multiply: 60 # (60s / impulse constant) * (1000W / 1kW)
total:
name: "Energy Consumption Heatpump"
web_server:
sorting_group_id: sg_energy
sorting_weight: 20
web_server:
sorting_group_id: sg_power
sorting_weight: 20
# Button configuration
# https://esphome.io/components/button/index.html
button:
- platform: template
id: zero_power_consumption_home
name: "Reset power consumption home"
icon: mdi:button-pointer
on_press:
then:
- pulse_meter.set_total_pulses:
id: power_consumption_home
value: 0
web_server:
sorting_group_id: sg_config
sorting_weight: 10
- platform: template
id: zero_power_consumption_heatpump
name: "Reset power consumption heatpump"
icon: mdi:button-pointer
on_press:
then:
- pulse_meter.set_total_pulses:
id: power_consumption_heatpump
value: 0
web_server:
sorting_group_id: sg_config
sorting_weight: 20