Bieniu
(Maciek)
February 24, 2019, 10:20am
1
Script adds to HA sensors with data from Airly via MQTT Discovery with entity registry support.
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
clyra
(Clyra)
February 24, 2019, 10:27am
2
Nice work. But I’m wondering why you choose the appdaemon/mqtt way and not a custom_component?
Bieniu
(Maciek)
February 24, 2019, 10:32am
3
Because of my poor Python skill.
clyra
(Clyra)
February 24, 2019, 10:40am
4
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.
Bieniu
(Maciek)
February 24, 2019, 12:25pm
5
Thanks. Write a custom component is my next step in learning Python. I will look at this NILU component.
sirfalo
(Sir Falo)
July 5, 2019, 9:58pm
6
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?
Bieniu
(Maciek)
July 5, 2019, 11:25pm
7
Do you have mqtt discovery correctly configured?
sirfalo
(Sir Falo)
July 6, 2019, 9:26pm
8
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.
Bieniu
(Maciek)
July 6, 2019, 11:37pm
9
Did you change latitude and longitude? If yes you have to remove old entities in entities registry.
sirfalo
(Sir Falo)
July 7, 2019, 8:29pm
10
Hi Maciek
Actually, I didn’t change location.
I removed those unwanted sensors, but they reappeared.
Unfortunatelly there is nothing in logs
Bieniu
(Maciek)
July 8, 2019, 6:13am
11
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
sirfalo
(Sir Falo)
July 8, 2019, 8:21pm
12
Oookk… This killed me.
I need to learn how to do it, but give me some time