ToddGreenfield / homebridge-airnow

Homebridge plugin for AirNow Web-API Air Quality Sensor
36 stars 10 forks source link

AQI is always 21 #1

Closed jadomski closed 6 years ago

jadomski commented 6 years ago

No matter which city I choose (Beijing, Singapore, Sydney, Los Angeles) the AQI from AQICN is always 21. The below line never changes in the home bridge output.

[Air Quality] AirNow air quality AQI is: 21

ToddGreenfield commented 6 years ago

@iJaffa what does your config.json section look like?

jadomski commented 6 years ago

Below is my config section, where xxx is the API key I received from AQICN

    "accessories": [{
                       "accessory": "airnow",
                       "name": "Air Quality",
                       "provider": "aqicn",
                       "aqicn_api": "xxx",
                       "aqicn_city": "singapore/south"
                     }]
ToddGreenfield commented 6 years ago

Have you tried the test-aqicn.js script (either download or should already be in the plugin directory)? Be sure to update appropriately. Does that give any errors?

ToddGreenfield commented 6 years ago

Nevermind. I just recreated the issue and get the same thing with your settings. Give me a bit to look into it-

ToddGreenfield commented 6 years ago

I have narrowed this down to the waqi.info API (I believe). If an individuals apikey is used with a specific location "ex. shanghai", the response is always from "Barrie, Ontario" - which is where the 21 is coming from. If an individuals apikey is used using geo-location "ex. here", the response works as intended. If the "demo" apikey is used using geo-location "ex. here", the response works as intended. I will need to do some more testing and potentially contact waqi.info to understand why this is happening. Let me know if you find anything more in your troubleshooting.

jadomski commented 6 years ago

I just did some testing and that seems to be consistent with what I’m experiencing. My IP address currently reports the right location to WAQI but I’m sure it will vary when it dynamically changes.

volschin commented 6 years ago

Seem to be a problem with this part of the API. If you use eg the @6132 instead 'germany/berlin', all works fine for me.

jadomski commented 6 years ago

Are you using it with or without the @ sign in config.json?

ToddGreenfield commented 6 years ago

It looks like the @ works in the config.json. I also tried %40 which works as well. I have not heard back from waqi regarding the API, and am still unable to get the city feed to work for some reason. Everything returns Barrie, Ontario. I suspect because that has an index of 0 and is the first record returned by the API. I should be able to change the way the plugin works, still using the city config param, but leverage the search function of the API instead of feed. That worked well in my early testing in the browser. Give me a few days and I will push a patch out-

ToddGreenfield commented 6 years ago

Opting to not change the code and just update the readme file to use the @code since that is easiest. See below screenshot on how to obtain the correct city code. screen shot 2017-11-29 at 6 24 59 am