Properly connect sensors to hub (#21414)
* Properly connect sensors to hub Refs #20958 * Don't connect (merge) with main device * Provide manufacturer * Linting * Do connect upnp-sensors to main device * Linting * Fix requirements_all.txt
This commit is contained in:
parent
adca598172
commit
d1f75fcf32
2 changed files with 13 additions and 3 deletions
|
@ -23,7 +23,10 @@ class Device:
|
||||||
async def async_discover(cls, hass: HomeAssistantType):
|
async def async_discover(cls, hass: HomeAssistantType):
|
||||||
"""Discovery UPNP/IGD devices."""
|
"""Discovery UPNP/IGD devices."""
|
||||||
_LOGGER.debug('Discovering UPnP/IGD devices')
|
_LOGGER.debug('Discovering UPnP/IGD devices')
|
||||||
local_ip = hass.data[DOMAIN]['config'].get(CONF_LOCAL_IP)
|
local_ip = None
|
||||||
|
if DOMAIN in hass.data and \
|
||||||
|
'config' in hass.data[DOMAIN]:
|
||||||
|
local_ip = hass.data[DOMAIN]['config'].get(CONF_LOCAL_IP)
|
||||||
if local_ip:
|
if local_ip:
|
||||||
local_ip = IPv4Address(local_ip)
|
local_ip = IPv4Address(local_ip)
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
|
||||||
from .const import DOMAIN as DOMAIN_UPNP, SIGNAL_REMOVE_SENSOR
|
from .const import DOMAIN as DOMAIN_UPNP, SIGNAL_REMOVE_SENSOR
|
||||||
|
|
||||||
|
@ -46,7 +48,9 @@ OUT = 'sent'
|
||||||
KBYTE = 1024
|
KBYTE = 1024
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities,
|
async def async_setup_platform(hass: HomeAssistantType,
|
||||||
|
config,
|
||||||
|
async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Old way of setting up UPnP/IGD sensors."""
|
"""Old way of setting up UPnP/IGD sensors."""
|
||||||
_LOGGER.debug('async_setup_platform: config: %s, discovery: %s',
|
_LOGGER.debug('async_setup_platform: config: %s, discovery: %s',
|
||||||
|
@ -111,8 +115,11 @@ class UpnpSensor(Entity):
|
||||||
'identifiers': {
|
'identifiers': {
|
||||||
(DOMAIN_UPNP, self.unique_id)
|
(DOMAIN_UPNP, self.unique_id)
|
||||||
},
|
},
|
||||||
|
'connections': {
|
||||||
|
(dr.CONNECTION_UPNP, self._device.udn)
|
||||||
|
},
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'via_hub': (DOMAIN_UPNP, self._device.udn),
|
'manufacturer': self._device.manufacturer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue