Skip to content
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

Version sensor reports wrong beta version with source pypi #32268

Closed
gadgetchnnel opened this issue Feb 27, 2020 · 2 comments · Fixed by #33044
Closed

Version sensor reports wrong beta version with source pypi #32268

gadgetchnnel opened this issue Feb 27, 2020 · 2 comments · Fixed by #33044

Comments

@gadgetchnnel
Copy link
Contributor

gadgetchnnel commented Feb 27, 2020

The problem

When using a Version sensor with the source set to "pypi" and beta set to true it reports the version incorrectly. Currently the sensor.latest_version sensor in the below config reports 0.106.0 while sensor.latest_beta_version wrongly reports 0.99.3

Environment

  • Home Assistant release with the issue: 0.106.0
  • Last working Home Assistant release (if known): unknown
  • Operating environment (Hass.io/Docker/Windows/etc.): Python venv in Raspbian on RPi 3B+
  • Integration causing this issue: Version
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/version/

Problem-relevant configuration.yaml

sensor:
  - platform: version
    name: Latest Version  
    source: pypi
  - platform: version
    name: Latest Beta Version
    source: pypi
    beta: true

Traceback/Error logs

Additional information

@probot-home-assistant
Copy link

Hey there @fabaff, mind taking a look at this issue as its been labeled with a integration (version) you are listed as a codeowner for? Thanks!

@gadgetchnnel
Copy link
Contributor Author

I've looked through the code, and this looks like it is an issue in the pyhaversion package related to the way it uses the sorted function to sort the releases by version and 0.99.3 gets picked up as the latest version by a purely alphanumeric sort.

It looks like this can be fixed by using the natsorted function from the natsort package instead which applied a "natural" sorting and seems to pick up the correct version.
I'll raise an issue over at the pyhaversion repo for this.

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

Successfully merging a pull request may close this issue.

3 participants