Skip to content

Commit

Permalink
Fix Method GetNetworkInterfaces not implemented (home-assistant#36243)
Browse files Browse the repository at this point in the history
  • Loading branch information
djpremier authored Jun 3, 2020
1 parent a7a58b9 commit 0e2e39a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
18 changes: 14 additions & 4 deletions homeassistant/components/onvif/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 14 additions & 4 deletions homeassistant/components/onvif/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0e2e39a

Please sign in to comment.