Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

[WIP] Updates to the WAQI component #1

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Conversation

sbach
Copy link
Owner

@sbach sbach commented Oct 26, 2022

Draft changes checklist

  • Contact the current maintainer.
  • Ensure all the required properties/methods for SensorEntity are defined.
  • Add strings and translations for UI.
  • Read and follow all the official guidelines.
  • Take screen captures of the config flow UI.
  • Fill-up the below, to use in the future upstream PR.

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@sbach
Copy link
Owner Author

sbach commented Oct 26, 2022

@andrey-git, are you still actively maintaining this component?

I would love to help maintain it, as well as as its dependent Python library (see: https://github.com/sbach/waqi-client-async, for a proposal).

My initial goal for these updates was to provide support for configuration from the UI.

@bouwew
Copy link

bouwew commented Mar 8, 2023

The config_flow needs some headers, these can be added via the file strings.json.

@bouwew
Copy link

bouwew commented Mar 8, 2023

Question: what is the reason that you backend code cannot find my city?
I'm trying to add this station https://aqicn.org/station/@113074 but when I enter Doetinchem or Doetinchem, Gelderland, Netherland, no stations are found.

@bouwew
Copy link

bouwew commented Mar 9, 2023

I've turned your code into a custom_component, see here: https://github.com/bouwew/waqi-test
Copy as you like :)

I will try to extend the config_flow, add a choice between:

  • searching for a station, via entering a string, and
  • adding the station directly via entering the feed-id.

@sbach
Copy link
Owner Author

sbach commented Mar 13, 2023

Thanks @bouwew for having a look at my experiments, the suggestions, and iterating over my work!

I had started coding this as I was in the same position as you, where the in-tree integration stopped working reliably.

While I am still using it for my own needs, I did originally intend to further the work and attempt to mainline my changes. I later noticed this custom component and figured out they may be more complete that my work.

I will take a look at the state of things, just like you seem to be doing. I think it would be worth it to start discussing with everyone and get some updates mainline. I would certainly love to participate!

@sbach
Copy link
Owner Author

sbach commented Mar 13, 2023

Question: what is the reason that you backend code cannot find my city? I'm trying to add this station https://aqicn.org/station/@113074 but when I enter Doetinchem or Doetinchem, Gelderland, Netherland, no stations are found.

Provided we end-up furthering my work, I will be sure to test and cover this case.

@bouwew
Copy link

bouwew commented Mar 13, 2023

Thanks for getting back to me!
The custom_component you mention above, is using request as the basis, this is too old and also not async so not good for use in HA.
I've looked at all the available waqi-code realizations out there, they are all more or less the same. So shouldn't be too hard to come to something that's better.

FYI, I have the config_flow with choices between searching and entering the feed-id working :)
Only the error-handling would need some more TLC.
More info later tonight...

@bouwew
Copy link

bouwew commented Mar 13, 2023

Looks like this is working: https://github.com/bouwew/waqi-test

I can add my local feed with this: https://api.waqi.info/feed/A113074/?token=xxxxxxxxx
And I can add dedicated feeds like https://api.waqi.info/feed/@4567/?token=xxxxxxxxx
And keyword searching works as well.

I still need to see if the added local feed and the single added station (added via keyword search) update properly every 900 secs.

The error-handling is still TODO.

@iridris
Copy link

iridris commented May 3, 2023

Is there anything I could do to assist with moving this along? I'm not much of a programmer but could help test at least.

@xrxca
Copy link

xrxca commented May 26, 2023

A couple of minor suggestions/requests:

  1. the ability to directly specify a station number (must allow negative ids) (the only station with 25 miles of my site uses a negative id, and no search seems to find it)
  2. the ability to simply use the local lat/lng values to find the nearest station via the /feed/geo:lat;lng/?token=:token api.
  3. another way to use the local lat/lng would be to specify lat_offset and lng_offset values then if both offsets are >0 calculate the lat1 as local_lat-lat_offset and lat2 as local_lat+lat_offset and the same for lng then retrieve stations using the /map/bounds?token=:token&latlng=lat1,lng1,lat2,lng2 api, if either of the offsets are zero use the /feed/geo option.

@bouwew
Copy link

bouwew commented May 27, 2023

@xrxca
Please try my updated version: https://github.com/bouwew/waqi-test

I've added the option to enter the station number/id directly (via the config flow).
I've also noticed that when you write here instead of the station number/id it will find the closest station.

@xrxca
Copy link

xrxca commented May 28, 2023 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants