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

Fix Fully Kiosk service call config entry handling #85275

Merged
merged 2 commits into from Jan 6, 2023

Conversation

cgarwood
Copy link
Member

@cgarwood cgarwood commented Jan 6, 2023

Proposed change

It's possible for a fully_kiosk device entry to have multiple config_entries listed (especially if using device tracking integrations like unifi or netgear). The existing service code assumed there would only be one config entry listed for the device. This fixes that to iterate through the config_entries for the device until we find the fully_kiosk 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)
  • 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

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:

@@ -47,10 +47,19 @@ async def execute_service(
for target in call.data[ATTR_DEVICE_ID]:
device = registry.async_get(target)
if device:
Copy link
Member

Choose a reason for hiding this comment

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

For a future PR, this should probably raise if a user has pointed it at a non-existing device.

It can also be re-written to a guard clause to save on indentation

if device is None:
    raise HomeAssistantError("Non-existing device")

coordinator = hass.data[DOMAIN][key]
# fully_method(coordinator.fully, *args, **kwargs) would make
# test_services.py fail.
await getattr(coordinator.fully, fully_method.__name__)(
Copy link
Member

Choose a reason for hiding this comment

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

Also for a future PR, but why pass in a method just to fetch it's name?

@balloob balloob added this to the 2023.1.1 milestone Jan 6, 2023
@balloob balloob merged commit cf92142 into home-assistant:dev Jan 6, 2023
balloob pushed a commit that referenced this pull request Jan 6, 2023
* Make sure we're getting the fully_kiosk config entry

* Make sure we're getting the fully_kiosk config entry
@balloob balloob mentioned this pull request Jan 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2023
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.

Fully Kiosk service to change URLs Error
2 participants