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:
Steven Looman authored and Diogo Gomes committed 2018-12-21 17:25:23 +00:00
1 parent 5efc61feaf
commit 501b3f9927
12 files changed
+195 -653

No files matched your search

+19 -3
View File
@@ -10,7 +10,7 @@ import logging
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.components.upnp.const import DOMAIN as DATA_UPNP
from homeassistant.components.upnp.const import DOMAIN as DOMAIN_UPNP
from homeassistant.components.upnp.const import SIGNAL_REMOVE_SENSOR
@@ -73,8 +73,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(sensors, True)
data = config_entry.data
udn = data['udn']
device = hass.data[DATA_UPNP]['devices'][udn]
if 'udn' in data:
udn = data['udn']
else:
# any device will do
udn = list(hass.data[DOMAIN_UPNP]['devices'].keys())[0]
device = hass.data[DOMAIN_UPNP]['devices'][udn]
async_add_sensor(device)
@@ -100,6 +105,17 @@ class UpnpSensor(Entity):
self.hass.async_create_task(self.async_remove())
@property
def device_info(self):
"""Get device info."""
return {
'identifiers': {
(DOMAIN_UPNP, self.unique_id)
},
'name': self.name,
'via_hub': (DOMAIN_UPNP, self._device.udn),
}
class RawUPnPIGDSensor(UpnpSensor):
"""Representation of a UPnP/IGD sensor."""