There is an sensor for HASS called luftdaten, it queries the cloud based API and creates sensors in HASS.
The air quality open source sensor project is based upon a NodeMCU (ESP8266) and a SDS011 particle sensor.
You can if you want query the your local ESP8266 instead of the cloud API.
Access the local sensor is done via HTTP and the output is JSON. http://ip.adress/data.json is the URL to query.
More info can also be found (in german) on www.luftdaten.info and Swedish on www.luftdata.se
sensor:
- platform: command_line
name: "Luftdata PM10"
command: 'curl http://192.168.21.47/data.json'
value_template: "{{ value_json.sensordatavalues[0].value | round(2) }}"
unit_of_measurement: "µg/m³"
- platform: command_line
name: "Luftdata PM2.5"
command: 'curl http://192.168.21.47/data.json'
value_template: "{{ value_json.sensordatavalues[1].value | round(2) }}"
unit_of_measurement: "µg/m³"
- platform: command_line
name: "Luftdata Temperature DHT22"
command: 'curl http://192.168.21.47/data.json'
value_template: "{{ value_json.sensordatavalues[2].value | round(1) }}"
unit_of_measurement: "°C"
- platform: command_line
name: "Luftdata Humidity DHT22"
command: 'curl http://192.168.21.47/data.json'
value_template: "{{ value_json.sensordatavalues[3].value | round(1) }}"
unit_of_measurement: "%"
- platform: statistics
name: pm10 stats
entity_id: sensor.luftdata_pm10
max_age:
minutes: 60
- platform: statistics
name: pm25 stats
entity_id: sensor.luftdata_pm25
max_age:
minutes: 60
- platform: template
sensors:
air_quality_pm10:
friendly_name: 'Air quality PM10'
value_template: >-
{%if states.sensor.pm10_stats_mean.state | float<=25 %}EXCELLENT
{% elif sensor.pm10_stats_mean.state | float<=50 | float>25 %}GOOD
{% elif sensor.pm10_stats_mean.state | float<=90 | float>25 %}FAIR
{% elif sensor.pm10_stats_mean.state | float<=180 | float>90 %}INFERIOR
{% elif sensor.pm10_stats_mean.state | float>180 %}POOR
{%- endif %}
- platform: template
sensors:
air_quality_pm25:
friendly_name: 'Air quality PM2.5'
value_template: >-
{%if states.sensor.pm25_stats_mean.state | float<=15 %}EXCELLENT
{% elif sensor.pm25_stats_mean.state | float<=30 | float>15 %}GOOD
{% elif sensor.pm25_stats_mean.state | float<=55 | float>30 %}FAIR
{% elif sensor.pm25_stats_mean.state | float<=110 | float>55 %}INFERIOR
{% elif sensor.pm25_stats_mean.state | float>110 %}POOR
{%- endif %}