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

Add config flow to fritzbox_callmonitor #40736

Merged

Conversation

springstan
Copy link
Member

@springstan springstan commented Sep 28, 2020

Breaking change

Proposed change

Adds the ability to set up the fritzbox_callmonitor integration via a config flow and adds the ability to import from YAML to a config entry.

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
sensor:
  - platform: fritzbox_callmonitor
    name: Phone
    username: my_username
    password: my_password
    phonebook: 0
    prefixes:
      - '+49'
      - '+4989'
      - '089'

Additional information

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@springstan springstan changed the title Add config flow fritzbox_callmonitor Add config flow to fritzbox_callmonitor Sep 28, 2020
@springstan
Copy link
Member Author

I will add tests for this integration as soon as I am sure that this config flow satisfies all standards. Therefore any feedback or comments about the config flow and the integrations itself is greatly appreciated 😄

@springstan springstan marked this pull request as ready for review September 29, 2020 17:30
@springstan springstan mentioned this pull request Oct 2, 2020
21 tasks
@Kane610
Copy link
Member

Kane610 commented Oct 3, 2020

I think if you can avoid a breaking change initially it's a good thing. You can do import from platforms to config entry just as well from the init https://github.com/home-assistant/core/pull/26587/files

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Couple of changes necessary 👍 Already looking really good

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Requires tests of the config flow to be added.

@springstan
Copy link
Member Author

Removing the breaking change paragraph and label since this breaking change has been merged with #39995

@springstan springstan mentioned this pull request Dec 6, 2020
21 tasks
@springstan springstan removed the waiting-for-upstream We're waiting for a change upstream label Dec 7, 2020
@balloob balloob merged commit 566058f into home-assistant:dev Jan 27, 2021
Copy link
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.

Nice! Some comments.

try:
return self.number_dict[prefix + number.lstrip("0")]
except KeyError:
pass
Copy link
Member

Choose a reason for hiding this comment

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

We should return None explicitly in the last case.

"homeassistant.components.fritzbox_callmonitor.base.FritzPhonebook.modelname",
return_value=MOCK_PHONEBOOK_NAME_1,
), patch(
"homeassistant.components.fritzbox_callmonitor.config_flow.FritzConnection.__init__",
Copy link
Member

Choose a reason for hiding this comment

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

Normally the class name is patched and not the init method. Then the return value of that mock, of the class, can be specced with attributes that have return values or side effects as needed.

port=self._port,
sensor=self,
)
self._monitor.connect()
Copy link
Member

Choose a reason for hiding this comment

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

The connect does blocking I/O by creating and connecting a socket. This needs to run in the executor via hass.async_add_executor_job.

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

Successfully merging this pull request may close these issues.

5 participants