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