Use constant and update ordering (#8246)
parent
27c92937f2
commit
05acf1c10a
|
@ -1,27 +1,27 @@
|
||||||
"""
|
"""
|
||||||
This component provides basic support for Netgear Arlo IP cameras.
|
This component provides basic support for Netgear Arlo IP cameras.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/arlo/
|
https://home-assistant.io/components/arlo/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant.helpers import config_validation as cv
|
|
||||||
|
|
||||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
|
|
||||||
import homeassistant.loader as loader
|
|
||||||
|
|
||||||
from requests.exceptions import HTTPError, ConnectTimeout
|
from requests.exceptions import HTTPError, ConnectTimeout
|
||||||
|
|
||||||
|
import homeassistant.loader as loader
|
||||||
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
|
||||||
|
|
||||||
REQUIREMENTS = ['pyarlo==0.0.4']
|
REQUIREMENTS = ['pyarlo==0.0.4']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_ATTRIBUTION = 'Data provided by arlo.netgear.com'
|
CONF_ATTRIBUTION = "Data provided by arlo.netgear.com"
|
||||||
|
|
||||||
DOMAIN = 'arlo'
|
|
||||||
|
|
||||||
|
DATA_ARLO = 'data_arlo'
|
||||||
DEFAULT_BRAND = 'Netgear Arlo'
|
DEFAULT_BRAND = 'Netgear Arlo'
|
||||||
|
DOMAIN = 'arlo'
|
||||||
|
|
||||||
NOTIFICATION_ID = 'arlo_notification'
|
NOTIFICATION_ID = 'arlo_notification'
|
||||||
NOTIFICATION_TITLE = 'Arlo Camera Setup'
|
NOTIFICATION_TITLE = 'Arlo Camera Setup'
|
||||||
|
@ -47,7 +47,7 @@ def setup(hass, config):
|
||||||
arlo = PyArlo(username, password, preload=False)
|
arlo = PyArlo(username, password, preload=False)
|
||||||
if not arlo.is_connected:
|
if not arlo.is_connected:
|
||||||
return False
|
return False
|
||||||
hass.data['arlo'] = arlo
|
hass.data[DATA_ARLO] = arlo
|
||||||
except (ConnectTimeout, HTTPError) as ex:
|
except (ConnectTimeout, HTTPError) as ex:
|
||||||
_LOGGER.error("Unable to connect to Netgar Arlo: %s", str(ex))
|
_LOGGER.error("Unable to connect to Netgar Arlo: %s", str(ex))
|
||||||
persistent_notification.create(
|
persistent_notification.create(
|
||||||
|
|
|
@ -6,15 +6,14 @@ https://home-assistant.io/components/camera.arlo/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.components.arlo import DEFAULT_BRAND, DATA_ARLO
|
||||||
from homeassistant.components.arlo import DEFAULT_BRAND
|
from homeassistant.components.camera import Camera, PLATFORM_SCHEMA
|
||||||
|
|
||||||
from homeassistant.components.camera import (Camera, PLATFORM_SCHEMA)
|
|
||||||
from homeassistant.components.ffmpeg import DATA_FFMPEG
|
from homeassistant.components.ffmpeg import DATA_FFMPEG
|
||||||
from homeassistant.helpers.aiohttp_client import (
|
from homeassistant.helpers import config_validation as cv
|
||||||
async_aiohttp_proxy_stream)
|
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
||||||
|
|
||||||
DEPENDENCIES = ['arlo', 'ffmpeg']
|
DEPENDENCIES = ['arlo', 'ffmpeg']
|
||||||
|
|
||||||
|
@ -23,15 +22,14 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
CONF_FFMPEG_ARGUMENTS = 'ffmpeg_arguments'
|
CONF_FFMPEG_ARGUMENTS = 'ffmpeg_arguments'
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_FFMPEG_ARGUMENTS):
|
vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string,
|
||||||
cv.string,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Set up an Arlo IP Camera."""
|
"""Set up an Arlo IP Camera."""
|
||||||
arlo = hass.data.get('arlo')
|
arlo = hass.data.get(DATA_ARLO)
|
||||||
if not arlo:
|
if not arlo:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -40,7 +38,6 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
cameras.append(ArloCam(hass, camera, config))
|
cameras.append(ArloCam(hass, camera, config))
|
||||||
|
|
||||||
async_add_devices(cameras, True)
|
async_add_devices(cameras, True)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class ArloCam(Camera):
|
class ArloCam(Camera):
|
||||||
|
@ -56,7 +53,7 @@ class ArloCam(Camera):
|
||||||
self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS)
|
self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS)
|
||||||
|
|
||||||
def camera_image(self):
|
def camera_image(self):
|
||||||
"""Return a still image reponse from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
return self._camera.last_image
|
return self._camera.last_image
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
Loading…
Reference in New Issue