-
-
Notifications
You must be signed in to change notification settings - Fork 38.1k
Camera services arm disarm including Netgear Arlo #7961
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
Changes from 31 commits
705205b
1ef7055
8669c7f
e6deae2
eb11fd8
70808e5
c4a91c9
e2c0113
c1a8382
2775c0e
4b1f36f
49438bb
7f8e914
53dc772
890d7f1
7e477a2
285d9b4
2e1208b
fe2d68e
282487d
a4e5cc1
60aaa52
07b941c
96f0ee7
d304f2b
baab606
27d9c28
5c95020
33362c9
6c97791
488a71e
19c3d62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,17 +9,19 @@ | |
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.arlo import DEFAULT_BRAND, DATA_ARLO | ||
| from homeassistant.components.camera import Camera, PLATFORM_SCHEMA | ||
| from homeassistant.components.ffmpeg import DATA_FFMPEG | ||
| from homeassistant.helpers import config_validation as cv | ||
| from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream | ||
| from homeassistant.components.arlo import DEFAULT_BRAND | ||
| from homeassistant.components.camera import Camera, PLATFORM_SCHEMA | ||
| from homeassistant.components.ffmpeg import DATA_FFMPEG | ||
|
|
||
| DEPENDENCIES = ['arlo', 'ffmpeg'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| CONF_FFMPEG_ARGUMENTS = 'ffmpeg_arguments' | ||
| ARLO_MODE_ARMED = 'armed' | ||
| ARLO_MODE_DISARMED = 'disarmed' | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
| vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string, | ||
|
|
@@ -46,9 +48,10 @@ class ArloCam(Camera): | |
| def __init__(self, hass, camera, device_info): | ||
| """Initialize an Arlo camera.""" | ||
| super().__init__() | ||
|
|
||
| self._camera = camera | ||
| self._base_stn = hass.data['arlo'].base_stations[0] | ||
| self._name = self._camera.name | ||
| self._motion_status = False | ||
| self._ffmpeg = hass.data[DATA_FFMPEG] | ||
| self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS) | ||
|
|
||
|
|
@@ -87,3 +90,27 @@ def model(self): | |
| def brand(self): | ||
| """Camera brand.""" | ||
| return DEFAULT_BRAND | ||
|
|
||
| @property | ||
| def should_poll(self): | ||
| """Camera should poll periodically.""" | ||
| return True | ||
|
|
||
| @property | ||
| def motion_detection_enabled(self): | ||
| """Camera Motion Detection Status.""" | ||
| return self._motion_status | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should return a boolean.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, i will change this code to return a boolean and post for PR |
||
|
|
||
| def set_base_station_mode(self, mode): | ||
| """Set the mode in the base station.""" | ||
| self._base_stn.mode = mode | ||
|
|
||
| def enable_motion_detection(self): | ||
| """Enable the Motion detection in base station (Arm).""" | ||
| self._motion_status = True | ||
| self.set_base_station_mode(ARLO_MODE_ARMED) | ||
|
|
||
| def disable_motion_detection(self): | ||
| """Disable the motion detection in base station (Disarm).""" | ||
| self._motion_status = False | ||
| self.set_base_station_mode(ARLO_MODE_DISARMED) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Describes the format for available camera services | ||
|
|
||
| enable_motion_detection: | ||
| description: Enable the motion detection in a camera | ||
|
|
||
| fields: | ||
| entity_id: | ||
| description: Name(s) of entities to enable motion detection | ||
| example: 'camera.living_room_camera' | ||
|
|
||
| disable_motion_detection: | ||
| description: Disable the motion detection in a camera | ||
|
|
||
| fields: | ||
| entity_id: | ||
| description: Name(s) of entities to disable motion detection | ||
| example: 'camera.living_room_camera' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """The tests for local file camera component.""" | ||
| import asyncio | ||
| from homeassistant.components import camera | ||
| from homeassistant.setup import async_setup_component | ||
|
|
||
|
|
||
| @asyncio.coroutine | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expected 2 blank lines, found 1 |
||
| def test_motion_detection(hass): | ||
| """Test motion detection services.""" | ||
| # Setup platform | ||
| yield from async_setup_component(hass, 'camera', { | ||
| 'camera': { | ||
| 'platform': 'demo' | ||
| } | ||
| }) | ||
|
|
||
| # Fetch state and check motion detection attribute | ||
| state = hass.states.get('camera.demo_camera') | ||
| assert not state.attributes.get('motion_detection') | ||
|
|
||
| # Call service to turn on motion detection | ||
| camera.enable_motion_detection(hass, 'camera.demo_camera') | ||
| yield from hass.async_block_till_done() | ||
|
|
||
| # Check if state has been updated. | ||
| state = hass.states.get('camera.demo_camera') | ||
| assert state.attributes.get('motion_detection') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1