-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
particulate_matter.yaml
219 lines (198 loc) · 8.25 KB
/
particulate_matter.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
substitutions:
name: particulate_matter
friendly_name: Particulate matter
static_ip: !secret particulate_matter_static_ip
wifi_ap_password: !secret ap_password
ota_password: !secret particulate_matter_ota_password
encryption_key: !secret particulate_matter_encryption_key
version: v1
packages:
device_base: !include packages/device_base.yaml
esphome:
name: ${name}
friendly_name: ${friendly_name}
project:
name: golles.${friendly_name}
version: ${version}
esp32:
board: mhetesp32minikit
framework:
type: arduino
wifi:
manual_ip:
dns1: !secret dns1 # Without DNS the device can't find any host on the internet.
dns2: !secret dns2
http_request:
useragent: esphome/${name}
timeout: 10s
verify_ssl: false
uart: # Enable UART for SDS011
rx_pin: GPIO32
tx_pin: GPIO12
baud_rate: 9600
i2c: # Enable i2c for BME280
sda: GPIO27
scl: GPIO25
sensor:
- platform: sds011
pm_10_0:
id: ${name}_pm10
name: PM 10
accuracy_decimals: 2
# All the sensor values update in the same cycle and the logs indicate that pm10 is the last one. so we can trigger the automation here.
on_value:
- if:
condition:
switch.is_on: standalone_mode
then:
- script.execute: push_sds011_data
pm_2_5:
id: ${name}_pm25
name: PM 2.5
accuracy_decimals: 2
update_interval: 30min # First deploy config with 0min, see https://github.com/esphome/issues/issues/1144 - you might need to do this a few times.
- platform: bme280_i2c
address: 0x76
humidity:
id: ${name}_humidity
name: Humidity
accuracy_decimals: 2
# All the sensor values update in the same cycle and the logs indicate that humidity is the last one. so we can trigger the automation here.
on_value:
- if:
condition:
switch.is_on: standalone_mode
then:
- script.execute: push_bme280_data
pressure:
id: ${name}_pressure
name: Pressure
accuracy_decimals: 2
temperature:
id: ${name}_temperature
name: Temperature
accuracy_decimals: 2
update_interval: 5min
switch:
- platform: template
id: standalone_mode
name: Standalone mode
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
text_sensor:
- platform: version
id: ${name}_esphome_short_version
hide_timestamp: true
internal: true # Don't expose, only use in API calls.
script:
# API descriptions can be found here: https://github.com/opendata-stuttgart/meta/wiki/EN-APIs
- id: push_sds011_data
then:
- http_request.post:
url: https://api.sensor.community/v1/push-sensor-data/
headers:
Content-Type: application/json
X-Pin: 1 # This tells Luftdaten that it is SDS011 data.
X-Sensor: !secret luftdaten_x_sensor
json: |-
root["software_version"] = id(${name}_esphome_short_version).state;
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject pm10 = sensordatavalues.createNestedObject();
pm10["value_type"] = "P1";
pm10["value"] = id(${name}_pm10).state;
JsonObject pm25 = sensordatavalues.createNestedObject();
pm25["value_type"] = "P2";
pm25["value"] = id(${name}_pm25).state;
- delay: 30s
- http_request.post:
url: https://api-rrd.madavi.de/data.php
headers:
Content-Type: application/json
X-Sensor: !secret luftdaten_x_sensor
json: |-
root["software_version"] = id(${name}_esphome_short_version).state;
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject pm10 = sensordatavalues.createNestedObject();
pm10["value_type"] = "SDS_P1";
pm10["value"] = id(${name}_pm10).state;
JsonObject pm25 = sensordatavalues.createNestedObject();
pm25["value_type"] = "SDS_P2";
pm25["value"] = id(${name}_pm25).state;
JsonObject signal = sensordatavalues.createNestedObject();
signal["value_type"] = "signal";
signal["value"] = id(${name}_esphome_wifi_signal).state;
- delay: 30s
- http_request.post:
# API documentation: https://docs.opensensemap.org/#api-Measurements-postNewMeasurements
url: !secret opensensemap_url # https://api.opensensemap.org/boxes/YOUR_BOX_ID/data?luftdaten=1
headers:
Content-Type: application/json
Authorization: !secret opensensemap_access_token
json: |-
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject pm10 = sensordatavalues.createNestedObject();
pm10["value_type"] = "SDS_P1";
pm10["value"] = id(${name}_pm10).state;
JsonObject pm25 = sensordatavalues.createNestedObject();
pm25["value_type"] = "SDS_P2";
pm25["value"] = id(${name}_pm25).state;
- id: push_bme280_data
then:
- http_request.post:
url: https://api.sensor.community/v1/push-sensor-data/
headers:
Content-Type: application/json
X-Pin: 11 # This tells Luftdaten that it is BME280 data.
X-Sensor: !secret luftdaten_x_sensor
json: |-
root["software_version"] = id(${name}_esphome_short_version).state;
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject humidity = sensordatavalues.createNestedObject();
humidity["value_type"] = "humidity";
humidity["value"] = id(${name}_humidity).state;
JsonObject pressure = sensordatavalues.createNestedObject();
pressure["value_type"] = "pressure";
pressure["value"] = id(${name}_pressure).state * 100;
JsonObject temperature = sensordatavalues.createNestedObject();
temperature["value_type"] = "temperature";
temperature["value"] = id(${name}_temperature).state;
- delay: 30s
- http_request.post:
url: https://api-rrd.madavi.de/data.php
headers:
Content-Type: application/json
X-Sensor: !secret luftdaten_x_sensor
json: |-
root["software_version"] = id(${name}_esphome_short_version).state;
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject humidity = sensordatavalues.createNestedObject();
humidity["value_type"] = "BME280_humidity";
humidity["value"] = id(${name}_humidity).state;
JsonObject pressure = sensordatavalues.createNestedObject();
pressure["value_type"] = "BME280_pressure";
pressure["value"] = id(${name}_pressure).state * 100;
JsonObject temperature = sensordatavalues.createNestedObject();
temperature["value_type"] = "BME280_temperature";
temperature["value"] = id(${name}_temperature).state;
JsonObject signal = sensordatavalues.createNestedObject();
signal["value_type"] = "signal";
signal["value"] = id(${name}_esphome_wifi_signal).state;
- delay: 30s
- http_request.post:
# API documentation: https://docs.opensensemap.org/#api-Measurements-postNewMeasurements
url: !secret opensensemap_url # https://api.opensensemap.org/boxes/YOUR_BOX_ID/data?luftdaten=1
headers:
Content-Type: application/json
Authorization: !secret opensensemap_access_token
json: |-
JsonArray sensordatavalues = root.createNestedArray("sensordatavalues");
JsonObject humidity = sensordatavalues.createNestedObject();
humidity["value_type"] = "BME280_humidity";
humidity["value"] = id(${name}_humidity).state;
JsonObject pressure = sensordatavalues.createNestedObject();
pressure["value_type"] = "BME280_pressure";
pressure["value"] = id(${name}_pressure).state;
JsonObject temperature = sensordatavalues.createNestedObject();
temperature["value_type"] = "BME280_temperature";
temperature["value"] = id(${name}_temperature).state;