From 8357c20fb3eff18514e3c8b410aa03ad50edc514 Mon Sep 17 00:00:00 2001 From: skircr115 Date: Tue, 18 Aug 2026 17:04:59 -0400 Subject: [PATCH] fix: Prevent TypeError in ws_poster when image is None Gracefully handle cases where the camera image cannot be fetched (evaluates to None). Previously, attempting to log `len(image)` caused an unhandled TypeError, resulting in a 500 Internal Server Error. --- custom_components/webrtc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/webrtc/__init__.py b/custom_components/webrtc/__init__.py index f084e2aa..86db4bcb 100644 --- a/custom_components/webrtc/__init__.py +++ b/custom_components/webrtc/__init__.py @@ -206,7 +206,7 @@ async def ws_poster(hass: HomeAssistant, params: dict) -> web.Response: # support entity_id as poster image_entity = _get_image_from_entity_id(hass, poster) image = await image_entity.async_image() - _LOGGER.debug(f"webrtc image_entity: {image_entity} - {len(image)}") + _LOGGER.debug(f"webrtc image_entity: {image_entity} - {len(image) if image else 0}") return web.Response(body=image, content_type="image/jpeg") # support poster from go2rtc stream name