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

Add control of Amcrest indicator light #23986

Merged
merged 1 commit into from
May 31, 2019

Conversation

pnbruckner
Copy link
Contributor

@pnbruckner pnbruckner commented May 19, 2019

Description:

Automatically control the camera's indicator light, turning it on if the audio or video streams are enabled, and turning it off if both streams are disabled.

Enable feature by default but allow it to be disabled by control_light: false in config.

Get brand from camera instead of assuming Amcrest (since this works with other cameras, too.)

Retrieve RTSP URL in update method instead of in stream_source property and in handle_async_mjpeg_stream method.

Related issue (if applicable): None

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

Example entry for configuration.yaml (if applicable):

amcrest:
  - host: IP_ADDRESS_CAMERA
    username: YOUR_USERNAME
    password: YOUR_PASSWORD
    control_light: true

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.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.


def _enable_light(self, enable):
"""Enable or disable indicator light."""
from amcrest import AmcrestError
Copy link
Member

Choose a reason for hiding this comment

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

You can now import things on top, out of functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool! I rebased, moved the imports, tested and force pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pvizeli is this ok now and ready for a merge, or does it still require more review? Thanks!

Enable feature by default but allow it to be disabled by "control_light: false" in config.

Get brand from camera instead of assuming Amcrest (since this works with other cameras, too.)

Retrieve RTSP URL in update method instead of in stream_source property and in handle_async_mjpeg_stream method.

Move amcrest imports from methods to global.
@pnbruckner pnbruckner force-pushed the amcrest-indicator-light branch from 029e008 to 3995275 Compare May 23, 2019 15:09
@balloob balloob merged commit d966e0c into home-assistant:dev May 31, 2019
@pnbruckner pnbruckner deleted the amcrest-indicator-light branch May 31, 2019 20:44
@balloob balloob mentioned this pull request Jun 26, 2019
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