Show all UPNP/IGD sensors in one device (#27517)

* show all UPNP/IGD sensors in one device

* use device name correctly

* Use id of device
This commit is contained in:
escoand 2019-10-31 20:51:35 +01:00 committed by Fabian Affolter
parent ec373d90c1
commit 82729bef70
3 changed files with 11 additions and 2 deletions

View File

@ -162,6 +162,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry):
identifiers={(DOMAIN, device.udn)},
name=device.name,
manufacturer=device.manufacturer,
model=device.model_name,
)
# set up sensors

View File

@ -78,6 +78,11 @@ class Device:
"""Get the manufacturer."""
return self._igd_device.manufacturer
@property
def model_name(self):
"""Get the model name."""
return self._igd_device.model_name
async def async_add_port_mappings(self, ports, local_ip):
"""Add port mappings."""
if local_ip == "127.0.0.1":

View File

@ -2,6 +2,7 @@
import logging
from homeassistant.core import callback
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
@ -93,9 +94,11 @@ class UpnpSensor(Entity):
def device_info(self):
"""Get device info."""
return {
"identifiers": {(DOMAIN_UPNP, self.unique_id)},
"name": self.name,
"connections": {(dr.CONNECTION_UPNP, self._device.udn)},
"identifiers": {(DOMAIN_UPNP, self._device.udn)},
"name": self._device.name,
"manufacturer": self._device.manufacturer,
"model": self._device.model_name,
}