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

Replace token in camera.push with webhook #18380

Merged
merged 7 commits into from
Nov 28, 2018

Conversation

dgomes
Copy link
Contributor

@dgomes dgomes commented Nov 11, 2018

Description:

This moves from the temporary webhook solution to the webhook solution in #16817

Related issue (if applicable): fixes #16817

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#7451

Example entry for configuration.yaml (if applicable):

camera:
  - platform: push
    name: cam1
    timeout: 10
    cache: 5
    webhook_id: my_custom_webhook_id 

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@dgomes dgomes force-pushed the camera_push.webhook branch from e4203d5 to 98e13dc Compare November 11, 2018 17:21
@fabaff fabaff changed the title replace token in camera.push with webhook Replace token in camera.push with webhook Nov 25, 2018
_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = ['http']
RECEIVED_DATA = 'push_camera_received'
Copy link
Member

Choose a reason for hiding this comment

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

not used

hass.http.register_view(CameraPushReceiver(hass,
config[CONF_IMAGE_FIELD]))
try:
hass.components.webhook.async_register(DOMAIN, 'push',
Copy link
Member

Choose a reason for hiding this comment

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

'push' ? Pass the entity name.

camera.image_field)
return

await camera.update_image(data[camera.image_field].file.read(),
Copy link
Member

Choose a reason for hiding this comment

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

file.read() is doing I/O

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's memory, it's not from the filesystem. file is the property that contains the image bytes received by the webhook.

@@ -117,6 +107,15 @@ def __init__(self, hass, name, buffer_size, timeout, image_field,
"""Call when entity is added to hass."""
self.hass.data[PUSH_CAMERA_DATA][self.webhook_id] = self

try:
self.hass.components.webhook.async_register(DOMAIN,
self.entity_id,
Copy link
Member

@balloob balloob Nov 27, 2018

Choose a reason for hiding this comment

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

Why entity id ? This will be shown in the UI, let's do name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, you suggested entity name, I read entity id :(

@balloob balloob merged commit a039c32 into home-assistant:dev Nov 28, 2018
@ghost ghost removed the Ready for review label Nov 28, 2018
@balloob balloob mentioned this pull request Dec 12, 2018
@dgomes dgomes deleted the camera_push.webhook branch April 7, 2022 18:10
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.

4 participants