Skip to content

Amcrest switch platform#7876

Closed
dparker18 wants to merge 7 commits into
home-assistant:devfrom
dparker18:amcrest-switch-platform
Closed

Amcrest switch platform#7876
dparker18 wants to merge 7 commits into
home-assistant:devfrom
dparker18:amcrest-switch-platform

Conversation

@dparker18
Copy link
Copy Markdown

Description:

Added new amcrest switch platform to control your camera's motion detection setting. For example, disable it based on device presence.

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

Example entry for configuration.yaml (if applicable):

# Example configuration.yaml entry
switch:
  - platform: amcrest
    host: IP_ADDRESS
    username: USERNAME
    password: PASSWORD

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][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @dparker18,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@mention-bot
Copy link
Copy Markdown

@dparker18, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @robbiet480 to be potential reviewers.

_LOGGER.debug("Pulling Motion Detection data from %s sensor.", self._name)
detection = self._camera.is_motion_detector_on()
self._state = STATE_ON if detection else STATE_OFF
#self._attrs['Motion Detection Config'] = self._camera.motion_detection
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '


def update(self):
"""Update Motion Detection state."""
_LOGGER.debug("Pulling Motion Detection data from %s sensor.", self._name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (82 > 79 characters)

self._camera.motion_detection = 'false'


def update(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

self._camera.motion_detection = 'true'


def turn_off(self, **kwargs):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

return self._state == STATE_ON


def turn_on(self, **kwargs):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

self._state = STATE_UNKNOWN


@property
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

#self._attrs = {}
self._camera = camera
self._name = device_info.get(CONF_NAME)
#self._icon = 'mdi:{}'.format(SENSOR_TYPES.get(self._sensor_type)[2])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '


def __init__(self, device_info, camera):
"""Initialize the switch."""
#self._attrs = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '

"""Representation of a switch to toggle on/off motion detection."""


def __init__(self, device_info, camera):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)


import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_HOST, CONF_NAME, CONF_USERNAME, CONF_PASSWORD, CONF_PORT, STATE_UNKNOWN, STATE_OFF, STATE_ON)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (131 > 79 characters)

def update(self):
"""Update Motion Detection state."""
_LOGGER.debug("Pulling Motion Detection data from %s sensor.",
self._name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Copy link
Copy Markdown
Contributor

@tchellomello tchellomello left a comment

Choose a reason for hiding this comment

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

Nice PR!!

config.get(CONF_HOST), config.get(CONF_PORT),
config.get(CONF_USERNAME), config.get(CONF_PASSWORD)).camera

try:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@balloob
Copy link
Copy Markdown
Member

balloob commented Jun 5, 2017

I don't want to add any more amcrest platforms until the amcrest auth is generalized into a component instead of requiring each platform get the auth set in it's config.

amcrest:
  username: XX
  password: YY

sensor:
  platform: amcrest

camera:
  platform: amcrest

@dparker18
Copy link
Copy Markdown
Author

I can take a stab at it. Is there another component with similar structure you'd recommend looking at?

@tchellomello
Copy link
Copy Markdown
Contributor

tchellomello commented Jun 5, 2017

@cmsimike
Copy link
Copy Markdown
Contributor

cmsimike commented Jun 7, 2017

I have been looking forward to this for a while. Thank you for your work!

@tchellomello
Copy link
Copy Markdown
Contributor

@dparker18 I've been working on a new sensor for Amcrest platform too.
I just want to know if you already started to migrate the platform for your PR as requested by @balloob. If not, I'll create a PR with the changes here and then you can adapt your PR to the new format.

If you already started it, I'll wait for your PR and then I'll add the new sensor later.

Thank you!

@dparker18
Copy link
Copy Markdown
Author

dparker18 commented Jun 13, 2017 via email

@tchellomello
Copy link
Copy Markdown
Contributor

@dparker18
I've submitted the PR #8184 that converted the Amcrest component to use a central hub.
If that gets approved, then you can adjust your code. Looking forward to have the switch functionality proposed by you.
Thank you!

@balloob
Copy link
Copy Markdown
Member

balloob commented Jul 14, 2017

@dparker18 the PR by @tchellomello has been merged. Do you have any plans to finish this PR ?

@dparker18
Copy link
Copy Markdown
Author

dparker18 commented Jul 14, 2017 via email

@tchellomello
Copy link
Copy Markdown
Contributor

@dparker18 are you planning to try to include this on 0.50 version? Do you need any help?

@balloob
Copy link
Copy Markdown
Member

balloob commented Aug 12, 2017

This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it.

@balloob balloob closed this Aug 12, 2017
@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.

8 participants