Getting the luftdaten.info - Data directly from the Sensor (Intranet)

Since both HA Components (opensensemap and luftdaten) or probably the related APIs are not very reliable ( see Tread: Luftdaten component updating error), I decided to get the data directly from my Sensor. The Sensor was built on basis of the instructions found here: https://luftdaten.info/feinstaubsensor-bauen/.

As a result you get a lightweight webserver, that publishes all the sensor data looking like

I Use Scrape Sensors to get the data as follows (I Only need the PM values):

- platform: scrape
  name: mySDS011 PM2.5
  resource: http://[localIPofDevice]/values
  select: ".r"
  index: 0
  value_template: "{{ value.split('µg/m³')[0] | float }}"
  unit_of_measurement: 'µg/m³'
  scan_interval: 360

- platform: scrape
  name: mySDS011 PM10
  resource: http://[localIPofDevice]/values
  select: ".r"
  index: 1
  value_template: "{{ value.split('µg/m³')[0] | float }}"
  unit_of_measurement: 'µg/m³'
  scan_interval: 360

I had to use this weired value_template-contruct, because the sensor would not split at the blank. But now it works.

I hope this way of getting reliable Air Quality Data into HA is helping others to…

2 Likes

Initially, like yourself, I thought I could use the luftdaten device’s own JSON interface to retrieve air quality data. However, running that over a longer period of time I noticed that the device was frequently unresponsive for a couple of seconds - I assume around the time the ESP was busy spinning up the SDS011 sensor. This in turn led to many failed attempts by the HA rest sensor to retrieve the data.

Eventually I decided to have the device upload its data into a local InfluxDB, and I configured some sensors to retrieve air quality data from InfluxDB.
More details can be found here:

I wonder if it would be possible to use the Send data to own API might be a good idea so we could just push it into home assistant, i just cant seem to find information on what is pushed

I briefly looked at that option, but I don’t think this would work with HA. My understanding is the key thing missing in the luftdaten device’s capability to send data to a random API is the ability to set the “Authorization” header with a token.

We could possibly have a php page or flask server running on the same machine as home assistant and then push that to home assistant making it a local push rather than a local poll making it a lot more reliable

I am running this setup now since I posted it first and i have had no problems with the setup in that time. Only once I had to manually restart the whole sensor box because the SDS did not measure anything anymore although the DHT in the same box kept on working.

So for me this is an optimal solution. No need for improvements.

I don’t see the advantage of this compared to going through InfluxDB.
Luftdaten sensor pushes to InfluxDB (built in capability), and HA pulls from InfluxDB (built in integration).