2016-10-15 03:56:40 +00:00
|
|
|
"""
|
2016-10-29 20:10:42 +00:00
|
|
|
Support for ZoneMinder.
|
2016-10-15 03:56:40 +00:00
|
|
|
|
|
|
|
For more details about this component, please refer to the documentation at
|
|
|
|
https://home-assistant.io/components/zoneminder/
|
|
|
|
"""
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
from homeassistant.const import (
|
2018-08-25 09:21:57 +00:00
|
|
|
CONF_HOST, CONF_PASSWORD, CONF_PATH, CONF_SSL, CONF_USERNAME,
|
|
|
|
CONF_VERIFY_SSL)
|
2016-10-29 20:10:42 +00:00
|
|
|
import homeassistant.helpers.config_validation as cv
|
2016-10-15 03:56:40 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2018-09-25 05:53:35 +00:00
|
|
|
REQUIREMENTS = ['zm-py==0.0.3']
|
2018-09-15 06:44:48 +00:00
|
|
|
|
2017-02-21 06:17:11 +00:00
|
|
|
CONF_PATH_ZMS = 'path_zms'
|
2018-08-25 09:21:57 +00:00
|
|
|
|
2016-10-29 20:10:42 +00:00
|
|
|
DEFAULT_PATH = '/zm/'
|
2017-02-21 06:17:11 +00:00
|
|
|
DEFAULT_PATH_ZMS = '/zm/cgi-bin/nph-zms'
|
2016-10-29 20:10:42 +00:00
|
|
|
DEFAULT_SSL = False
|
|
|
|
DEFAULT_TIMEOUT = 10
|
2018-08-25 09:21:57 +00:00
|
|
|
DEFAULT_VERIFY_SSL = True
|
2016-10-15 03:56:40 +00:00
|
|
|
DOMAIN = 'zoneminder'
|
|
|
|
|
|
|
|
CONFIG_SCHEMA = vol.Schema({
|
|
|
|
DOMAIN: vol.Schema({
|
|
|
|
vol.Required(CONF_HOST): cv.string,
|
2018-08-25 09:21:57 +00:00
|
|
|
vol.Optional(CONF_PASSWORD): cv.string,
|
2016-10-29 20:10:42 +00:00
|
|
|
vol.Optional(CONF_PATH, default=DEFAULT_PATH): cv.string,
|
2017-02-21 06:17:11 +00:00
|
|
|
vol.Optional(CONF_PATH_ZMS, default=DEFAULT_PATH_ZMS): cv.string,
|
2018-08-25 09:21:57 +00:00
|
|
|
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
|
2016-10-15 03:56:40 +00:00
|
|
|
vol.Optional(CONF_USERNAME): cv.string,
|
2018-08-25 09:21:57 +00:00
|
|
|
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
|
2016-10-15 03:56:40 +00:00
|
|
|
})
|
|
|
|
}, extra=vol.ALLOW_EXTRA)
|
|
|
|
|
|
|
|
|
|
|
|
def setup(hass, config):
|
2016-10-29 20:10:42 +00:00
|
|
|
"""Set up the ZoneMinder component."""
|
2018-09-15 06:44:48 +00:00
|
|
|
from zoneminder.zm import ZoneMinder
|
2016-10-15 03:56:40 +00:00
|
|
|
|
|
|
|
conf = config[DOMAIN]
|
2016-10-27 13:54:03 +00:00
|
|
|
if conf[CONF_SSL]:
|
2016-10-29 20:10:42 +00:00
|
|
|
schema = 'https'
|
2016-10-27 13:54:03 +00:00
|
|
|
else:
|
2016-10-29 20:10:42 +00:00
|
|
|
schema = 'http'
|
2016-10-27 13:54:03 +00:00
|
|
|
|
2017-02-21 06:17:11 +00:00
|
|
|
server_origin = '{}://{}'.format(schema, conf[CONF_HOST])
|
2018-09-15 06:44:48 +00:00
|
|
|
hass.data[DOMAIN] = ZoneMinder(server_origin,
|
|
|
|
conf.get(CONF_USERNAME),
|
|
|
|
conf.get(CONF_PASSWORD),
|
|
|
|
conf.get(CONF_PATH),
|
|
|
|
conf.get(CONF_PATH_ZMS),
|
|
|
|
conf.get(CONF_VERIFY_SSL))
|
|
|
|
|
|
|
|
return hass.data[DOMAIN].login()
|