Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3479716
Added ONVIF camera component
matt2005 Jun 9, 2017
df30ac2
added requirements
matt2005 Jun 9, 2017
d4a7140
corrected long lines
matt2005 Jun 9, 2017
7edc323
fixed indenting
matt2005 Jun 9, 2017
e74001c
fixed indenting
matt2005 Jun 9, 2017
c9d7347
removed bad whitespace
matt2005 Jun 9, 2017
dc5ca01
updated coveragerc
matt2005 Jun 9, 2017
71f47c8
updated requirements
matt2005 Jun 10, 2017
273437e
Added ONVIF camera component
matt2005 Jun 9, 2017
6ae0fff
added requirements
matt2005 Jun 9, 2017
cc8b57c
corrected long lines
matt2005 Jun 9, 2017
2a3bdb5
fixed indenting
matt2005 Jun 9, 2017
b041ce8
fixed indenting
matt2005 Jun 9, 2017
6abadaf
removed bad whitespace
matt2005 Jun 9, 2017
21ba321
updated requirements
matt2005 Jun 10, 2017
524616c
fixed pylink error indenting
matt2005 Jun 10, 2017
fe8ccca
Added ONVIF camera component
matt2005 Jun 9, 2017
4836109
added requirements
matt2005 Jun 9, 2017
0336ea3
corrected long lines
matt2005 Jun 9, 2017
2566f8b
fixed indenting
matt2005 Jun 9, 2017
810c1cb
fixed indenting
matt2005 Jun 9, 2017
771c6db
removed bad whitespace
matt2005 Jun 9, 2017
e77512d
updated requirements
matt2005 Jun 10, 2017
f8d2bf3
Added ONVIF camera component
matt2005 Jun 9, 2017
e54d734
added requirements
matt2005 Jun 9, 2017
9f3d464
corrected long lines
matt2005 Jun 9, 2017
f9f2695
fixed indenting
matt2005 Jun 9, 2017
bad633a
fixed indenting
matt2005 Jun 9, 2017
d50b6a9
removed bad whitespace
matt2005 Jun 9, 2017
215a5a8
updated requirements
matt2005 Jun 10, 2017
876dac4
fixed pylink error indenting
matt2005 Jun 10, 2017
3d8e2d3
rebased and fixed requirements
matt2005 Jun 12, 2017
96bf6ec
Removed Debug logging
matt2005 Jun 13, 2017
d035bf2
Added info logging to show URL being used.
matt2005 Jun 13, 2017
2b0c0d1
corrected spacing
matt2005 Jun 13, 2017
568cf3e
Tidied up and renamed input to host
matt2005 Jun 14, 2017
abb89c5
fixed typo
matt2005 Jun 14, 2017
0087206
corrected line lengths
matt2005 Jun 14, 2017
a41970b
added default to ffmpeg_arguments
matt2005 Jun 14, 2017
6f5b659
removed unecessary ffmpeg arguements
matt2005 Jun 14, 2017
3767992
changed to use .format instead of +
matt2005 Jun 15, 2017
689a0a9
fixed indenting
matt2005 Jun 15, 2017
457c525
cleanup & make it more readable
pvizeli Jun 15, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ omit =
homeassistant/components/camera/foscam.py
homeassistant/components/camera/mjpeg.py
homeassistant/components/camera/rpi_camera.py
homeassistant/components/camera/onvif.py
homeassistant/components/camera/synology.py
homeassistant/components/climate/eq3btsmart.py
homeassistant/components/climate/flexit.py
Expand Down
102 changes: 102 additions & 0 deletions homeassistant/components/camera/onvif.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""
Support for ONVIF Cameras with FFmpeg as decoder.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.onvif/
"""
import asyncio
import logging

import voluptuous as vol

from homeassistant.const import (
CONF_NAME, CONF_HOST, CONF_USERNAME, CONF_PASSWORD, CONF_PORT)
from homeassistant.components.camera import Camera, PLATFORM_SCHEMA
from homeassistant.components.ffmpeg import (
DATA_FFMPEG)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.aiohttp_client import (
async_aiohttp_proxy_stream)

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['onvif-py3==0.1.3',
'suds-py3==1.3.3.0',
'https://github.com/tgaugry/suds-passworddigest-py3'
'/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip'
'#suds-passworddigest-py3==0.1.2a']
DEPENDENCIES = ['ffmpeg']
DEFAULT_NAME = 'ONVIF Camera'
DEFAULT_PORT = 5000
DEFAULT_USERNAME = 'admin'
DEFAULT_PASSWORD = '888888'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD): cv.string,
vol.Optional(CONF_USERNAME, default=DEFAULT_USERNAME): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
})


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up a ONVIF camera."""
if not hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_HOST)):
return
async_add_devices([ONVIFCamera(hass, config)])


class ONVIFCamera(Camera):
"""An implementation of an ONVIF camera."""

def __init__(self, hass, config):
"""Initialize a ONVIF camera."""
from onvif import ONVIFService
super().__init__()

self._name = config.get(CONF_NAME)
self._ffmpeg_arguments = '-q:v 2'
media = ONVIFService(
'http://{}:{}/onvif/device_service'.format(
config.get(CONF_HOST), config.get(CONF_PORT)),
config.get(CONF_USERNAME),
config.get(CONF_PASSWORD),
'{}/deps/onvif/wsdl/media.wsdl'.format(hass.config.config_dir)
)
self._input = media.GetStreamUri().Uri
_LOGGER.debug("ONVIF Camera Using the following URL for %s: %s",
self._name, self._input)

@asyncio.coroutine
def async_camera_image(self):
"""Return a still image response from the camera."""
from haffmpeg import ImageFrame, IMAGE_JPEG
ffmpeg = ImageFrame(
self.hass.data[DATA_FFMPEG].binary, loop=self.hass.loop)

image = yield from ffmpeg.get_image(
self._input, output_format=IMAGE_JPEG,
extra_cmd=self._ffmpeg_arguments)
return image

@asyncio.coroutine
def handle_async_mjpeg_stream(self, request):
"""Generate an HTTP MJPEG stream from the camera."""
from haffmpeg import CameraMjpeg

stream = CameraMjpeg(self.hass.data[DATA_FFMPEG].binary,
loop=self.hass.loop)
yield from stream.open_camera(
self._input, extra_cmd=self._ffmpeg_arguments)

yield from async_aiohttp_proxy_stream(
self.hass, request, stream,
'multipart/x-mixed-replace;boundary=ffserver')
yield from stream.close()

@property
def name(self):
"""Return the name of this camera."""
return self._name
9 changes: 9 additions & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ hikvision==0.4
# homeassistant.components.binary_sensor.workday
holidays==0.8.1

# homeassistant.components.camera.onvif
https://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a

# homeassistant.components.switch.rachio
https://github.com/Klikini/rachiopy/archive/2c8996fcfa97a9f361a789e0c998797ed2805281.zip#rachiopy==0.1.1

Expand Down Expand Up @@ -406,6 +409,9 @@ oemthermostat==1.1
# homeassistant.components.media_player.onkyo
onkyo-eiscp==1.1

# homeassistant.components.camera.onvif
onvif-py3==0.1.3

# homeassistant.components.sensor.openevse
openevsewifi==0.4

Expand Down Expand Up @@ -833,6 +839,9 @@ statsd==3.2.1
# homeassistant.components.sensor.steam_online
steamodd==4.21

# homeassistant.components.camera.onvif
suds-py3==1.3.3.0

# homeassistant.components.binary_sensor.tapsaff
tapsaff==0.1.3

Expand Down