-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathklimerko.yaml
177 lines (156 loc) · 4.97 KB
/
klimerko.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
substitutions: # Mandatory setting
devicename: klimerko # Put your device name here
device_ip: 192.168.x.xxx # Put your device IP address here and device gateway in next line
device_gateway: 192.168.x.xxx
makerid: maker:xxxxxxxxxxx # Put your Allthingstalk makerid here
deviceid: xxxxxxxx # Put your Allthingstalk device id here
esphome:
name: $devicename
comment: "D1 Mini ESP8266 - Klimerko" # edit comment for your device
esp8266:
board: d1_mini_lite #change board type if you have different one or try as is
# Enable Home Assistant API, create new device in ESPHOME and copy and replace xxx with api key and ota password below
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi: # add your wifi ssid and password to secrets file or edit them directly here
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: ${device_ip}
manual_ip:
static_ip: ${device_ip}
gateway: ${device_gateway}
subnet: 255.255.255.0
dns1: 8.8.8.8
dns2: 1.1.1.1
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: $devicename
password: !secret wifi_password
captive_portal:
# Enable logging
# Remove comments from four lines after 'logger:' to enable mqtt debug logging - optional
logger:
# level: VERBOSE
# logs:
# mqtt.component: DEBUG
# mqtt.client: DEBUG
# PMS7003 uart port config
uart:
rx_pin: D6
tx_pin: D5
baud_rate: 9600
# I2C bus config for BME280
i2c:
sda: D2
scl: D1
# MQTT setup for communication with Allthingstalk
mqtt:
id: att
broker: "api.allthingstalk.io"
client_id: $deviceid
username: $makerid
password: "bfnbayv9"
keepalive: 15s
# important, indicates not to add home assistant prefix to MQTT messages by default
topic_prefix: null
discovery: false
discovery_prefix: null
discover_ip: false
# Timer, send new data to cloud each minute
interval:
- interval: 1min
id: update_interval
then:
- logger.log: "Interval triggered"
- mqtt.publish_json:
topic: "device/$deviceid/state"
payload: |-
root["air-quality"]["value"] = id(airQualityText).state;
root["pm1"]["value"] = id(pm_1_0).state;
root["pm2-5"]["value"] = id(pm_2_5).state;
root["pm10"]["value"] = id(pm_10_0).state;
root["temperature"]["value"] = id(temperature).state;
root["humidity"]["value"] = id(humidity).state;
root["pressure"]["value"] = id(pressure).state;
root["firmware"]["value"] = id(firmware).state;
root["interval"]["value"] = 120;
root["wifi-signal"]["value"] = id(WifiText).state;
sensor:
# WiFi signal sensor
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s
id: wifi_signal_strenght
# pms7003 sensor config
- platform: pmsx003
type: PMSX003
id: pmsensor
pm_1_0:
name: "Particulate Matter <1.0µm Concentration"
id: "pm_1_0"
pm_2_5:
name: "Particulate Matter <2.5µm Concentration"
id: pm_2_5
pm_10_0:
name: "Particulate Matter <10.0µm Concentration"
id: pm_10_0
update_interval: 120s
# bme280 sensor config
- platform: bme280_i2c
temperature:
name: "BME280 Temperature"
oversampling: 16x
id: temperature
pressure:
name: "BME280 Pressure"
id: pressure
humidity:
name: "BME280 Humidity"
id: humidity
address: 0x77
update_interval: 60s
text_sensor:
# Firmware sensor, uploads ESPHOME firmware virsion to cloud
- platform: version
name: "ESPHome Version"
hide_timestamp: true
id: firmware
# Air quality text sensor
- platform: template
id: airQualityText
name: "$devicename Air Quality PM2.5"
icon: "mdi:air-filter"
lambda: |-
if (id(pm_10_0).state <= 20) {
return {"Excellent"};
} else if (id(pm_10_0).state >= 21 && id(pm_10_0).state <= 40) {
return {"Good"};
} else if (id(pm_10_0).state >= 41 && id(pm_10_0).state <= 50) {
return {"Acceptable"};
} else if (id(pm_10_0).state >= 51 && id(pm_10_0).state <= 100) {
return {"Polluted"};
} else if (id(pm_10_0).state > 100) {
return {"Very Polluted"};
}
return {"Very Polluted"};
# Wifi text sensor
- platform: template
id: WifiText
name: "$devicename WiFi Signal"
lambda: |-
if (id(wifi_signal_strenght).state < -87) {
return {"Horrible"};
} else if (id(wifi_signal_strenght).state >= -87 && id(wifi_signal_strenght).state <= -80) {
return {"Bad"};
} else if (id(wifi_signal_strenght).state > -80 && id(wifi_signal_strenght).state <= -70) {
return {"Decent"};
} else if (id(wifi_signal_strenght).state > -70 && id(wifi_signal_strenght).state <= -55) {
return {"Good"};
} else if (id(wifi_signal_strenght).state > -55) {
return {"Excellent"};
}
return {"Error"};
icon: "mdi:wifi"