Skip to content

Commit

Permalink
WebRTC hotfix (#2)
Browse files Browse the repository at this point in the history
* bump

* WebRTC hotfix and old firmware workaround
  • Loading branch information
xannor authored Jul 27, 2022
1 parent 84f137f commit df148b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/reolink_rest/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _sub_failure(entry_id: str):
)
hass.create_task(_coordinator.async_request_refresh())
subscription = None
if not bool(coordinator.data.ports["onvifEnable"]):
if not bool(coordinator.data.ports.get("onvifEnable", True)):
coordinator.logger.warning(
"ONVIF not enabled for device %s, forcing polling mode",
coordinator.data.device.name,
Expand Down
18 changes: 14 additions & 4 deletions custom_components/reolink_rest/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ def __init__(
self._attr_supported_features = supported_features
self._snapshot_task: Task[bytes | None] = None
if self.entity_description.output_type == OutputStreamTypes.RTSP and not bool(
self.coordinator.data.ports["rtspEnable"]
self.coordinator.data.ports.get("rtspEnable", True)
):
self._attr_available = False
self.coordinator.logger.error(
"RTSP is disabled on device (%s) camera will be unavailable",
self.coordinator.data.device.name,
)
elif self.entity_description.output_type == OutputStreamTypes.RTMP and not bool(
self.coordinator.data.ports["rtmpEnable"]
self.coordinator.data.ports.get("rtmpEnable", True)
):
self._attr_available = False
self.coordinator.logger.error(
Expand Down Expand Up @@ -400,6 +400,12 @@ async def stream_source(self) -> str | None:
return await super().stream_source()
return url

async def _async_use_rtsp_to_webrtc(self) -> bool:
# Force falce since the RTMP stream does not seem to work with webrtc
if self.entity_description.output_type != OutputStreamTypes.RTSP:
return False
return await super()._async_use_rtsp_to_webrtc()

async def _async_camera_image(self):
domain_data: ReolinkDomainData = self.hass.data[DOMAIN]
client = domain_data[self.coordinator.config_entry.entry_id][
Expand Down Expand Up @@ -445,9 +451,13 @@ def available(self) -> bool:

def _handle_coordinator_update(self) -> None:
if self.entity_description.output_type == OutputStreamTypes.RTSP:
self._attr_available = bool(self.coordinator.data.ports["rtspEnable"])
self._attr_available = bool(
self.coordinator.data.ports.get("rtspEnable", True)
)
elif self.entity_description.output_type == OutputStreamTypes.RTMP:
self._attr_available = bool(self.coordinator.data.ports["rtmpEnable"])
self._attr_available = bool(
self.coordinator.data.ports.get("rtmpEnable", True)
)
return super()._handle_coordinator_update()

async def async_set_zoom(self, position: int):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/reolink_rest/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Reolink IP Device",
"documentation": "https://github.com/xannor/ha_reolink_rest",
"issue_tracker": "https://github.com/xannor/ha_reolink_rest/issues",
"version": "0.5.4",
"version": "0.5.5",
"iot_class": "local_polling",
"requirements": ["async-reolink.rest==0.5.8"],
"dependencies": ["camera"],
Expand Down
2 changes: 1 addition & 1 deletion custom_components/reolink_rest/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ async def _send(self, url: str, headers, data):
return (response.status, et.fromstring(text))

def _get_onvif_base(self, config_entry: ConfigEntry, device_data: EntityData):
if not bool(device_data.ports["onvifEnable"]):
if not bool(device_data.ports.get("onvifEnable", True)):
return None
discovery: dict = config_entry.options.get(OPT_DISCOVERY, {})
host = config_entry.data.get(CONF_HOST, discovery.get("ip", None))
Expand Down

0 comments on commit df148b5

Please sign in to comment.