8000 Android webcam better error handling / pump library 0.4 by pvizeli · Pull Request #6518 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Android webcam better error handling / pump library 0.4 #6518
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
31 changes: 17 additions & 14 deletions homeassistant/components/android_ip_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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)
Expand Down Expand Up @@ -199,14 +199,15 @@ def async_update_data(now):
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
if sensor in SENSORS]
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
Expand All @@ -226,19 +227,21 @@ def async_update_data(now):
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(
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/sensor/android_ip_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def state(self):
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:
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/switch/android_ip_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def is_on(self):
@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)
Expand All @@ -77,11 +77,11 @@ def async_turn_on(self, **kwargs):
@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)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0