forked from mhendriks/esphome-p1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s0-dongle.yaml
162 lines (139 loc) · 3.83 KB
/
s0-dongle.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
substitutions:
device_name: s0-dongle
device_description: "S0 module to read S0 interfaces (pulse counters)"
friendly_name: S0-Dongle
p_version: "v22.12.1"
esphome:
name: ${device_name}
comment: "${device_description}"
name_add_mac_suffix: false
project:
name: smartstuff.s0-dongle
version: ${p_version}
external_components:
- source: github://pr#3321
components: [pulse_meter]
esp8266:
board: esp12e
restore_from_flash: true
status_led:
pin:
number: 2
inverted: true
ota:
wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name}
ap_timeout: 15s
dashboard_import:
package_import_url: github://mhendriks/esphome-p1/s0-dongle.yaml
captive_portal:
web_server:
port: 80
# Enable logging
logger:
level: DEBUG
esp8266_store_log_strings_in_flash: False
api:
#via Home Assistant Ontwikkelhulpmiddelen > services zoeken op esphome.watermeter_set_water_reading en via deze methode de juiste beginstand invoeren
services:
- service: s0_reset_total_energy
then:
- button.press:
id: button_reset_total
- service: s0_set_total_energy
variables:
s0_value: int
then:
- pulse_meter.set_total_pulses:
id: pulse
value: !lambda 'return s0_value;'
globals:
- id: tot_count
type: float
restore_value: no # aanpassen naar no indien de nieuwe waarde onder de oude ligt
initial_value: '0' # beginstand -> aanpassen via Home Assistant services
- id: pulse_rate
type: int
restore_value: no # aanpassen naar no indien de nieuwe waarde onder de oude ligt
initial_value: '1000' # pulse rate van de kWh meter -> xxx pulses / kWh
button:
- platform: restart
name: "_Restart device"
- platform: factory_reset
name: "_Restart with Factory Default Settings"
- platform: template
name: "_Reset - Total Energy Counter"
id: button_reset_total
on_press:
- pulse_meter.set_total_pulses:
id: pulse
value: 0
sensor:
- platform: pulse_meter
pin:
number: 5
mode:
input: true
pullup: true #v3.5 aanzetten
id: pulse
state_class: measurement
unit_of_measurement: 'W'
device_class: power
internal_filter: 100ms
internal_filter_mode: EDGE
icon: mdi:flash-outline
filters:
#- multiply: 0.06 # (60s/1000 pulses per kWh)
- lambda: return x * ((60.0 / id(pulse_rate)) * 1000.0);
total:
name: "S0 Total Energy"
id: pulse_tot
unit_of_measurement: "kWh"
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- lambda: return x * (1.0 / id(pulse_rate));
- platform: uptime
name: "Uptime"
- platform: total_daily_energy
name: 'S0 Daily Energy'
id:
power_id: pulse
unit_of_measurement: 'kWh'
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
# Enable time component to reset energy at midnight
# https://esphome.io/components/time.html#home-assistant-time-source
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: wifi_info
ip_address:
name: IP-adres
icon: mdi:ip-network
ssid:
name: Netwerk
icon: mdi:access-point-network
mac_address:
name: Mac-adres
icon: mdi:folder-key-network-outline
- platform: template
name: "Config Version"
icon: "mdi:label-outline"
update_interval: 6h
lambda: return {"$p_version"};
- platform: version
name: "ESPHome Version"
hide_timestamp: true