mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Android webcam better error handling / pump library 0.4 (#6518)
This commit is contained in:
parent
ffb1613d55
commit
44da43065f
@ -27,7 +27,7 @@ from homeassistant.components.camera.mjpeg import (
|
|||||||
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL)
|
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL)
|
||||||
|
|
||||||
DOMAIN = 'android_ip_webcam'
|
DOMAIN = 'android_ip_webcam'
|
||||||
REQUIREMENTS = ["pydroid-ipcam==0.3"]
|
REQUIREMENTS = ["pydroid-ipcam==0.4"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
SCAN_INTERVAL = timedelta(seconds=10)
|
SCAN_INTERVAL = timedelta(seconds=10)
|
||||||
@ -199,7 +199,7 @@ def async_setup(hass, config):
|
|||||||
if cam_config[CONF_AUTO_DISCOVERY]:
|
if cam_config[CONF_AUTO_DISCOVERY]:
|
||||||
if not cam.available:
|
if not cam.available:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Android webcam %s not found for discovery!", host)
|
"Android webcam %s not found for discovery!", cam.base_url)
|
||||||
return
|
return
|
||||||
|
|
||||||
sensors = [sensor for sensor in cam.enabled_sensors
|
sensors = [sensor for sensor in cam.enabled_sensors
|
||||||
@ -207,6 +207,7 @@ def async_setup(hass, config):
|
|||||||
switches = [setting for setting in cam.enabled_settings
|
switches = [setting for setting in cam.enabled_settings
|
||||||
if setting in SWITCHES]
|
if setting in SWITCHES]
|
||||||
motion = True if 'motion_active' in cam.enabled_sensors else False
|
motion = True if 'motion_active' in cam.enabled_sensors else False
|
||||||
|
sensors.extend(['audio_connections', 'video_connections'])
|
||||||
|
|
||||||
# load platforms
|
# load platforms
|
||||||
webcams[host] = cam
|
webcams[host] = cam
|
||||||
@ -226,6 +227,7 @@ def async_setup(hass, config):
|
|||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_add_job(discovery.async_load_platform(
|
||||||
hass, 'camera', 'mjpeg', mjpeg_camera, config))
|
hass, 'camera', 'mjpeg', mjpeg_camera, config))
|
||||||
|
|
||||||
|
if sensors:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_add_job(discovery.async_load_platform(
|
||||||
hass, 'sensor', DOMAIN, {
|
hass, 'sensor', DOMAIN, {
|
||||||
CONF_NAME: name,
|
CONF_NAME: name,
|
||||||
@ -233,6 +235,7 @@ def async_setup(hass, config):
|
|||||||
CONF_SENSORS: sensors,
|
CONF_SENSORS: sensors,
|
||||||
}, config))
|
}, config))
|
||||||
|
|
||||||
|
if switches:
|
||||||
hass.async_add_job(discovery.async_load_platform(
|
hass.async_add_job(discovery.async_load_platform(
|
||||||
hass, 'switch', DOMAIN, {
|
hass, 'switch', DOMAIN, {
|
||||||
CONF_NAME: name,
|
CONF_NAME: name,
|
||||||
|
@ -64,6 +64,8 @@ class IPWebcamSensor(AndroidIPCamEntity):
|
|||||||
def async_update(self):
|
def async_update(self):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
if self._sensor in ('audio_connections', 'video_connections'):
|
if self._sensor in ('audio_connections', 'video_connections'):
|
||||||
|
if not self._ipcam.status_data:
|
||||||
|
return
|
||||||
self._state = self._ipcam.status_data.get(self._sensor)
|
self._state = self._ipcam.status_data.get(self._sensor)
|
||||||
self._unit = 'Connections'
|
self._unit = 'Connections'
|
||||||
else:
|
else:
|
||||||
|
@ -63,11 +63,11 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_turn_on(self, **kwargs):
|
def async_turn_on(self, **kwargs):
|
||||||
"""Turn device on."""
|
"""Turn device on."""
|
||||||
if self._setting is 'torch':
|
if self._setting == 'torch':
|
||||||
yield from self._ipcam.torch(activate=True)
|
yield from self._ipcam.torch(activate=True)
|
||||||
elif self._setting is 'focus':
|
elif self._setting == 'focus':
|
||||||
yield from self._ipcam.focus(activate=True)
|
yield from self._ipcam.focus(activate=True)
|
||||||
elif self._setting is 'video_recording':
|
elif self._setting == 'video_recording':
|
||||||
yield from self._ipcam.record(record=True)
|
yield from self._ipcam.record(record=True)
|
||||||
else:
|
else:
|
||||||
yield from self._ipcam.change_setting(self._setting, True)
|
yield from self._ipcam.change_setting(self._setting, True)
|
||||||
@ -77,11 +77,11 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_turn_off(self, **kwargs):
|
def async_turn_off(self, **kwargs):
|
||||||
"""Turn device off."""
|
"""Turn device off."""
|
||||||
if self._setting is 'torch':
|
if self._setting == 'torch':
|
||||||
yield from self._ipcam.torch(activate=False)
|
yield from self._ipcam.torch(activate=False)
|
||||||
elif self._setting is 'focus':
|
elif self._setting == 'focus':
|
||||||
yield from self._ipcam.focus(activate=False)
|
yield from self._ipcam.focus(activate=False)
|
||||||
elif self._setting is 'video_recording':
|
elif self._setting == 'video_recording':
|
||||||
yield from self._ipcam.record(record=False)
|
yield from self._ipcam.record(record=False)
|
||||||
else:
|
else:
|
||||||
yield from self._ipcam.change_setting(self._setting, False)
|
yield from self._ipcam.change_setting(self._setting, False)
|
||||||
|
@ -482,7 +482,7 @@ pycmus==0.1.0
|
|||||||
pydispatcher==2.0.5
|
pydispatcher==2.0.5
|
||||||
|
|
||||||
# homeassistant.components.android_ip_webcam
|
# homeassistant.components.android_ip_webcam
|
||||||
pydroid-ipcam==0.3
|
pydroid-ipcam==0.4
|
||||||
|
|
||||||
# homeassistant.components.sensor.ebox
|
# homeassistant.components.sensor.ebox
|
||||||
pyebox==0.1.0
|
pyebox==0.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user