core: Onvif cams not working anymore

The problem

After upgrading from 0.106.6 to 0.107.1 my 2 onvif cameras show as entity not available in lovelace, they dont exist in entities.

Environment

  • Home Assistant release with the issue: 0.107.1
  • Last working Home Assistant release (if known):
    0.106.6
  • Operating environment (Hass.io/Docker/Windows/etc.): Hassio in docker on Ubuntu 18.04
  • Integration causing this issue: onvif core component
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/onvif/

Problem-relevant cameras.yaml

- platform: onvif
  host: !secret cam_front_onvif
  name: Front Garden
  port: !secret onvif_port
  password: !secret onvif_pass

Traceback/Error logs

Log Details (WARNING)
Logger: homeassistant.components.onvif.camera
Source: components/onvif/camera.py:206
Integration: onvif (documentation, issues)
First occurred: 4:49:42 PM (110 occurrences)
Last logged: 7:25:20 PM

Couldn't connect to camera 'Back Garden', but will retry later. Error: [Errno None] Can not write request body for http://192.168.7.111/onvif/Media
Couldn't connect to camera 'Back Garden', but will retry later. Error: None
Couldn't connect to camera 'Front Garden', but will retry later. Error: [Errno 32] Broken pipe
Couldn't connect to camera 'Back Garden', but will retry later. Error: [Errno None] Can not write request body for http://192.168.7.111:80/onvif/device_service
Couldn't connect to camera 'Front Garden', but will retry later. Error: [Errno None] Can not write request body for http://192.168.7.112:80/onvif/device_service

Logger: homeassistant.components.camera
Source: helpers/entity_platform.py:203
Integration: Camera (documentation, issues)
First occurred: 4:50:15 PM (108 occurrences)
Last logged: 7:25:20 PM

Platform onvif not ready yet. Retrying in 60 seconds.
Platform onvif not ready yet. Retrying in 90 seconds.
Platform onvif not ready yet. Retrying in 120 seconds.
Platform onvif not ready yet. Retrying in 150 seconds.
Platform onvif not ready yet. Retrying in 180 seconds.

Additional information

Some Debugging steps I have carried out:

1: Restored my 'pre-update' snapshot back to 0.106.6 and cameras started working again.

2: Restored back to 0.107.1 and the issue arose again

3: Downloaded the onvif component from the 0.106.6 'tag' on github and placed it in my custom component folder on version 0.107.1, rebooted and all is well. Cameras working no problem.

My cameras are ptz cams but I have never tried to use the service from home assistant. This is probably irrelevant info but I did notice there was an issue with non ptz onvif cams previously.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

A work around in the meantime until this is fixed is to download the onvif component directory from the 0.106.6 version and place it in your custom_components directory and restart home assistant. https://github.com/home-assistant/core/tree/0.106.6/homeassistant/components/onvif

This is what has got my cameras back up and running.

Thanks for the work around, it does work now, nice to have people that know stuff…

I have the same problem.

Version 2021.1.4
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.7
Operating System Family Linux
Operating System Version 5.9.16
CPU Architecture aarch64

Logger: homeassistant.bootstrap Source: bootstrap.py:394 First occurred: 8:26:45 PM (134 occurrences) Last logged: 10:39:46 PM

Waiting on integrations to complete setup: onvif

I’ve started light debugging on the latest (0.108.1) version. For me it goes wrong on the async_check_date_and_time function with the error Can not write request body for http://<camera ip>:<camera port>/onvif/device_service

It almost seems like the camera does not like getting multiple requests on one variable or getting bombarded with requests, two new functions have been added when starting up, obtain_mac_adress and obtain_snapshot_uri when i remove the obtain_mac_adress function it’ll finish the async_check_date_and_time function. Running my own python script to collect onvif information being careful not to request things twice seems to get through all of the info.

But if i run the same function twice it errors out on Cannot write to closing transport and then Can not write request body

A work around in the meantime until this is fixed is to download the onvif component directory from the 0.106.6 version and place it in your custom_components directory and restart home assistant. https://github.com/home-assistant/core/tree/0.106.6/homeassistant/components/onvif

This is what has got my cameras back up and running.