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

Enable/Disable Motion detection for Foscam Cameras #8582

Merged
merged 14 commits into from
Aug 1, 2017

Conversation

viswa-swami
Copy link
Contributor

Description:

Enable_Motion_Detection and Disable_Motion_Detection were services added to the Camera component in 0.48.1.

Support was added for Arlo cameras in one of the earlier releases. Now adding support for Foscam cameras to enable/disable motion detection.

Based on comments from @balloob, I have changed the code to use a foscam 3rd party library instead of implementing the foscam protocol in HASS.

Updated the requirements_all.txt to reflect the pyfoscam dependency/requirement.

This code has been tested with foscam camera in my home.

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New 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:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

…This support was added in 0.48.1 as a generic service for cameras. Motion detection can be enabled/disabled for foscam cameras with this code-set.
…lk to foscam, used a 3rd party foscam library to communicate with it. This library already has support to enable/disable motion detection and also APIs to change the motion detection schedule etc. Need to add more support in the pyfoscam 3rd party library for checking if motion was detected or even if sound was detected. Once that is done, we can add that into HASS as well.
@mention-bot
Copy link

@viswa-swami, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ishults, @SEJeff and @fabaff to be potential reviewers.


_LOGGER.info("Using the following URL for %s: %s",
self._name, uri_template.format('***', '***'))
self._foscam_session = FoscamCamera(ip_address, port, self._username, self._password)

Choose a reason for hiding this comment

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

line too long (93 > 79 characters)

@balloob
Copy link
Member

balloob commented Jul 25, 2017

Ok to merge once the lint and requirement builds pass. See Travis details for issues.

Copy link

@myusuf3 myusuf3 left a comment

Choose a reason for hiding this comment

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

you need to remove the requests import and this should be good to go. Since you aren't using it anymore @viswa-swami

def camera_image(self):
"""Return a still image reponse from the camera."""
# Send the request to snap a picture and return raw jpg data
# Handle exception if host is not reachable or url failed
try:
response = requests.get(self._snap_picture_url, timeout=10)
Copy link

Choose a reason for hiding this comment

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

You need to remove import requests above for tests to pass.

…t that i have. Generated using the gen_requirements_all.py script
self._name, uri_template.format('***', '***'))
from foscam import FoscamCamera

self._foscam_session = FoscamCamera(ip_address, port, self._username, self._password)

Choose a reason for hiding this comment

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

line too long (93 > 79 characters)

@balloob balloob merged commit e40388e into home-assistant:dev Aug 1, 2017
@balloob
Copy link
Member

balloob commented Aug 1, 2017

Awesome 🎉 🐬

@fabaff fabaff mentioned this pull request Aug 12, 2017
dethpickle pushed a commit to dethpickle/home-assistant that referenced this pull request Aug 18, 2017
* Added support to enable/disable motion detection for foscam cameras. This support was added in 0.48.1 as a generic service for cameras. Motion detection can be enabled/disabled for foscam cameras with this code-set.

* Fixed the violation identified by hound-bot

* Fixed the comment posted by HoundCI-Bot regarding using imperative mood statement for pydocstyle

* Fixed the error that travis-ci bot found.

* As per comment from @balloob, Instead of directly using the URL to talk to foscam, used a 3rd party foscam library to communicate with it. This library already has support to enable/disable motion detection and also APIs to change the motion detection schedule etc. Need to add more support in the pyfoscam 3rd party library for checking if motion was detected or even if sound was detected. Once that is done, we can add that into HASS as well.

* Lint

* Removed the requests library import which is not used anymore

* Updating requirements_all.txt based on the code-base of home assistant that i have. Generated using the gen_requirements_all.py script

* Updating requirements_all.txt and requirements_test_all.txt generated by gen_requirements_all.py after latest pull from origin/dev

* Updated requirements_all.txt with script

* Updated the foscam camera code to fix lint errors

* Fixed houndci violation
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
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.

7 participants