forked from klaasnicolaas/home-assistant-glow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
energy.yaml
228 lines (205 loc) · 5.57 KB
/
energy.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
substitutions:
device_name: energy
friendly_name: Verbrauch
project_version: "1.2.0"
device_description: "Measure your electricity consumption with the pulse LED on your smart meter and gas consumption with reed contact on your gas meter"
# Define the GPIO pins
pulse_pin_gas: GPIO5 #D1
pulse_pin_electricity: GPIO4 #D2
status_led: GPIO2 #D4 onboard LED
led_pin_electricity: GPIO12 #D6
led_pin_gas: GPIO13 #D7
# Webserver credentials #
web_username: 'energy'
web_password: !secret web_password
dashboard_import:
package_import_url: github://akula3/energy/energy.yaml
esphome:
name: '${device_name}'
comment: '${device_description}'
project:
name: "akula3.energy"
version: "${project_version}"
# Choose the right Platform
# esp32: https://esphome.io/components/esp32.html
# esp8266: https://esphome.io/components/esp8266.html
esp8266:
board: d1_mini
# WiFi credentials #
wifi:
ssid: !secret wifi_ssid # Enter your WiFi SSID here. Example: `ssid: 'your_network_name'`
password: !secret wifi_password # Enter your wifi password here. Example: `password: 'abcde123456'`
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: '${device_name}'
captive_portal:
# Enable logging
logger:
# Enable improv over serial
#improv_serial:
# Enable Home Assistant API
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
safe_mode: true
reboot_timeout: 10min
num_attempts: 5
web_server:
port: 80
auth:
username: '${web_username}'
password: '${web_password}'
# Sensors for ESP version and WIFI information
text_sensor:
# Installed version
- platform: template
name: "${device_name} - Installed version"
id: energy_version
icon: "mdi:label-outline"
entity_category: diagnostic
lambda: |-
return {"${project_version}"};
update_interval: 6h
# ESPHome version
- platform: version
hide_timestamp: true
name: '${device_name} - ESPHome Version'
# IP address and connected SSID
- platform: wifi_info
ip_address:
name: '${device_name} - IP Address'
icon: mdi:wifi
ssid:
name: '${device_name} - Connected SSID'
icon: mdi:wifi-strength-2
output:
- platform: gpio
pin: ${led_pin_electricity}
id: output_electricity
- platform: gpio
pin: ${led_pin_gas}
id: output_gas
# Status LED for connection
status_led:
pin:
# Blue LED
number: ${status_led}
button:
# Restart the ESP
- platform: restart
name: "${device_name} - Restart Device"
globals:
# Electricity pulse rate, imp/kWh
- id: electricity_pulse_rate
type: int
restore_value: true
initial_value: '500'
# Gas Puls rate, imp/m³
- id: gas_pulse_rate
type: int
restore_value: true
initial_value: '100'
binary_sensor:
- platform: gpio
id: internal_pulse_counter_electricity
pin:
number: ${pulse_pin_electricity}
inverted: true
name: "Strom Live-Impuls"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_on: output_electricity
on_release:
then:
- output.turn_off: output_electricity
- platform: gpio
id: internal_pulse_counter_gas
pin:
number: ${pulse_pin_gas}
mode: INPUT_PULLUP
inverted: true
name: "Gas Live-Impuls"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_on: output_gas
on_release:
then:
- output.turn_off: output_gas
sensor:
# WiFi signal
- platform: wifi_signal
name: "${device_name} - WiFi Signal"
update_interval: 120s
# Electricity Pulse meter
- platform: pulse_meter
name: 'Strom ${friendly_name}'
id: sensor_electricity_pulse_meter
unit_of_measurement: 'W'
state_class: measurement
device_class: power
icon: mdi:flash-outline
accuracy_decimals: 0
pin: ${pulse_pin_electricity}
# internal_filter: 100ms
filters:
# multiply value = (60 / imp value) * 1000
# - multiply: 60
- lambda: |-
return x * ((60.0 / id(electricity_pulse_rate)) * 1000.0);
total:
name: 'Strom ${friendly_name} gesamt'
id: sensor_electricity_total_energy
unit_of_measurement: 'kWh'
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# multiply value = 1 / imp value
# - multiply: 0.002
- lambda: |-
return x * (1.0 / id(electricity_pulse_rate));
# Gas Pulse meter
- platform: pulse_meter
name: 'Gas ${friendly_name}'
id: sensor_gas_pulse_meter
unit_of_measurement: 'm³/h'
state_class: measurement
device_class: gas
icon: mdi:fire
accuracy_decimals: 2
pin:
number: ${pulse_pin_gas}
mode: INPUT_PULLUP
inverted: true
internal_filter_mode: PULSE
internal_filter: 500ms
filters:
# multiply value = 60 / imp value
# - multiply: 60
- lambda: |-
return x * (60.0 / id(gas_pulse_rate));
total:
name: 'Gas ${friendly_name} gesamt'
id: sensor_gas_total_energy
unit_of_measurement: 'm³'
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: gas
accuracy_decimals: 2
filters:
# multiply value = 1 / imp value
# - multiply: 0.01
- lambda: |-
return x * (1.0 / id(gas_pulse_rate));
# Enable time component to reset energy at midnight
# https://esphome.io/components/time.html#home-assistant-time-source
time:
- platform: homeassistant
id: homeassistant_time