From 0e2e39a5f2d067325ec2db80acadc5683052fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diefferson=20Koderer=20M=C3=B4ro?= Date: Tue, 2 Jun 2020 23:45:20 -0300 Subject: [PATCH] Fix Method GetNetworkInterfaces not implemented (#36243) --- homeassistant/components/onvif/config_flow.py | 18 ++++++++++++++---- homeassistant/components/onvif/device.py | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/onvif/config_flow.py b/homeassistant/components/onvif/config_flow.py index 29784b2542987..fada2d497a74d 100644 --- a/homeassistant/components/onvif/config_flow.py +++ b/homeassistant/components/onvif/config_flow.py @@ -205,10 +205,20 @@ async def async_step_profiles(self, user_input=None): # Get the MAC address to use as the unique ID for the config flow if not self.device_id: - network_interfaces = await device_mgmt.GetNetworkInterfaces() - for interface in network_interfaces: - if interface.Enabled: - self.device_id = interface.Info.HwAddress + try: + network_interfaces = await device_mgmt.GetNetworkInterfaces() + for interface in network_interfaces: + if interface.Enabled: + self.device_id = interface.Info.HwAddress + except Fault as fault: + if "not implemented" not in fault.message: + raise fault + + LOGGER.debug( + "Couldn't get network interfaces from ONVIF deivice '%s'. Error: %s", + self.onvif_config[CONF_NAME], + fault, + ) # If no network interfaces are exposed, fallback to serial number if not self.device_id: diff --git a/homeassistant/components/onvif/device.py b/homeassistant/components/onvif/device.py index bbce71f5d286e..eec270d5b94ba 100644 --- a/homeassistant/components/onvif/device.py +++ b/homeassistant/components/onvif/device.py @@ -217,10 +217,20 @@ async def async_get_device_info(self) -> DeviceInfo: # Grab the last MAC address for backwards compatibility mac = None - network_interfaces = await device_mgmt.GetNetworkInterfaces() - for interface in network_interfaces: - if interface.Enabled: - mac = interface.Info.HwAddress + try: + network_interfaces = await device_mgmt.GetNetworkInterfaces() + for interface in network_interfaces: + if interface.Enabled: + mac = interface.Info.HwAddress + except Fault as fault: + if "not implemented" not in fault.message: + raise fault + + LOGGER.debug( + "Couldn't get network interfaces from ONVIF deivice '%s'. Error: %s", + self.name, + fault, + ) return DeviceInfo( device_info.Manufacturer,