Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make AirVisual platform async + other adjustments #14943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 14, 2018

Conversation

bachya
Copy link
Contributor

@bachya bachya commented Jun 12, 2018

Description:

This PR makes the following changes to AirVisual:

  • Bumps the underlying library (pyairvisual) to 1.0.0.
  • Makes the platform async.
  • Removes the radius configuration parameter (no longer used in the AirVisual API).
  • Fixes a bug with colliding unique IDs between U.S. and Chinese sensors.
  • Adds in support for scan_interval.
  • Rearchitects the platform the be more consistent in style with other sensor platforms.

BREAKING CHANGES

First, the radius configuration parameter no longer does anything and has been removed. This won't negatively impact any existing integrations, but it should still be noted.

Second, this PR will modify the unique IDs for each sensor to correctly include the locale. New unique IDs will now include _us_ and _cn_ – example:

sensor.us_air_quality_index:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_us_air_quality_index
sensor.chinese_main_pollutant:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_cn_main_pollutant
sensor.us_air_pollution_level:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_us_air_pollution_level
sensor.chinese_air_pollution_level:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_cn_air_pollution_level
sensor.chinese_air_quality_index:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_cn_air_quality_index
sensor.us_main_pollutant:
  config_entry_id:
  name:
  platform: airvisual
  unique_id: Los Angeles,California,USA_us_main_pollutant

Related issue (if applicable): N/A

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5534

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: airvisual
    api_key: API_KEY
    show_on_map: false
    city: Los Angeles
    state: California
    country: USA

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@bachya bachya changed the title Make AirVisual async + other adjustments Make AirVisual platform async + other adjustments Jun 12, 2018
_LOGGER.error(
"Can't retrieve data for location: %s (%s)", location,
err)
self.city = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you reset all these things ? If something is misconfigured, we should not just try to get the nearest city. We should just not update and mark as available=False.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point; not sure what I was thinking there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you're okay with the method I use in the latest commit.

@balloob balloob merged commit 0e7d284 into home-assistant:dev Jun 14, 2018
@balloob
Copy link
Member

balloob commented Jun 14, 2018

perfect.

@ghost ghost removed the in progress label Jun 14, 2018
@balloob balloob mentioned this pull request Jun 22, 2018
@bachya bachya deleted the airvisual-async branch June 22, 2018 18:26
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants