-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathekorrbo_esp.yaml
171 lines (158 loc) · 3.97 KB
/
ekorrbo_esp.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
substitutions:
node_name: ekorrbo
friendly_name: Ekorrbo
esphome:
name: ${node_name}_esp
platform: ESP8266
board: d1_mini
on_boot:
priority: 800.0
then:
- output.turn_off: gnd
- delay: 20ms
- component.update: ekorrbo_uptime_raw
wifi:
networks:
- ssid: "Erlandssons IOT"
password: !secret wifi_iot_password
hidden: true
priority: 256
- ssid: "Fredrik_AP"
password: !secret wifi_password
priority: 1
- ssid: "Ekorrbo"
password: !secret wifi_ekorrbo
priority: 2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ekorrbo_esp Fallback Hotspot"
password: !secret wifi_ap
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret ekorrbo_api_password
ota:
password: !secret ota_password
status_led:
pin:
number: D4
inverted: True
output:
- platform: gpio
pin:
number: D6
mode: OUTPUT
id: gnd
- platform: gpio
pin: D4
id: led_pin
binary_sensor:
- platform: gpio
pin: D2
name: pulse
internal: true
on_press:
then:
- light.turn_on:
id: led
- delay: 250ms
- light.turn_off:
id: led
light:
- platform: binary
name: "LED"
id: led
output: led_pin
internal: true
sensor:
- platform: dht
model: AM2302
pin: D7
update_interval: 20s
temperature:
name: "${friendly_name} Temperature"
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
# - 26.4 -> 22.8
- 28.0 -> 18.5
- 18.6 -> 17.7
- 17.6 -> 16.2
- median:
window_size: 5
send_every: 3
send_first_at: 3
- filter_out: 0.0
#internal: true
humidity:
name: "${friendly_name} Humidity"
filters:
- median:
window_size: 5
send_every: 3
send_first_at: 3
- filter_out: 0.0
#internal: true
- platform: wifi_signal
name: "${friendly_name} WiFi Signal Sensor"
update_interval: 180s
- platform: uptime
name: "${friendly_name} Uptime Sensor"
id: ${node_name}_uptime_raw
update_interval: 60s
on_raw_value:
then:
- logger.log:
format: "Raw Value of Uptime sensor: %f, %f"
args: ['id(${node_name}_uptime_raw).raw_state', 'id(${node_name}_uptime_raw).state']
level: INFO
- text_sensor.template.publish:
id: ekorrbo_uptime
state: !lambda |-
int seconds = round(id(${node_name}_uptime_raw).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
- platform: pulse_counter
pin:
number: D2
name: '${friendly_name} Power Meter'
update_interval: 20s
id: ${node_name}_power
unit_of_measurement: 'W'
device_class: power
accuracy_decimals: 0
filters:
- multiply: 300 # 200 pulse/kWh (60/200*1000)
- sliding_window_moving_average:
window_size: 3
send_every: 2
total:
unit_of_measurement: 'kWh'
name: '${friendly_name} Energy Meter'
last_reset_type: auto
state_class: measurement
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- throttle: 60s
- heartbeat: 60s
- multiply: 0.005 # 1/200 (1kWh / 200 pulses per kWh)
text_sensor:
- platform: template
name: ${friendly_name} Uptime
id: ${node_name}_uptime
icon: mdi:clock-start