Airly integration [AppDaemon]

Script adds to HA sensors with data from Airly via MQTT Discovery with entity registry support.

Airly

Script arguments:

  • airly_apikey - Airly API key, string (required)
  • latitude - latitude, float (required)
  • longitude - longitude, float (required)
  • retain - retain true or false for MQTT, boolean, default false (optional)
  • interval - update interval, integer, default 5 min. (optional)
  • sensors - dictionary of sensors to add, default pm1, pm25, pm10, caqi
    (optional), available sensors: pm1, pm25, pm10, caqi,
    temperature, humidity, pressure

Configuration example:

# apps.yaml
airly:
  module: airly
  class: Airly
  airly_apikey: 12345678910
  latitude: 52.2323788
  longitude: 21.0439212
  retain: false
  interval: 10
  sensors:
    - pm1
    - pm25
    - pm10
    - caqi
    - temperature
    - humidity
    - pressure

Download script: https://github.com/bieniu/home-assistant-config/blob/master/apps/airly.py

Nice work. But I’m wondering why you choose the appdaemon/mqtt way and not a custom_component?

Because of my poor Python skill.

Not a good programmer myself but the code looks good. There’s a small learning curve to write custom_components but it’s not that difficult. Sometime ago another user wrote a very similar sensor called NILU. You should be able to adapt it as the difference is just the get/parse the json from the site API.

Thanks. Write a custom component is my next step in learning Python. I will look at this NILU component.

Hi

Maciek, for some reasons, this don’t work for me…
Installed via HACS.
I copied and changed API key, lat/long, as in description. Ofc, in /config/appdeamon/apps/apps.yaml
Rebooted, sensors don’t exists… Any idea?

Do you have mqtt discovery correctly configured?

HA!
This was the reason!

Dzięki wielkie!

BTW, any idea why I have 2 airly sensors each?
One have no value, but second works great.

P.S.
Maybe it’s from history only and later it will dissapear. Need to check it.

EDIT2:
Nope, I removed history and still 2 sensors vibile.

Did you change latitude and longitude? If yes you have to remove old entities in entities registry.

Hi Maciek

Actually, I didn’t change location.
I removed those unwanted sensors, but they reappeared.

Unfortunatelly there is nothing in logs :confused:

You have to check what config topics are retained on MQTT broker:

mosquitto_sub -h <MQTT_BROKER_IP> -p 1883 -u <USERNAME> -P <PASSWORD> -v -t '<DISCOVERY_PREFIX/#'

and delete this unnecessary:

mosquitto_pub -h <MQTT_BROKER_IP> -p 1883 -u <USERNAME> -P <PASSWORD> -r -t '<TOPIC>' -m ''

You can also switch Airly AppDaemon integration to custom component Airly custom integration - air quality data

Oookk… This killed me.
I need to learn how to do it, but give me some time :slight_smile: