mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix Xeoma camera platform to allow different admin/viewer credentials (#12161)
This commit is contained in:
parent
49c7b422f2
commit
a2916a9c47
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,7 +16,9 @@ Icon
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# pytest
|
||||
.cache
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.const import (
|
||||
CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['pyxeoma==1.2']
|
||||
REQUIREMENTS = ['pyxeoma==1.3']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -22,6 +22,8 @@ CONF_CAMERAS = 'cameras'
|
||||
CONF_HIDE = 'hide'
|
||||
CONF_IMAGE_NAME = 'image_name'
|
||||
CONF_NEW_VERSION = 'new_version'
|
||||
CONF_VIEWER_PASSWORD = 'viewer_password'
|
||||
CONF_VIEWER_USERNAME = 'viewer_username'
|
||||
|
||||
CAMERAS_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_IMAGE_NAME): cv.string,
|
||||
@ -48,9 +50,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
host = config[CONF_HOST]
|
||||
login = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
new_version = config[CONF_NEW_VERSION]
|
||||
|
||||
xeoma = Xeoma(host, new_version, login, password)
|
||||
xeoma = Xeoma(host, login, password)
|
||||
|
||||
try:
|
||||
yield from xeoma.async_test_connection()
|
||||
@ -59,9 +60,12 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
{
|
||||
CONF_IMAGE_NAME: image_name,
|
||||
CONF_HIDE: False,
|
||||
CONF_NAME: image_name
|
||||
CONF_NAME: image_name,
|
||||
CONF_VIEWER_USERNAME: username,
|
||||
CONF_VIEWER_PASSWORD: pw
|
||||
|
||||
}
|
||||
for image_name in discovered_image_names
|
||||
for image_name, username, pw in discovered_image_names
|
||||
]
|
||||
|
||||
for cam in config[CONF_CAMERAS]:
|
||||
@ -77,8 +81,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
|
||||
cameras = list(filter(lambda c: not c[CONF_HIDE], discovered_cameras))
|
||||
async_add_devices(
|
||||
[XeomaCamera(xeoma, camera[CONF_IMAGE_NAME], camera[CONF_NAME])
|
||||
for camera in cameras])
|
||||
[XeomaCamera(xeoma, camera[CONF_IMAGE_NAME], camera[CONF_NAME],
|
||||
camera[CONF_VIEWER_USERNAME],
|
||||
camera[CONF_VIEWER_PASSWORD]) for camera in cameras])
|
||||
except XeomaError as err:
|
||||
_LOGGER.error("Error: %s", err.message)
|
||||
return
|
||||
@ -87,12 +92,14 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
class XeomaCamera(Camera):
|
||||
"""Implementation of a Xeoma camera."""
|
||||
|
||||
def __init__(self, xeoma, image, name):
|
||||
def __init__(self, xeoma, image, name, username, password):
|
||||
"""Initialize a Xeoma camera."""
|
||||
super().__init__()
|
||||
self._xeoma = xeoma
|
||||
self._name = name
|
||||
self._image = image
|
||||
self._username = username
|
||||
self._password = password
|
||||
self._last_image = None
|
||||
|
||||
@asyncio.coroutine
|
||||
@ -100,7 +107,8 @@ class XeomaCamera(Camera):
|
||||
"""Return a still image response from the camera."""
|
||||
from pyxeoma.xeoma import XeomaError
|
||||
try:
|
||||
image = yield from self._xeoma.async_get_camera_image(self._image)
|
||||
image = yield from self._xeoma.async_get_camera_image(
|
||||
self._image, self._username, self._password)
|
||||
self._last_image = image
|
||||
except XeomaError as err:
|
||||
_LOGGER.error("Error fetching image: %s", err.message)
|
||||
|
@ -1015,7 +1015,7 @@ pywebpush==1.5.0
|
||||
pywemo==0.4.25
|
||||
|
||||
# homeassistant.components.camera.xeoma
|
||||
pyxeoma==1.2
|
||||
pyxeoma==1.3
|
||||
|
||||
# homeassistant.components.zabbix
|
||||
pyzabbix==0.7.4
|
||||
|
Loading…
x
Reference in New Issue
Block a user