* Added Axis hub, binary sensors and camera * Added Axis logo to static images * Added Axis logo to configurator Added Axis mdns discovery * Fixed flake8 and pylint comments * Missed a change from list to function call V5 of axis py * Added dependencies to requirements_all.txt * Clean up * Added files to coveragerc * Guide lines says to import function when needed, this makes Tox pass * Removed storing hass in config until at the end where I send it to axisdevice * Don't call update in the constructor * Don't keep hass private * Unnecessary lint ignore, following Baloobs suggestion of using NotImplementedError * Axis package not in pypi yet * Do not catch bare excepts. Device schema validations raise vol.Invalid. * setup_device still adds hass object to the config, so the need to remove it prior to writing config file still remains * Don't expect axis.conf contains correct values * Improved configuration validation * Trigger time better explains functionality than scan interval * Forgot to remove this earlier * Guideline says double qoutes for sentences * Return false from discovery if config file contains bad data * Keys in AXIS_DEVICES are serialnumber * Ordered imports in alphabetical order * Moved requirement to pypi * Moved update callback that handles trigger time to axis binary sensor * Renamed configurator instance to request_id since that is what it really is * Removed unnecessary configurator steps * Changed link in configurator to platform documentation * Add not-context-manager (#7523) * Add not-context-manager * Add missing comma * Threadsafe configurator (#7536) * Make Configurator thread safe, get_instance timing issues breaking configurator working on multiple devices * No blank lines allowed after function docstring * Fix comment Tox * Added Axis hub, binary sensors and camera * Added Axis logo to static images * Added Axis logo to configurator Added Axis mdns discovery * Fixed flake8 and pylint comments * Missed a change from list to function call V5 of axis py * Added dependencies to requirements_all.txt * Clean up * Added files to coveragerc * Guide lines says to import function when needed, this makes Tox pass * Removed storing hass in config until at the end where I send it to axisdevice * Don't call update in the constructor * Don't keep hass private * Unnecessary lint ignore, following Baloobs suggestion of using NotImplementedError * Axis package not in pypi yet * Do not catch bare excepts. Device schema validations raise vol.Invalid. * setup_device still adds hass object to the config, so the need to remove it prior to writing config file still remains * Don't expect axis.conf contains correct values * Improved configuration validation * Trigger time better explains functionality than scan interval * Forgot to remove this earlier * Guideline says double qoutes for sentences * Return false from discovery if config file contains bad data * Keys in AXIS_DEVICES are serialnumber * Ordered imports in alphabetical order * Moved requirement to pypi * Moved update callback that handles trigger time to axis binary sensor * Renamed configurator instance to request_id since that is what it really is * Removed unnecessary configurator steps * Changed link in configurator to platform documentation * No blank lines allowed after function docstring * No blank lines allowed after function docstring * Changed discovery to use axis instead of axis_mdns * Travis CI requested rerun of script/gen_requirements_all.py
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""
|
|
Support for Axis camera streaming.
|
|
|
|
For more details about this platform, please refer to the documentation at
|
|
https://home-assistant.io/components/camera.axis/
|
|
"""
|
|
import logging
|
|
|
|
from homeassistant.const import (
|
|
CONF_NAME, CONF_USERNAME, CONF_PASSWORD,
|
|
CONF_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION)
|
|
from homeassistant.components.camera.mjpeg import (
|
|
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera)
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
DEPENDENCIES = ['axis']
|
|
DOMAIN = 'axis'
|
|
|
|
|
|
def _get_image_url(host, mode):
|
|
if mode == 'mjpeg':
|
|
return 'http://{}/axis-cgi/mjpg/video.cgi'.format(host)
|
|
elif mode == 'single':
|
|
return 'http://{}/axis-cgi/jpg/image.cgi'.format(host)
|
|
|
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
|
"""Setup Axis camera."""
|
|
device_info = {
|
|
CONF_NAME: discovery_info['name'],
|
|
CONF_USERNAME: discovery_info['username'],
|
|
CONF_PASSWORD: discovery_info['password'],
|
|
CONF_MJPEG_URL: _get_image_url(discovery_info['host'], 'mjpeg'),
|
|
CONF_STILL_IMAGE_URL: _get_image_url(discovery_info['host'], 'single'),
|
|
CONF_AUTHENTICATION: HTTP_DIGEST_AUTHENTICATION,
|
|
}
|
|
add_devices([MjpegCamera(hass, device_info)])
|