Solved: Airvisual Node Pro Air Quality Monitor Support

There are many calculators already on the web which I’m sure could be utilized as a web service to do this without implementing the formula. Most only need to know the current µg/m3 as given by the API.

Again I direct you to https://aqicn.org/calculator/

1 Like

So I’m trying to get it going your way… Let me ask you, how did you mount the samba folder within hass.io? If you put it within the fstab inside the container, it will be overwritten whenever restarting, no? If you do it on the filesystem, you’d need to map it to the container… I tried to map it inside the share directory, but it wasn’t visible from inside the container.

I mapped it directly on the filesystem using this HowTo : https://help.ubuntu.com/community/Samba/SambaClientGuide

I created a folder “airvisual” inside /usr/share/hassio/share and mapped it with mount -t cifs command

Then the files are available in /config/airvisual on HA

1 Like

Okay, so I finally got around to doing this and it works pretty well. A couple hints for anyone who wants to do it after me:

  1. Latest versions of Ubuntu do not include CIFS (Samba) mount command by default, you must install it with the commands
apt update
apt install cifs-utils
  1. Airvisual node requires v1 SMB, so make sure you include the argument for it in your fstab entry (mine wouldn’t mount without it). Here’s the syntax I used:
//YOUR_AIRVISUAL_IP/airvisual /usr/share/hassio/config/avnodehome cifs credentials=/etc/avnode.conf,vers=1.0,noexec 0 0

Also, I had no luck getting homeassistant to recognize the folder unless I mounted it using fstab, even if it was mounted correctly. Your mileage may vary, but this is what worked for me. The /etc/avnode.conf file (or whatever filename you want to use) containing the username and password looks like:

username=airvisual
password=YOUR_AIRVISUAL_PASSWORD

If you want to mount your airvisual directory into another folder than your config folder (such as your share folder in the example below), you will need to add this line to your configuration.yaml:

  whitelist_external_dirs:
    - /share
  1. As I like using the AirVisual Card in lovelace, I also made a sensor to use for Air Pollution Level. It looks like this:
  - platform: template
    sensors:
      home_air_pollution:
        friendly_name: "Home Air Pollution Level"
        value_template: >-
          {% if states('sensor.home_air_quality')|float < 50 %}
            Good
          {% elif states('sensor.home_air_quality')|float < 100 and states('sensor.home_air_quality')|float >= 50 %}
            Moderate
          {% elif states('sensor.home_air_quality')|float < 150 and states('sensor.home_air_quality')|float >= 100 %}
            Unh. Sens. Groups
          {% elif states('sensor.home_air_quality')|float < 200 and states('sensor.home_air_quality')|float >= 150 %}
            Unhealthy
          {% elif states('sensor.home_air_quality')|float < 250 and states('sensor.home_air_quality')|float >= 200 %}
            Very Unhealthy
          {% elif states('sensor.home_air_quality')|float < 500 and states('sensor.home_air_quality')|float >= 250 %}
            Hazardous
          {% else %}
            Off the Charts
          {% endif %} 

For the main_pollutant option I just use the one from the nearest public airvisual node, not from my node pro which doesn’t (and can’t) capture this.

Hi all. My wife and I recently bought a Pro Node, so I will be adding official support for it soon. There’s some work that needs to be done first (e.g., https://github.com/home-assistant/home-assistant/pull/32072), but wanted to drop you a line and let you know it’s on the way.

3 Likes

FYI, I’ve submitted a PR to add support for Node/Pro units: https://github.com/home-assistant/core/pull/32815

2 Likes

Cool! Look forward to testing it! TBH the SMB based template sensor is working very well, much better than I ever expected it to, but it will be a lot more practical for people to use a classical integration.

No doubt! The integration will use Samba, as well, but I wouldn’t have gotten the idea for wrapping that into an official integration without the work done here. :pray:t2:

1 Like

Hi @bachya

thanks for the support and development for airvisual ,
on Home Assistant 0.104.3
i sign to airvisual created an api key nothing special ,
follow the documentation i added to configuration file:

airvisual:
  api_key: !secret airvisual_api

getting error:

2020-03-20 23:55:54 ERROR (MainThread) [homeassistant.setup] Setup failed for airvisual: No setup function defined.

any idea?

That configuration schema appeared in 0.107.0; upgrade and it should work.

hi, does it work with Airviusal node pro now? Thank you

Not yet – see above.

Great news ! Thanks for your work <3

1 Like

Thank you for your work!
Just started in HA, so Pro integration will be very helpful

Trying to get Airvisual to work. Homeassistant 0.107.7
Getting the following in the log.
Logger: homeassistant.components.airvisual
Error while retrieving data: city_not_found

On the Airvisual site I can see the calls to the api increment.
Tried with and without geographies: set same result both using a api key
Configuration.yaml

airvisual:
    api_key: 24ecdedd-.........
    # geographies:
    #     city: Bend
    #     state: Oregon
    #     country: USA

When I try the following with my key I get proper results.

 curl --location --request GET 'api.airvisual.com/v2/city?city=Bend&state=Oregon&country=USA&key={24ecdedd-.........}'
{"status":"success","data":{"city":"Bend","state":"Oregon","country":"USA","location":{"type":"Point","coordinates":[-121.312554,44.063916]},"current":{"weather":{"ts":"2020-03-30T22:00:00.000Z","tp":4,"pr":1013,"hu":75,"ws":7.2,"wd":230,"ic":"09d"},"pollution":{"ts":"2020-03-30T22:00:00.000Z","aqius":0,"mainus":"p2","aqicn":0,"maincn":"p2"}}}}

Thanks

Figured it out.
First time I had configured it incorrectly with the wrong city. For some reason when I corrected this it never changed in core.entity_registry
Steps to correct.

  1. Commented out Airvisual: entry, restarted hass.io
  2. removed airvisula entries from core.config_entries and core.entity_registry
  3. un-commented Airvisual: entry and restarted hass.io

Hi bachya, I’m tracking your progress everyday and finally saw ‘Done’ yesterday. This would be crucial for my automations with purifier, based on AQI, and windows opening, based on CO2. Thank you very much for your efforts!

1 Like

Hi @bachya, thanks you again for doing this. Let me please ask if you think this will be introduced next release?

Yes, I anticipate this will go out with 0.110.0.

1 Like

I’ve just updated to Home Assistant 0.110, and followed this guide:

To enable the integration and gather from a Node/Pro unit, add the following lines to your configuration.yaml file:
airvisual:
ip_address: YOUR_NODE_PRO_IP_ADDRESS
password: YOUR_NODE_PRO_SAMBA_PASSWORD

However, I got the error:

Invalid config for [airvisual]: [ip_address] is an invalid option for [airvisual]. Check: airvisual->airvisual->ip_address. (See /config/configuration.yaml, line 36).

Update: I can add the node Pro though Integrations section. Thank you