Compare commits
No commits in common. "master" and "dev" have entirely different histories.
4 changed files with 27 additions and 387 deletions
|
@ -129,4 +129,3 @@ Grafana can be used to create dashboard and visualise prometheus metrics. To ins
|
|||
Grafana is accessible on port `:80`. Premade dashboards can be found in the `grafana/dashboards` folder.
|
||||
|
||||
![](./docs/grafana_dashboard.png)
|
||||
|
||||
|
|
|
@ -73,17 +73,12 @@ class Bme680Sensor(Accessory):
|
|||
if self.sensor.data.heat_stable:
|
||||
self._gas_resistance_metric.set(self.sensor.data.gas_resistance)
|
||||
|
||||
logging.info(
|
||||
f"T: {self.sensor.data.temperature}; H: {self.sensor.data.humidity}: P: {self.sensor.data.pressure}")
|
||||
logging.info(f"G: {self.sensor.data.gas_resistance}")
|
||||
|
||||
@Accessory.run_at_interval(120)
|
||||
def run(self):
|
||||
"""
|
||||
This function runs the accessory. It polls for data and publishes it at the given interval.
|
||||
"""
|
||||
try:
|
||||
logging.info("Reading data from BME680 sensor.")
|
||||
self._run()
|
||||
except IOError as e:
|
||||
# This happens from time to time, best we stop and let systemd restart us.
|
||||
|
|
|
@ -27,10 +27,10 @@ class Pms5003Sensor(Accessory):
|
|||
"pms5003_pm_ug_per_m3_1", "The PM1.0 ug/m3 (ultrafine particles)."
|
||||
)
|
||||
self._pms5003_pm_ug_per_m3_2 = Gauge(
|
||||
"pms5003_pm_ug_per_m3_2", "PM2.5 ug/m3 (combustion particles, organic compounds, metals)."
|
||||
"pms5003_pm_ug_per_m3_1", "PM2.5 ug/m3 (combustion particles, organic compounds, metals)."
|
||||
)
|
||||
self._pms5003_pm_ug_per_m3_10 = Gauge(
|
||||
"pms5003_pm_ug_per_m3_10", "PM10 ug/m3 (dust, pollen, mould spores)"
|
||||
"pms5003_pm_ug_per_m3_1", "PM10 ug/m3 (dust, pollen, mould spores)"
|
||||
)
|
||||
|
||||
@Accessory.run_at_interval(120)
|
||||
|
@ -39,14 +39,11 @@ class Pms5003Sensor(Accessory):
|
|||
This function runs the accessory. It polls for data and updates prometheus metrics.
|
||||
"""
|
||||
try:
|
||||
logging.info("Reading data from PMS5003 sensor.")
|
||||
data = self.sensor.read()
|
||||
|
||||
self._pms5003_pm_ug_per_m3_1.set(data.pm_ug_per_m3(1.0))
|
||||
self._pms5003_pm_ug_per_m3_2.set(data.pm_ug_per_m3(2.5))
|
||||
self._pms5003_pm_ug_per_m3_10.set(data.pm_ug_per_m3(10))
|
||||
|
||||
logging.info(f"PM1.0 {data.pm_ug_per_m3(1.0)} PM2.5 {data.pm_ug_per_m3(2.5)} PM10 {data.pm_ug_per_m3(10)}")
|
||||
except IOError as e:
|
||||
# This happens from time to time, best we stop and let systemd restart us.
|
||||
logging.critical("Failed to read data from serial.")
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
"__inputs": [
|
||||
{
|
||||
"name": "DS_PROMETHEUS",
|
||||
"label": "prometheus",
|
||||
"label": "Prometheus",
|
||||
"description": "",
|
||||
"type": "datasource",
|
||||
"pluginId": "prometheus",
|
||||
"pluginName": "Prometheus"
|
||||
}
|
||||
],
|
||||
"__elements": {},
|
||||
"__elements": [],
|
||||
"__requires": [
|
||||
{
|
||||
"type": "grafana",
|
||||
"id": "grafana",
|
||||
"name": "Grafana",
|
||||
"version": "10.3.1"
|
||||
"version": "8.5.5"
|
||||
},
|
||||
{
|
||||
"type": "datasource",
|
||||
|
@ -65,324 +65,6 @@
|
|||
"links": [],
|
||||
"liveNow": true,
|
||||
"panels": [
|
||||
{
|
||||
"gridPos": {
|
||||
"h": 1,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 14,
|
||||
"title": "Air Quality",
|
||||
"type": "row"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "ug/m3",
|
||||
"unitScale": false
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 7,
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"id": 11,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "pms5003_pm_ug_per_m3_1{instance=\"localhost:8000\"}",
|
||||
"instant": false,
|
||||
"legendFormat": "Measurement",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "PM1.0 ug/m3 (ultrafine particles)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "ug/m3",
|
||||
"unitScale": false
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 8,
|
||||
"x": 7,
|
||||
"y": 1
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "pms5003_pm_ug_per_m3_2{instance=\"localhost:8000\"}",
|
||||
"instant": false,
|
||||
"legendFormat": "Measurement",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "PM2.5 ug/m3 (combustion particles, organic compounds, metals).",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "ug/m3",
|
||||
"unitScale": false
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 9,
|
||||
"x": 15,
|
||||
"y": 1
|
||||
},
|
||||
"id": 13,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "pms5003_pm_ug_per_m3_10{instance=\"localhost:8000\"}",
|
||||
"instant": false,
|
||||
"legendFormat": "Measurement",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "PM10 ug/m3 (dust, pollen, mould spores)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"collapsed": false,
|
||||
"gridPos": {
|
||||
"h": 1,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 9
|
||||
},
|
||||
"id": 10,
|
||||
"panels": [],
|
||||
"title": "Climate Sensor",
|
||||
"type": "row"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
|
@ -403,8 +85,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"unit": "celsius",
|
||||
"unitScale": true
|
||||
"unit": "celsius"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
|
@ -412,7 +93,7 @@
|
|||
"h": 4,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 10
|
||||
"y": 0
|
||||
},
|
||||
"id": 8,
|
||||
"options": {
|
||||
|
@ -427,11 +108,9 @@
|
|||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showPercentChange": false,
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.3.1",
|
||||
"pluginVersion": "8.5.5",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -465,8 +144,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"unit": "humidity",
|
||||
"unitScale": true
|
||||
"unit": "humidity"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
|
@ -474,7 +152,7 @@
|
|||
"h": 4,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 10
|
||||
"y": 0
|
||||
},
|
||||
"id": 9,
|
||||
"options": {
|
||||
|
@ -489,11 +167,9 @@
|
|||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showPercentChange": false,
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.3.1",
|
||||
"pluginVersion": "8.5.5",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -518,9 +194,6 @@
|
|||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
|
@ -532,7 +205,6 @@
|
|||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
|
@ -563,8 +235,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"unit": "celsius",
|
||||
"unitScale": true
|
||||
"unit": "celsius"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
|
@ -572,15 +243,14 @@
|
|||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
"y": 4
|
||||
},
|
||||
"id": 2,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
|
@ -593,10 +263,7 @@
|
|||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "bme680_temperature_celsius{}",
|
||||
"legendFormat": "Temperature",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
|
@ -614,9 +281,6 @@
|
|||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
|
@ -628,7 +292,6 @@
|
|||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
|
@ -659,8 +322,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"unit": "humidity",
|
||||
"unitScale": true
|
||||
"unit": "humidity"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
|
@ -668,15 +330,14 @@
|
|||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 14
|
||||
"y": 4
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
|
@ -689,10 +350,7 @@
|
|||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "bme680_humidity_rh{}",
|
||||
"legendFormat": "Relative Humidity",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
|
@ -710,9 +368,6 @@
|
|||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
|
@ -724,7 +379,6 @@
|
|||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
|
@ -755,24 +409,22 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"unit": "pressurehpa",
|
||||
"unitScale": true
|
||||
"unit": "pressurehpa"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"h": 11,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 24
|
||||
"y": 14
|
||||
},
|
||||
"id": 6,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
|
@ -785,10 +437,7 @@
|
|||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "bme680_pressure_hpa{}",
|
||||
"legendFormat": "Pressure",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
|
@ -796,20 +445,20 @@
|
|||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": false,
|
||||
"schemaVersion": 39,
|
||||
"schemaVersion": 36,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Home",
|
||||
"uid": "snBE4Jj7z",
|
||||
"version": 4,
|
||||
"version": 5,
|
||||
"weekStart": ""
|
||||
}
|
Loading…
Reference in a new issue