Skip to content

Commit

Permalink
Merge pull request #185 from twrecked/take-snapshot-service
Browse files Browse the repository at this point in the history
add request snapshot service
  • Loading branch information
twrecked authored Mar 17, 2020
2 parents 8013d6a + 8d1ff38 commit 52f83ba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
aarlo/pyaarlo
0.6.17: Add request_snapshot webservice
0.6.16: Fix last_image so lovelace card works
Arlo Baby: fix effect switching
0.6.15: Copied services into aarlo domain
Expand Down
4 changes: 2 additions & 2 deletions custom_components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"aarlo": {
"version": "0.6.16",
"version": "0.6.17",
"local_location": "/custom_components/aarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand All @@ -18,7 +18,7 @@
]
},
"pyaarlo": {
"version": "0.6.16",
"version": "0.6.17",
"local_location": "/custom_components/aarlo/pyaarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/pyaarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN

__version__ = '0.6.16'
__version__ = '0.6.17'

_LOGGER = logging.getLogger(__name__)

Expand Down
26 changes: 26 additions & 0 deletions custom_components/aarlo/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
WS_TYPE_LIBRARY = 'aarlo_library'
WS_TYPE_STREAM_URL = 'aarlo_stream_url'
WS_TYPE_SNAPSHOT_IMAGE = 'aarlo_snapshot_image'
WS_TYPE_REQUEST_SNAPSHOT = 'aarlo_request_snapshot'
WS_TYPE_VIDEO_DATA = 'aarlo_video_data'
WS_TYPE_STOP_ACTIVITY = 'aarlo_stop_activity'
WS_TYPE_SIREN_ON = 'aarlo_camera_siren_on'
Expand All @@ -126,6 +127,10 @@
vol.Required('type'): WS_TYPE_SNAPSHOT_IMAGE,
vol.Required('entity_id'): cv.entity_id
})
SCHEMA_WS_REQUEST_SNAPSHOT = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
vol.Required('type'): WS_TYPE_REQUEST_SNAPSHOT,
vol.Required('entity_id'): cv.entity_id
})
SCHEMA_WS_VIDEO_DATA = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
vol.Required('type'): WS_TYPE_VIDEO_DATA,
vol.Required('entity_id'): cv.entity_id
Expand Down Expand Up @@ -253,6 +258,10 @@ async def async_camera_service(call):
WS_TYPE_SNAPSHOT_IMAGE, websocket_snapshot_image,
SCHEMA_WS_SNAPSHOT_IMAGE
)
hass.components.websocket_api.async_register_command(
WS_TYPE_REQUEST_SNAPSHOT, websocket_request_snapshot,
SCHEMA_WS_REQUEST_SNAPSHOT
)
hass.components.websocket_api.async_register_command(
WS_TYPE_VIDEO_DATA, websocket_video_data,
SCHEMA_WS_VIDEO_DATA
Expand Down Expand Up @@ -615,6 +624,23 @@ async def websocket_snapshot_image(hass, connection, msg):
connection.send_message(websocket_api.error_message(
msg['id'], 'image_fetch_failed', 'Unable to fetch image'))

@websocket_api.async_response
async def websocket_request_snapshot(hass, connection, msg):
camera = get_entity_from_domain(hass, DOMAIN, msg['entity_id'])
_LOGGER.debug('request_snapshot_image for ' + str(camera.unique_id))

try:
await camera.async_request_snapshot()
connection.send_message(websocket_api.result_message(
msg['id'], {
'snapshot requested'
}
))

except HomeAssistantError:
connection.send_message(websocket_api.error_message(
msg['id'], 'image_fetch_failed', 'Unable to fetch image'))


@websocket_api.async_response
async def websocket_video_data(hass, connection, msg):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

_LOGGER = logging.getLogger('pyaarlo')

__version__ = '0.6.16'
__version__ = '0.6.17'


class PyArlo(object):
Expand Down

0 comments on commit 52f83ba

Please sign in to comment.