Skip to content

Fix ONVIF config entry unique ID#36008

Merged
MartinHjelmare merged 5 commits intohome-assistant:devfrom
hunterjm:bugfix/onvif-unique-id
May 24, 2020
Merged

Fix ONVIF config entry unique ID#36008
MartinHjelmare merged 5 commits intohome-assistant:devfrom
hunterjm:bugfix/onvif-unique-id

Conversation

@hunterjm
Copy link
Copy Markdown
Member

@hunterjm hunterjm commented May 23, 2020

Proposed change

Fixes issue where some ONVIF devices do not expose MAC address through the API. This falls back to the serial number as the config entry Unique ID, fixing #35883

While testing (adding and removing config entries after commenting out portions of code) I realized that the Event subscription is not ended properly when removing a config entry and will continue attempting to poll the device indefinitely until a Home Assistant reboot. A fix for that is also included in this PR.

While playing around in config flow, I also made password optional which fixes #35904

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

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

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.

For the future, please separate different fixes into different PRs. That will speed up review and time to merge.

Comment thread homeassistant/components/onvif/base.py
Comment thread homeassistant/components/onvif/camera.py
Comment thread homeassistant/components/onvif/config_flow.py
Comment thread homeassistant/components/onvif/config_flow.py Outdated
Comment thread tests/components/onvif/test_config_flow.py Outdated
@hunterjm
Copy link
Copy Markdown
Member Author

hunterjm commented May 24, 2020

Will do RE more than one issue in this PR. The second issue really only changed the schema for one step changing a .Required to a .Optional, which is why it was included, and the event fix was isolated and 3 lines of code.

@frenck frenck modified the milestones: 0.110.2, 0.110.3 May 24, 2020
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.

Great!

@MartinHjelmare MartinHjelmare merged commit bd8848e into home-assistant:dev May 24, 2020
@hunterjm hunterjm deleted the bugfix/onvif-unique-id branch May 25, 2020 00:53
frenck pushed a commit that referenced this pull request May 26, 2020
* fallback to device serial number if no mac available

* make password optional to fix #35904

* update tests to reflect new flow

* fix snake case and AsyncMock

* add comments around why weird things are being done
@frenck frenck mentioned this pull request May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants