-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathferraris_meter_analog.yaml
149 lines (132 loc) · 3.79 KB
/
ferraris_meter_analog.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
# This is an example configuration for an ESPHome firmware to measure the
# current power and overall energy consumption using a Ferraris electricity
# meter
# In this variant, the analog output A0 of the TCRT5000 module is used as
# input for the rotation observation of the turntable.
# generic configuration (to be adapted)
esphome:
name: ferraris-meter
friendly_name: Stromzähler
project:
name: jensrossbach.ferraris_meter
version: 1.4.1
# example ESP8266 firmware (can be replaced by appropriate configuration)
esp8266:
board: esp01_1m
# include Ferraris component (mandatory)
external_components:
- source: github://jensrossbach/esphome-ferraris-meter@v1.4.1
components: [ferraris]
# enable logging (optional)
logger:
level: INFO
# enable Home Assistant API (mandatory if used with Home Assistant, alternatively configure MQTT)
api:
encryption:
key: !secret ha_api_key
# enable over-the-air updates (recommended)
ota:
- platform: esphome
password: !secret ota_password
# enable Wi-Fi (mandatory)
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# enable fallback hotspot (captive portal) in case Wi-Fi connection fails
ap:
ssid: Ferraris Meter Fallback Hotspot
password: !secret fallback_hs_password
# needed for fallback hotspot (see above)
captive_portal:
# Ferraris component (mandatory)
ferraris:
id: ferraris_meter
analog_input: adc_input
analog_threshold: adc_threshold
energy_start_value: last_energy_value
# numeric sensors
sensor:
- platform: ferraris
# sensor for current power consumption
power_consumption:
name: Momentanverbrauch
# sensor for energy meter reading
energy_meter:
name: Verbrauchszähler
# sensor for analog input signal
- platform: adc
id: adc_input
pin: GPIO17 # ADC pin of ESP8266
internal: true
raw: true
samples: 10
update_interval: 50ms
# sensor for Wi-Fi signal strength
- platform: wifi_signal
name: Wi-Fi Signal
update_interval: 60s
# binary sensors
binary_sensor:
- platform: ferraris
# sensor for indicating detected rotation during calibration mode
rotation_indicator:
name: Umdrehungsindikator
# sensor for wireless connection status
- platform: status
name: Status
# text sensors
text_sensor:
- platform: wifi_info
# sensor providing the IP address of the ESP microcontroller
ip_address:
name: IP Adresse
# number components
number:
# import entity holding last energy meter reading from Home Assistant
- platform: homeassistant
id: last_energy_value
entity_id: input_number.stromzaehler_letzter_wert
# number used to configure and calibrate the analog threshold
- platform: template
id: adc_threshold
name: ADC Schwellwert
icon: mdi:speedometer-slow
entity_category: config
mode: box
optimistic: true
initial_value: 50
min_value: 0
max_value: 1000
step: 1
# number used to manually overwrite the energy meter
- platform: template
id: target_energy_value
name: Manueller Zählerstand
icon: mdi:counter
unit_of_measurement: kWh
device_class: energy
entity_category: config
mode: box
optimistic: true
min_value: 0
max_value: 1000000
step: 0.01
# switch components
switch:
- platform: ferraris
# switch used to activate or deactivate the calibration mode
calibration_mode:
name: Kalibrierungsmodus
# button components
button:
# button used to trigger the manual overwriting of the energy meter
- platform: template
name: Verbrauchszähler überschreiben
icon: mdi:download
entity_category: config
on_press:
- ferraris.set_energy_meter:
id: ferraris_meter
value: !lambda |-
float val = id(target_energy_value).state;
return (val >= 0) ? val : 0;