mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Sort discovered entries by 'st' to ensure getting the same device each discovery (#23763)
This commit is contained in:
parent
068749bcbe
commit
05960fa29c
@ -1,5 +1,6 @@
|
|||||||
"""Open ports in your router for Home Assistant and provide statistics."""
|
"""Open ports in your router for Home Assistant and provide statistics."""
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -88,6 +89,8 @@ async def async_discover_and_construct(hass, udn=None) -> Device:
|
|||||||
_LOGGER.warning('Wanted UPnP/IGD device with UDN "%s" not found, '
|
_LOGGER.warning('Wanted UPnP/IGD device with UDN "%s" not found, '
|
||||||
'aborting', udn)
|
'aborting', udn)
|
||||||
return None
|
return None
|
||||||
|
# ensure we're always taking the latest
|
||||||
|
filtered = sorted(filtered, key=itemgetter('st'), reverse=True)
|
||||||
discovery_info = filtered[0]
|
discovery_info = filtered[0]
|
||||||
else:
|
else:
|
||||||
# get the first/any
|
# get the first/any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user