Timestream DB visualization with Grafana (including data from soon to be retired DarkSky)
First create an Inject node. The payload does not matter. Check the box “Inject once after…” and configure the interval for how often you’d like to collect the data.
Next create and connect an HTTP request node, and configure it to use your Awair Element HTTP API
Next, add a JSON node with the default settings
Now, we add our first Change node. In Domoticz, a virtual sensor (Temp+Hum) was created, and I noted down the IDX number. Here we are using JSONata to format the payload value (into a temporary store) to what is expected by Domoticz. The payload is then cleared (so as only to have the expected payload), and is repopulated with the IDX, nvalue required by Domoticz, and the svalue with the data.
Here we have the PM 2.5 sensor data. In Domoticz I created a Custom Sensor “Awair PM 2.5” and set the label as ug/m3. For the Custom Sensor type it seems that I had to use a string data type to get it to register (but parses the data as a number just fine after that point)
Same thing for PM 10 sensor data.
CO2 (ppm measurement):
VOC (ppb measurement):
And last, the Awair “score” determined by mixing the sensor data:
Finally, create an MQTT out node, and configure it to point to the MQTT server you’re using for Domoticz. Deploy the flow, and at this point, you should have data coming into Domoticz.
Temperature tab in Domoticz
On the Utility tab in Domoticz, we can see all the “Custom Sensor” data
For the MQTT bridge I have the domoticz/out topic going out to AWS IoT Core and domoticz/in coming back in (for some AWS Lambda functions that I have to grab even more API data such as AirNow). I highly recommend DietPi Linux if you’re using a Raspberry Pi.
In AWS IoT Core I have a rule that sends this data to a TimeStream DB (up to 200 year retention if you wanted!!!)
For Grafana, I installed it as a Docker container in Elastic Container Services. I attached the AmazonTimeStreamReadOnlyAccess policy to the ecsInstanceRole so that it could read the Timestream DB.
I then configured the Timestream plugin in Grafana. I named the DB similar to the “DarkSky” API which is End of Life soon ☹
I stumbled my way around PromQL for quite some time before figuring out how to make a proper graph. Dual Y axis is being used
My AWS costs are minimal. My end of month bill is forecasted to be $1.04. I expect this to grow slowly over time as I add more and more data, but nothing to bat an eye at.