I’m using the web scraper platform to get some data from the real time air quality sensors in Norway via www.luftkvalitet.info. There are heaps of them all over the place, so you would only need to change some of the links here to get your city. I’d love for someone to improve this so it could trigger on unhealthy levels.
sensors.yaml:
- platform: scrape
name: O³
resource: http://www.luftkvalitet.info/home/overview.aspx?type=Station&id={9f6b3149-209a-4e02-836c-c865c5e306f6}
select: "td:nth-of-type(8)"
unit_of_measurement: 'µg/m³'
- platform: scrape
name: NO²
resource: http://www.luftkvalitet.info/home/overview.aspx?type=Station&id={9f6b3149-209a-4e02-836c-c865c5e306f6}
select: "td:nth-of-type(14)"
unit_of_measurement: 'µg/m³'
- platform: scrape
name: SO²
resource: http://www.luftkvalitet.info/home/overview.aspx?type=Station&id={9f6b3149-209a-4e02-836c-c865c5e306f6}
select: "td:nth-of-type(20)"
unit_of_measurement: 'µg/m³'
- platform: scrape
name: PM25
resource: http://www.luftkvalitet.info/home/overview.aspx?type=Station&id={4c308d8e-dba8-4f9f-8730-f083da14ae01}
select: "td:nth-of-type(8)"
unit_of_measurement: 'µg/m³'
- platform: scrape
name: PM10
resource: http://www.luftkvalitet.info/home/overview.aspx?type=Station&id={4c308d8e-dba8-4f9f-8730-f083da14ae01}
select: "td:nth-of-type(14)"
unit_of_measurement: 'µg/m³'
groups.yaml:
air_quality:
name: Air Quality Oslo
view: no
icon: mdi:jquery
entities:
- sensor.o3
- sensor.no2
- sensor.so2
- sensor.pm25
- sensor.pm10
Keep healthy!
4 Likes
dawnlord
(Christer)
March 15, 2018, 10:27pm
2
How do you target the values?
I tried to do the same on this page http://goteborg.se/wps/portal?uri=gbglnk%3Agbg.page.66289f63-5959-4215-9029-bb8f6c3a3844 but i am not able to target correct attributes and values.
Honestly, the scrape sensor is pretty finicky to get working. I just ended up making like 20 sensors, and changing the variables a little in each of them, to see which ones got closer. I think someone here would be able to help with scraping much more than me, I just brute forced it.
metbril
(Robert 🇳🇱🇪🇺)
March 16, 2018, 6:54am
4
Parihaka:
www.luftkvalitet.info
Aren’t these stations also available through www.waqi.info? There already is a platform for their api.
dawnlord
(Christer)
March 16, 2018, 7:11am
5
Unfortunately there is no measurements even close to Gothenburg with waqi
Hey, that looks perfect! Even better! Thanks for that
@Parihaka Do you have Waqi working for your stations?
I cant get it to work.
UPDATE:
Got it working like this:
- platform: waqi
token: 8f28blablabla32a
locations:
- mystation, mytown, mycountry
Ah, beat me to it. Glad you have it working!
I have had the Nilu - Norsk institutt for luftforskning (Norwegian Institute for Air Research), sensor code running for some time now, and it works fine.
Check it out here:
# Home Assistant - Air Quality Measurement Sensor for Norway
"Air pollution - from traffic, industrial or natural sources – can have a major impact on the environment, human health and ecosystems at all scales." Nilu- Norsk institutt for luftforskning (Norwegian Institute for Air Research).
Sensor code for Home Assistant, using Nilu API, for getting air quality measurement components/value from stations scattered around Norway.
Find the stations(s) closest to you at www.luftkvalitet.info , and get the air quality components (PM 2.5, PM10, NO2 etc.) with value and a health risk assessment.
The code creates separate sensors for every station/component. In addition a sensor ending in ”_max” . The MAX-sensor has the component with the highest health risk.
Note, different stations can deliver different measurement components. The value scale for each component is individual when it comes to health risk. Meaning, components with the same value, does not represent the same health risk. Component/value is mapped to the health risk scale and is represented by the attributes “index" (1 to 6-highest health risk) / "color" / "message" (Low/Moderate/Significant/Serious health risk).
Input parameters are “area” and “location”. Find your area/location at www.luftkvalitet.info
Example:
- platform: nilu
region: Oslo,Manglerud
Add the nilu.py file to /config/custom_components/sensor/nilu.py
This file has been truncated. show original