From 008b641c564d48c0d3a80491d8b5572a12c32b7f Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Fri, 5 Apr 2019 19:14:54 +0200 Subject: [PATCH] Axis - support stream (#22593) * Add support for new stream component --- homeassistant/components/axis/camera.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/homeassistant/components/axis/camera.py b/homeassistant/components/axis/camera.py index ec1d761d3d0..62b694a99bb 100644 --- a/homeassistant/components/axis/camera.py +++ b/homeassistant/components/axis/camera.py @@ -1,5 +1,6 @@ """Support for Axis camera streaming.""" +from homeassistant.components.camera import SUPPORT_STREAM from homeassistant.components.mjpeg.camera import ( CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera, filter_urllib3_logging) from homeassistant.const import ( @@ -14,6 +15,7 @@ DEPENDENCIES = [AXIS_DOMAIN] AXIS_IMAGE = 'http://{}:{}/axis-cgi/jpg/image.cgi' AXIS_VIDEO = 'http://{}:{}/axis-cgi/mjpg/video.cgi' +AXIS_STREAM = 'rtsp://{}:{}@{}/axis-media/media.amp?videocodec=h264' async def async_setup_entry(hass, config_entry, async_add_entities): @@ -56,6 +58,19 @@ class AxisCamera(MjpegCamera): self.unsub_dispatcher.append(async_dispatcher_connect( self.hass, self.device.event_reachable, self.update_callback)) + @property + def supported_features(self): + """Return supported features.""" + return SUPPORT_STREAM + + @property + def stream_source(self): + """Return the stream source.""" + return AXIS_STREAM.format( + self.device.config_entry.data[CONF_DEVICE][CONF_USERNAME], + self.device.config_entry.data[CONF_DEVICE][CONF_PASSWORD], + self.device.host) + @callback def update_callback(self, no_delay=None): """Update the cameras state."""