JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
1.12k stars 88 forks source link

Bug: Error Handling Request #100

Closed david-kalbermatten closed 3 years ago

david-kalbermatten commented 3 years ago

Describe the bug Sometimes when loading my dashboard the camera view doesn't load and I find this error in my logs. Refreshing the page usually resolves the issue.

To Reproduce Steps to reproduce the behavior:

  1. Go to Dashboard with camera view
  2. Check whether the camera view loads or not
  3. If it didn't load, check the logs

Expected behavior The camera view should load every time

Log If applicable, add error logs.

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/tapo_control/camera.py:253
Integration: Tapo: Cameras Control (documentation, issues)
First occurred: 14:15:26 (1 occurrences)
Last logged: 14:15:26

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 211, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 517, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 552, in handle
    stream = await camera.handle_async_mjpeg_stream(request)
  File "/config/custom_components/tapo_control/camera.py", line 253, in handle_async_mjpeg_stream
    await stream.close()
  File "/usr/local/lib/python3.9/site-packages/haffmpeg/core.py", line 158, in close
    await self._loop.run_in_executor(None, _close)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/site-packages/haffmpeg/core.py", line 153, in _close
    self._proc.stdin.write(b"q")
BrokenPipeError: [Errno 32] Broken pipe

Camera (please complete the following information):

Using stream component no

Camera works through onvif component OR different cameras work in general my only camera and it seems to work otherwise

Camera has all attributes filled out properly in developer tools yes

HASS Environment Docker on Unraid

Additional context This is the card I'm using: image

type: custom:stack-in-card
cards:
  - type: picture-glance
    title: Bedroom
    camera_image: camera.tapo_camera_5489_sd
    camera_view: live
    entity: camera.tapo_camera_5489_hd
    entities:
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:arrow-left-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            pan: LEFT
    hold_action:
      action: more-info
    style: |
      :host .box {
        display: none 
      }
  - type: glance
    show_icon: true
    show_name: false
    show_state: false
    style: |
      ha-card.type-glance .entities, 
      ha-card.type-glance .entity {
        padding: 0px;
        margin: 0px;
      }
      ha-card.type-glance {
        margin-top: 14px;
      }
    entities:
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:arrow-left-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            pan: LEFT
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:arrow-up-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            tilt: UP
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:arrow-down-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            tilt: DOWN
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:arrow-right-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            pan: RIGHT
  - type: glance
    show_icon: true
    show_name: false
    show_state: false
    style: |
      ha-card.type-glance .entities, 
      ha-card.type-glance .entity {
        padding: 0px;
        margin: 0px;
      }
      ha-card.type-glance {
        margin-bottom: 0px;
      }
    entities:
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:theme-light-dark
        tap_action:
          action: call-service
          service: tapo_control.set_day_night_mode
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            day_night_mode: auto
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:weather-sunny
        tap_action:
          action: call-service
          service: tapo_control.set_day_night_mode
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            day_night_mode: 'off'
      - entity: camera.tapo_camera_5489_hd
        icon: mdi:weather-night
        tap_action:
          action: call-service
          service: tapo_control.set_day_night_mode
          service_data:
            entity_id: camera.tapo_camera_5489_hd
            day_night_mode: 'on'
  - type: entities
    entities:
      - entity: binary_sensor.tapo_camera_5489_motion
        name: Motion Sensor
      - switch.tapo_cam_1_privacy_switch
      - switch.tapo_cam_1_alarm_switch
      - switch.tapo_cam_1_auto_track_switch
    style: |
      ha-card.type-entities {
        margin-right: 14px;
      }
      ha-card.type-entities #states {
        padding-top: 10px;
      }
JurajNyiri commented 3 years ago

Not related to this integration. Your connection from camera to Home Assistant has been ended prematurely.