Skip to content

Commit

Permalink
Fix Axis camera platform support HTTPS (home-assistant#114886)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 authored and frenck committed Apr 5, 2024
1 parent 411e55d commit 96003e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 8 additions & 8 deletions homeassistant/components/axis/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, hub: AxisHub) -> None:
mjpeg_url=self.mjpeg_source,
still_image_url=self.image_source,
authentication=HTTP_DIGEST_AUTHENTICATION,
verify_ssl=False,
unique_id=f"{hub.unique_id}-camera",
)

Expand All @@ -74,16 +75,18 @@ def _generate_sources(self) -> None:
Additionally used when device change IP address.
"""
proto = self.hub.config.protocol
host = self.hub.config.host
port = self.hub.config.port

image_options = self.generate_options(skip_stream_profile=True)
self._still_image_url = (
f"http://{self.hub.config.host}:{self.hub.config.port}/axis-cgi"
f"/jpg/image.cgi{image_options}"
f"{proto}://{host}:{port}/axis-cgi/jpg/image.cgi{image_options}"
)

mjpeg_options = self.generate_options()
self._mjpeg_url = (
f"http://{self.hub.config.host}:{self.hub.config.port}/axis-cgi"
f"/mjpg/video.cgi{mjpeg_options}"
f"{proto}://{host}:{port}/axis-cgi/mjpg/video.cgi{mjpeg_options}"
)

stream_options = self.generate_options(add_video_codec_h264=True)
Expand All @@ -95,10 +98,7 @@ def _generate_sources(self) -> None:
self.hub.additional_diagnostics["camera_sources"] = {
"Image": self._still_image_url,
"MJPEG": self._mjpeg_url,
"Stream": (
f"rtsp://user:pass@{self.hub.config.host}/axis-media"
f"/media.amp{stream_options}"
),
"Stream": (f"rtsp://user:pass@{host}/axis-media/media.amp{stream_options}"),
}

@property
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/axis/hub/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_PROTOCOL,
CONF_TRIGGER_TIME,
CONF_USERNAME,
)
Expand All @@ -31,6 +32,7 @@ class AxisConfig:

entry: ConfigEntry

protocol: str
host: str
port: int
username: str
Expand All @@ -54,6 +56,7 @@ def from_config_entry(cls, config_entry: ConfigEntry) -> Self:
options = config_entry.options
return cls(
entry=config_entry,
protocol=config.get(CONF_PROTOCOL, "http"),
host=config[CONF_HOST],
username=config[CONF_USERNAME],
password=config[CONF_PASSWORD],
Expand Down

0 comments on commit 96003e3

Please sign in to comment.