Skip to content

stream_source defined as a @property shadows HA's async Camera.stream_source() — stream API (HLS) fails with TypeError: 'str' object is not callable #116

Description

@Raymondvb1985

Environment

  • Home Assistant Core 2026.7.4 (HAOS, Raspberry Pi 5)
  • ha_creality_ws v0.9.7
  • Printer: Creality K1 Max
  • Camera in go2rtc-bridge mode (not direct signaling)

Bug

custom_components/ha_creality_ws/camera.py defines stream_source as a synchronous property returning the go2rtc stream name:

@property
def stream_source(self) -> Optional[str]:
    """Return the stream name for go2rtc. ..."""
    if not self._uses_go2rtc_webrtc_bridge():
        return None
    return self._stream_name

Home Assistant core defines Camera.stream_source as an async method, and the stream (HLS) machinery calls it as one:

source = await self.stream_source()

Because the subclass property shadows the method, self.stream_source evaluates to a str (the stream name), and calling it raises:

TypeError: 'str' object is not callable

The result: WebRTC works fine, but any consumer of the classic stream pipeline — the
camera/stream WebSocket command, HLS playback, camera.record/camera.play_stream
services, casting, etc. — fails for this camera.

There is already a correct async variant right below it (async_get_stream_source), but HA
core never calls that name; the property is what gets hit.

Steps to reproduce

  1. Set up the integration with the camera in go2rtc mode.
  2. In a browser dev console (or any WS client), send
    {"type": "camera/stream", "entity_id": "camera.<printer>_printer_camera"}.
  3. HA returns an error; the log shows the TypeError: 'str' object is not callable traceback
    in the stream component.

Fix that works for me (hand-patched locally)

Replace the property with an async method returning an actual RTSP URL on HA's internal
go2rtc (which HA's stream component can consume), and expose the stream name via
extra_state_attributes instead:

async def stream_source(self) -> Optional[str]:
    if not self._uses_go2rtc_webrtc_bridge():
        return None
    await self._ensure_stream_configured()
    if not self._stream_name:
        return None
    return f"rtsp://127.0.0.1:18554/{self._stream_name}"

(18554 = HA's internal go2rtc RTSP port.)

With this change camera/stream / HLS work.

Note for anyone else hitting this

Reloading the config entry does not re-import the module code — a full HA Core restart
is needed after patching.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbug / feature request accepted and will be implementedbugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions