Skip to content

Add Garmin Connect integration#30792

Merged
balloob merged 45 commits into
home-assistant:devfrom
cyberjunky:garmin-connect
Jan 27, 2020
Merged

Add Garmin Connect integration#30792
balloob merged 45 commits into
home-assistant:devfrom
cyberjunky:garmin-connect

Conversation

@cyberjunky
Copy link
Copy Markdown
Contributor

@cyberjunky cyberjunky commented Jan 15, 2020

Description:

Provides sensors for quite a few values exposed in Garmin Connect.

Implemented async and configflow, dropped yaml cfg for now

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11752

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@cyberjunky
Copy link
Copy Markdown
Contributor Author

Looking into flake8 failure.

@cyberjunky
Copy link
Copy Markdown
Contributor Author

Need to decide about correct/wanted config name for the resources.
I'm now using the home-assistant's native in the code:

CONF_MONITORED_CONDITIONS

But FitBit uses a local declared:

CONF_MONITORED_RESOURCES = "monitored_resources"

And I believe there is also a:

CONF_RESOURCES

Any suggestion/preferences?

@cyberjunky
Copy link
Copy Markdown
Contributor Author

Need to decide about correct/wanted config name for the resources.
I'm now using the home-assistant's native in the code:

CONF_MONITORED_CONDITIONS

Any suggestion/preferences?

Doing a fgrep -R inside the components directory shows that the usage of CONF_MONITORED_CONDITIONS is the highest, so sticking with that one.

@cyberjunky cyberjunky changed the title WIP: Add Garmin Connect integration Add Garmin Connect integration Jan 15, 2020
@balloob
Copy link
Copy Markdown
Member

balloob commented Jan 15, 2020

We're phasing out the usage of monitored conditions per ADR-003. Please remove that support.

Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please use the core interfaces in the test to make them more robust.

Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread homeassistant/components/garmin_connect/__init__.py Outdated
@paularmstrong
Copy link
Copy Markdown

Just want to poke in and say thanks @cyberjunky for diving into this and @MartinHjelmare for all of your patience and assistance on the code review.

Really looking forward to having this integration for myself!

Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
@cyberjunky
Copy link
Copy Markdown
Contributor Author

I see this error in the CI logs pytest for python37:
Is this something I can/need to fix?

import file mismatch:
imported module 'test_config_flow' has this __file__ attribute:
  /__w/1/s/tests/components/garmin_connect/test_config_flow.py
which is not the same as the test file we want to collect:
  /__w/1/s/tests/components/netatmo/test_config_flow.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules

@MartinHjelmare
Copy link
Copy Markdown
Member

The netatmo integration is missing an init module in its test package.

https://github.com/home-assistant/home-assistant/tree/dev/tests/components/netatmo

If you have time, you can open a separate PR and just add an __init__.py module in that directory.

@cyberjunky
Copy link
Copy Markdown
Contributor Author

Done #31189

Comment thread homeassistant/components/garmin_connect/__init__.py Outdated
Comment thread homeassistant/components/garmin_connect/__init__.py Outdated
Comment thread homeassistant/components/garmin_connect/__init__.py Outdated
Comment thread homeassistant/components/garmin_connect/__init__.py Outdated
Comment thread homeassistant/components/garmin_connect/config_flow.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread homeassistant/components/garmin_connect/sensor.py Outdated
Comment thread tests/components/garmin_connect/__init__py Outdated
Comment thread homeassistant/components/garmin_connect/strings.json Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@cyberjunky
Copy link
Copy Markdown
Contributor Author

I think I have applied all requested changes, I have one thing left; This change let the test_config_flow mock and the check fail again for the already configured test:

        await self.async_set_unique_id(unique_id)
        self._abort_if_unique_id_configured()

        # entries = self._async_current_entries()
        # for entry in entries:
        #     if entry.data[CONF_ID] == unique_id:
        #         return self.async_abort(reason="already_configured")

Comment thread tests/components/garmin_connect/test_config_flow.py Outdated
@balloob balloob merged commit 4e2737b into home-assistant:dev Jan 27, 2020
@cyberjunky cyberjunky deleted the garmin-connect branch January 27, 2020 20:03
@lock lock Bot locked and limited conversation to collaborators Jan 28, 2020
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.

5 participants