diff --git a/homeassistant/components/camera/axis.py b/homeassistant/components/camera/axis.py index 4227cca7e2f..9846ae85fb2 100644 --- a/homeassistant/components/camera/axis.py +++ b/homeassistant/components/camera/axis.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/camera.axis/ import logging from homeassistant.components.camera.mjpeg import ( - CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera) + CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera, filter_urllib3_logging) from homeassistant.const import ( CONF_AUTHENTICATION, CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT, CONF_USERNAME, HTTP_DIGEST_AUTHENTICATION) @@ -29,6 +29,8 @@ def _get_image_url(host, port, mode): def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Axis camera.""" + filter_urllib3_logging() + camera_config = { CONF_NAME: discovery_info[CONF_NAME], CONF_USERNAME: discovery_info[CONF_USERNAME], diff --git a/homeassistant/components/camera/mjpeg.py b/homeassistant/components/camera/mjpeg.py index ee9b8321a90..0e73dfac0b7 100644 --- a/homeassistant/components/camera/mjpeg.py +++ b/homeassistant/components/camera/mjpeg.py @@ -46,7 +46,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a MJPEG IP Camera.""" - # Filter header errors from urllib3 due to a urllib3 bug + filter_urllib3_logging() + + if discovery_info: + config = PLATFORM_SCHEMA(discovery_info) + async_add_entities([MjpegCamera(config)]) + + +def filter_urllib3_logging(): + """Filter header errors from urllib3 due to a urllib3 bug.""" urllib3_logger = logging.getLogger("urllib3.connectionpool") if not any(isinstance(x, NoHeaderErrorFilter) for x in urllib3_logger.filters): @@ -54,10 +62,6 @@ async def async_setup_platform(hass, config, async_add_entities, NoHeaderErrorFilter() ) - if discovery_info: - config = PLATFORM_SCHEMA(discovery_info) - async_add_entities([MjpegCamera(config)]) - def extract_image_from_mjpeg(stream): """Take in a MJPEG stream object, return the jpg from it.""" diff --git a/homeassistant/components/camera/zoneminder.py b/homeassistant/components/camera/zoneminder.py index 703e6f3e355..9bde4ac099b 100644 --- a/homeassistant/components/camera/zoneminder.py +++ b/homeassistant/components/camera/zoneminder.py @@ -8,7 +8,7 @@ import logging from homeassistant.const import CONF_NAME, CONF_VERIFY_SSL from homeassistant.components.camera.mjpeg import ( - CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera) + CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera, filter_urllib3_logging) from homeassistant.components.zoneminder import DOMAIN as ZONEMINDER_DOMAIN _LOGGER = logging.getLogger(__name__) @@ -18,6 +18,7 @@ DEPENDENCIES = ['zoneminder'] def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ZoneMinder cameras.""" + filter_urllib3_logging() zm_client = hass.data[ZONEMINDER_DOMAIN] monitors = zm_client.get_monitors()