Disable creating port mappings from UI, add discovery from component (#18565)
* Disable creating port mappings from UI, add discovery from component * Remove unused constant * Upgrade to async_upnp_client==0.13.6 and use manufacturer from device * Upgrade to async_upnp_client==0.13.7
This commit is contained in:
parent
5efc61feaf
commit
501b3f9927
12 changed files with 195 additions and 653 deletions
|
@ -18,6 +18,27 @@ class Device:
|
|||
self._igd_device = igd_device
|
||||
self._mapped_ports = []
|
||||
|
||||
@classmethod
|
||||
async def async_discover(cls, hass: HomeAssistantType):
|
||||
"""Discovery UPNP/IGD devices."""
|
||||
_LOGGER.debug('Discovering UPnP/IGD devices')
|
||||
|
||||
# discover devices
|
||||
from async_upnp_client.igd import IgdDevice
|
||||
discovery_infos = await IgdDevice.async_discover()
|
||||
|
||||
# add extra info and store devices
|
||||
devices = []
|
||||
for discovery_info in discovery_infos:
|
||||
discovery_info['udn'] = discovery_info['usn'].split('::')[0]
|
||||
discovery_info['ssdp_description'] = discovery_info['location']
|
||||
discovery_info['source'] = 'async_upnp_client'
|
||||
_LOGGER.debug('Discovered device: %s', discovery_info)
|
||||
|
||||
devices.append(discovery_info)
|
||||
|
||||
return devices
|
||||
|
||||
@classmethod
|
||||
async def async_create_device(cls,
|
||||
hass: HomeAssistantType,
|
||||
|
@ -34,7 +55,7 @@ class Device:
|
|||
disable_state_variable_validation=True)
|
||||
upnp_device = await factory.async_create_device(ssdp_description)
|
||||
|
||||
# wrap with async_upnp_client IgdDevice
|
||||
# wrap with async_upnp_client.IgdDevice
|
||||
from async_upnp_client.igd import IgdDevice
|
||||
igd_device = IgdDevice(upnp_device, None)
|
||||
|
||||
|
@ -50,6 +71,11 @@ class Device:
|
|||
"""Get the name."""
|
||||
return self._igd_device.name
|
||||
|
||||
@property
|
||||
def manufacturer(self):
|
||||
"""Get the manufacturer."""
|
||||
return self._igd_device.manufacturer
|
||||
|
||||
async def async_add_port_mappings(self, ports, local_ip):
|
||||
"""Add port mappings."""
|
||||
if local_ip == '127.0.0.1':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue