mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Clean up MjpegCamera by removing unnused hass object in __init__ (#16628)
This commit is contained in:
parent
00918af94d
commit
19514ea500
@ -50,7 +50,7 @@ class AxisCamera(MjpegCamera):
|
|||||||
|
|
||||||
def __init__(self, hass, config, port):
|
def __init__(self, hass, config, port):
|
||||||
"""Initialize Axis Communications camera component."""
|
"""Initialize Axis Communications camera component."""
|
||||||
super().__init__(hass, config)
|
super().__init__(config)
|
||||||
self.port = port
|
self.port = port
|
||||||
dispatcher_connect(
|
dispatcher_connect(
|
||||||
hass, DOMAIN + '_' + config[CONF_NAME] + '_new_ip', self._new_ip)
|
hass, DOMAIN + '_' + config[CONF_NAME] + '_new_ip', self._new_ip)
|
||||||
|
@ -47,7 +47,7 @@ def async_setup_platform(hass, config, async_add_entities,
|
|||||||
"""Set up a MJPEG IP Camera."""
|
"""Set up a MJPEG IP Camera."""
|
||||||
if discovery_info:
|
if discovery_info:
|
||||||
config = PLATFORM_SCHEMA(discovery_info)
|
config = PLATFORM_SCHEMA(discovery_info)
|
||||||
async_add_entities([MjpegCamera(hass, config)])
|
async_add_entities([MjpegCamera(config)])
|
||||||
|
|
||||||
|
|
||||||
def extract_image_from_mjpeg(stream):
|
def extract_image_from_mjpeg(stream):
|
||||||
@ -65,7 +65,7 @@ def extract_image_from_mjpeg(stream):
|
|||||||
class MjpegCamera(Camera):
|
class MjpegCamera(Camera):
|
||||||
"""An implementation of an IP camera that is reachable over a URL."""
|
"""An implementation of an IP camera that is reachable over a URL."""
|
||||||
|
|
||||||
def __init__(self, hass, device_info):
|
def __init__(self, device_info):
|
||||||
"""Initialize a MJPEG camera."""
|
"""Initialize a MJPEG camera."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._name = device_info.get(CONF_NAME)
|
self._name = device_info.get(CONF_NAME)
|
||||||
|
@ -28,21 +28,21 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
cameras = []
|
cameras = []
|
||||||
for monitor in monitors:
|
for monitor in monitors:
|
||||||
_LOGGER.info("Initializing camera %s", monitor.id)
|
_LOGGER.info("Initializing camera %s", monitor.id)
|
||||||
cameras.append(ZoneMinderCamera(hass, monitor))
|
cameras.append(ZoneMinderCamera(monitor))
|
||||||
add_entities(cameras)
|
add_entities(cameras)
|
||||||
|
|
||||||
|
|
||||||
class ZoneMinderCamera(MjpegCamera):
|
class ZoneMinderCamera(MjpegCamera):
|
||||||
"""Representation of a ZoneMinder Monitor Stream."""
|
"""Representation of a ZoneMinder Monitor Stream."""
|
||||||
|
|
||||||
def __init__(self, hass, monitor):
|
def __init__(self, monitor):
|
||||||
"""Initialize as a subclass of MjpegCamera."""
|
"""Initialize as a subclass of MjpegCamera."""
|
||||||
device_info = {
|
device_info = {
|
||||||
CONF_NAME: monitor.name,
|
CONF_NAME: monitor.name,
|
||||||
CONF_MJPEG_URL: monitor.mjpeg_image_url,
|
CONF_MJPEG_URL: monitor.mjpeg_image_url,
|
||||||
CONF_STILL_IMAGE_URL: monitor.still_image_url
|
CONF_STILL_IMAGE_URL: monitor.still_image_url
|
||||||
}
|
}
|
||||||
super().__init__(hass, device_info)
|
super().__init__(device_info)
|
||||||
self._is_recording = None
|
self._is_recording = None
|
||||||
self._monitor = monitor
|
self._monitor = monitor
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user