Airly widget

Hi,

Anyone try to add airly widget?

API docs:
https://developer.airly.eu/docs

How does this work? Would this poll the result from one specific sensor?

What’s the base URL of those endpoint?

I have no idea. I tried to add this widget as camera generic or take snapshot using phantomjs but its not working.Maybe someone tried to add this to hasss…
I found configuration for domoticz but there is no solution for Hass

It’s easy to implement. You have to use Rest Sensor. In headers section you should provide api key.

I came up with the following:

  - platform: rest
    name: Airly
    resource: https://airapi.airly.eu/v1/nearestSensor/measurements?latitude=YOUR_LATITUDE&longitude=YOUR_LONGITUDE&maxDistance=1000
    headers:
      apikey: !secret airly_apikey
    value_template: "{{ value_json['airQualityIndex'] }} {{ value_json['pm25'] }} {{ value_json['pm10'] }}"


  - platform: template
    sensors:
      airly_aqi:
        unit_of_measurement: "units"
        value_template: "{{ states.sensor.airly.state.split(' ')[0] | round(0) }}"
      airly_pm25:
        unit_of_measurement: "μg/m3"
        value_template: "{{ states.sensor.airly.state.split(' ')[1] | round(0) }}"
      airly_pm10:
        unit_of_measurement: "μg/m3"
        value_template: "{{ states.sensor.airly.state.split(' ')[2] | round(0) }}"

Airly response is a bit verbose and needs some tweaking with template sensors. You can omit that if you’re interested in aqi or pm25 only.

How to change calls interval? Your sample works fine, but Airly API is limited to 1000 requests per day. Default Sensor interval is equal 30 seconds.
Is there any way to set this value only for airly sensors?

In sensors add scan_interval

It works. Thanks!

On February 28 2019 Airly will end support for the old version of API v1. Here is how I did transition to v2:

  - platform: rest
    scan_interval: 120
    name: Airly
    resource: https://airapi.airly.eu/v2/measurements/nearest?indexType=AIRLY_CAQI&lat=xxx&lng=xxx&maxDistanceKM=1
    value_template: "{{ value_json['current']['values'][1]['value'] }} {{ value_json['current']['values'][2]['value'] }} {{ value_json['current']['values'][3]['value'] }} {{ value_json['current']['values'][4]['value'] }} {{ value_json['current']['values'][5]['value'] }} {{ value_json['current']['indexes'][0]['level'] }}"
    headers:
      apikey: !secret api_airly

  - platform: template
    sensors:
      airly_pm25:
        unit_of_measurement: "μg/m3"
        value_template: "{{ states.sensor.airly.state.split(' ')[0] }}"
      airly_pm10:
        unit_of_measurement: "μg/m3"
        value_template: "{{ states.sensor.airly.state.split(' ')[1] }}"
      airly_pressure:
        unit_of_measurement: "hPA"
        value_template: "{{ states.sensor.airly.state.split(' ')[2] }}"
      airly_humidity:
        unit_of_measurement: "%"
        value_template: "{{ states.sensor.airly.state.split(' ')[3] }}"
      airly_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ states.sensor.airly.state.split(' ')[4] }}"
      airly_quality:
        value_template: "{{ states.sensor.airly.state.split(' ')[5] }}"

Hi,
Thank you :slight_smile:

I just have one question to you (I’m total noob so far):
How to remove “Airly” sensor icon? I mean, this which contains all informations together?

Hi

sensor.airly:
hidden: true

1 Like

Grate work. I replaced airly_quality with airly_caqi_level as this is source for it and it says LOW when air is good. And low quality suggests it’s not good. Also, you can use the token Airly uses for a widget that can be generated on the map view on their website and poll every 60s (testing does this work now but 120s will work on regular keys).