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

Projects
None yet
4 participants
@dgomes
Copy link
Member

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 added some commits Nov 11, 2018

@dgomes dgomes force-pushed the dgomes:camera_push.webhook branch from e4203d5 to 98e13dc Nov 11, 2018

dgomes added some commits Nov 21, 2018

@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'

This comment has been minimized.

@balloob

balloob Nov 27, 2018

Member

not used

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

This comment has been minimized.

@balloob

balloob Nov 27, 2018

Member

'push' ? Pass the entity name.

camera.image_field)
return

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

This comment has been minimized.

@balloob

balloob Nov 27, 2018

Member

file.read() is doing I/O

This comment has been minimized.

@dgomes

dgomes Nov 27, 2018

Member

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,

This comment has been minimized.

@balloob

balloob Nov 27, 2018

Member

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

This comment has been minimized.

@dgomes

dgomes Nov 27, 2018

Member

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

@balloob balloob merged commit a039c32 into home-assistant:dev Nov 28, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.1%) to 92.927%
Details

@wafflebot wafflebot bot removed the Ready for review label Nov 28, 2018

@balloob balloob referenced this pull request Dec 12, 2018

Merged

0.84 #19215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment