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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic fix stream thumbnail #69378

Merged
merged 8 commits into from Apr 7, 2022

Conversation

davet2001
Copy link
Contributor

Proposed change

The new generic camera config flow autodetects image type for still images. But it is not automatic for streams. So if a camera only had a stream_url and no still_image_url, the content_type would be undefined. This caused the thumbnail to fail for a stream #69128.

This PR fixes this by reinstating the content_type field, and defaulting to the user value if the autodetect is skipped.

It also enables the value to be read from YAML.

A small fix is made to the duplicate checking code which was triggering log errors.

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

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.

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:

@project-bot project-bot bot added this to Needs review in Dev Apr 5, 2022
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Apr 5, 2022
@bdraco bdraco added this to the 2022.4.0 milestone Apr 6, 2022
Comment on lines 94 to 99
vol.Optional(
CONF_CONTENT_TYPE,
description={
"suggested_value": user_input.get(CONF_CONTENT_TYPE, "image/jpeg")
},
): str,
Copy link
Member

Choose a reason for hiding this comment

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

Why are we asking the user for input in that case? Do we know when only a stream is given already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The autodetect for content type does not work yet for streams.

This means if the user wants to configure only a stream (no still image) with a content type that is not the default jpeg, then we need to get that setting from the user.

Copy link
Member

Choose a reason for hiding this comment

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

Can we make that a second step, and only show it if we know it's a content type that can be ambiguous ?

Copy link
Member

Choose a reason for hiding this comment

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

We definitely can move it in a second step when we know the still image URL is empty.

@davet2001
Copy link
Contributor Author

@balloob Please let me know if this is what you had in mind and I'll add tests for the new code. I have tested manually ok.

Comment on lines 296 to 299
return self.async_show_form(
step_id="user2",
data_schema=build_schema2({}),
errors={},
Copy link
Member

Choose a reason for hiding this comment

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

Just call the step without user input, and let the step then generate the form if no input is given.

Suggested change
return self.async_show_form(
step_id="user2",
data_schema=build_schema2({}),
errors={},
return await self.async_step_user2(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok done. 92bb1cb

homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/generic/config_flow.py Outdated Show resolved Hide resolved
Dev automation moved this from By Code Owner to Review in progress Apr 7, 2022
@balloob balloob modified the milestones: 2022.4.1, 2022.4.2 Apr 7, 2022
@balloob balloob removed this from the 2022.4.2 milestone Apr 7, 2022
@balloob balloob added this to the 2022.4.1 milestone Apr 7, 2022
@balloob balloob merged commit be8e285 into home-assistant:dev Apr 7, 2022
Dev automation moved this from Review in progress to Done Apr 7, 2022
@balloob balloob mentioned this pull request Apr 7, 2022
balloob pushed a commit that referenced this pull request Apr 7, 2022
@davet2001 davet2001 deleted the generic_fix_stream_thumbnail branch April 7, 2022 22:29
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

Still image not working for generic camera with no still image url
6 participants