How to turn off the warning info when ip camera is offline?

I have install onvif in homeassistant to serve ip camera,it works fine.
When the ip camera is offline,my hass always output the warning info:

2021-07-13 21:33:18 WARNING (MainThread) [homeassistant.components.onvif] Couldn't connect to camera 'camera', but will retry later. Error: [Errno 113] Connect call failed ('192.168.31.97', 80)
2021-07-13 21:34:41 WARNING (MainThread) [homeassistant.components.onvif] Couldn't connect to camera 'camera', but will retry later. Error: [Errno 113] Connect call failed ('192.168.31.97', 80)
2021-07-13 21:36:04 WARNING (MainThread) [homeassistant.components.onvif] Couldn't connect to camera 'camera', but will retry later. Error: [Errno 113] Connect call failed ('192.168.31.97', 80)
2021-07-13 21:37:28 WARNING (MainThread) [homeassistant.components.onvif] Couldn't connect to camera 'camera', but will retry later. Error: [Errno 113] Connect call failed ('192.168.31.97', 80)

How to turn off the warning info when ip camera is offline?

I don’t think there is an easy way to only turn off this specific warning. See below

You could set up your Logger so that it will ignore all log messages with log level lower than error from homeassistant.components.onvif.

However, you will lose all the other warnings (plus info and lower). List of warnings:

core/homeassistant/components/onvif$ rg -C 3 warning
device.py
124-                if profile.video.encoding == "H264"
125-            )
126-        except RequestError as err:
127:            LOGGER.warning(
128-                "Couldn't connect to camera '%s', but will retry later. Error: %s",
129-                self.name,
130-                err,
--
177-                cdate = device_time.LocalDateTime
178-
179-            if cdate is None:
180:                LOGGER.warning("Could not retrieve date/time on this camera")
181-            else:
182-                cam_date = dt.datetime(
183-                    cdate.Date.Year,
--
202-                self._dt_diff_seconds = dt_diff.total_seconds()
203-
204-                if self._dt_diff_seconds > 5:
205:                    LOGGER.warning(
206-                        "The date/time on the device (UTC) is '%s', "
207-                        "which is different from the system '%s', "
208-                        "this could lead to authentication issues",
--
210-                        system_date,
211-                    )
212-        except RequestError as err:
213:            LOGGER.warning(
214-                "Couldn't get device '%s' date/time. Error: %s", self.name, err
215-            )
216-
--
342-    ):
343-        """Perform a PTZ action on the camera."""
344-        if not self.capabilities.ptz:
345:            LOGGER.warning("PTZ actions are not supported on device '%s'", self.name)
346-            return
347-
348-        ptz_service = self.device.create_ptz_service()
--
367-            if move_mode == CONTINUOUS_MOVE:
368-                # Guard against unsupported operation
369-                if not profile.ptz.continuous:
370:                    LOGGER.warning(
371-                        "ContinuousMove not supported on device '%s'", self.name
372-                    )
373-                    return
--
387-            elif move_mode == RELATIVE_MOVE:
388-                # Guard against unsupported operation
389-                if not profile.ptz.relative:
390:                    LOGGER.warning(
391-                        "RelativeMove not supported on device '%s'", self.name
392-                    )
393-                    return
--
404-            elif move_mode == ABSOLUTE_MOVE:
405-                # Guard against unsupported operation
406-                if not profile.ptz.absolute:
407:                    LOGGER.warning(
408-                        "AbsoluteMove not supported on device '%s'", self.name
409-                    )
410-                    return
--
421-            elif move_mode == GOTOPRESET_MOVE:
422-                # Guard against unsupported operation
423-                if preset_val not in profile.ptz.presets:
424:                    LOGGER.warning(
425-                        "PTZ preset '%s' does not exist on device '%s'. Available Presets: %s",
426-                        preset_val,
427-                        self.name,
--
439-                await ptz_service.Stop(req)
440-        except ONVIFError as err:
441-            if "Bad Request" in err.reason:
442:                LOGGER.warning("Device '%s' doesn't support PTZ", self.name)
443-            else:
444-                LOGGER.error("Error trying to perform PTZ action: %s", err)
445-

event.py
131-            restarted = False
132-
133-        if not restarted:
134:            LOGGER.warning(
135-                "Failed to restart ONVIF PullPoint subscription for '%s'. Retrying",
136-                self.unique_id,
137-            )
--
177-                # Likley a shutdown event, nothing to see here
178-                return
179-            except SUBSCRIPTION_ERRORS as err:
180:                LOGGER.warning(
181-                    "Failed to fetch ONVIF PullPoint subscription messages for '%s': %s",
182-                    self.unique_id,
183-                    err,
--
222-            event = await parser(self.unique_id, msg)
223-
224-            if not event:
225:                LOGGER.warning("Unable to parse event from %s: %s", self.unique_id, msg)
226-                return
227-
228-            self._events[event.uid] = event

EDIT: See better solution in TazUk’s post below.

Build a filter to exclude that specific message using the filtering in the Logger component: Logger - Home Assistant

1 Like

Could I avoid onvif connecting if I already have a switch which shows that the camera is switched off?
My camera’s are only switched on during the night and when nobody is home.

Onvif continuously trying to connect and then filtering the log does not seem energy efficient.