-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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 snapshot service to image entity #110057
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
68ebd70
to
4a9164c
Compare
ae0cdba
to
1cf1e69
Compare
7845a05
to
e1c12c9
Compare
@NickM-27 There are merge conflicts, can you please merge or rebase the PR? |
4174078
to
558cb35
Compare
@emontnemery thanks, rebased 👍 |
looks like the failing tests are unrelated to these changes |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, make sure to also update the examples and documentation.
8ccd24e
to
1cb31e4
Compare
Co-authored-by: Erik Montnemery <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @NickM-27 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments in a new PR. Thanks!
# check if we allow to access to that file | ||
if not hass.config.is_allowed_path(snapshot_file): | ||
raise HomeAssistantError( | ||
f"Cannot write `{snapshot_file}`, no access to path; `allowlist_external_dirs` may need to be adjusted in `configuration.yaml`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please break long strings around max 88 characters per line.
f"Cannot write `{snapshot_file}`, no access to path; `allowlist_external_dirs` may need to be adjusted in `configuration.yaml`" | ||
) | ||
|
||
async with asyncio.timeout(IMAGE_TIMEOUT): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What catches TimeoutError
? Only HomeAssistantError
is allowed to leak out from the service handler.
|
||
# check if we allow to access to that file | ||
if not hass.config.is_allowed_path(snapshot_file): | ||
raise HomeAssistantError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be ServiceValidationError
?
https://developers.home-assistant.io/docs/core/platform/raising_exceptions/
"fields": { | ||
"filename": { | ||
"name": "Filename", | ||
"description": "Template of a filename. Variable available is `entity_id`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we remove the entity_id
variable?
* Add service definition for saving snapshot of image entity * Add service to image * Add tests for image entity service * Fix tests * Formatting * Add service icon * Formatting * Formatting * Raise home assistant error instead of single log error * Correctly pass entity id * Raise exception from existing exception * Expect home assistant error * Fix services example * Add test for templated snapshot * Correct icon service config * Set correct type for service template * Remove unneeded Co-authored-by: Erik Montnemery <[email protected]> * remove template * fix imports * Update homeassistant/components/image/__init__.py * Apply suggestions from code review --------- Co-authored-by: Erik Montnemery <[email protected]>
Proposed change
Integrations are moving from using the camera.entity to image.entity but there is not feature parity when it comes to the services offered for the image.entity. This PR adds the snapshot service to the image entity so users are able to save the images offline for their own usage.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: