Fix NoEntitySpecifiedError during knx startup (#17366)

* Potential fix for #13699

* removed uneccessary initialization of hass

* removed hass from signature
This commit is contained in:
Julius Mittenzwei authored and Martin Hjelmare committed 2018-10-15 03:29:36 +02:00
1 parent c5905ee5ca
commit a71cc67efb
6 files changed
+42 -31

No files matched your search

+7 -5
View File
@@ -42,7 +42,7 @@ def async_add_entities_discovery(hass, discovery_info, async_add_entities):
entities = []
for device_name in discovery_info[ATTR_DISCOVER_DEVICES]:
device = hass.data[DATA_KNX].xknx.devices[device_name]
entities.append(KNXSensor(hass, device))
entities.append(KNXSensor(device))
async_add_entities(entities)
@@ -56,17 +56,15 @@ def async_add_entities_config(hass, config, async_add_entities):
group_address=config.get(CONF_ADDRESS),
value_type=config.get(CONF_TYPE))
hass.data[DATA_KNX].xknx.devices.add(sensor)
async_add_entities([KNXSensor(hass, sensor)])
async_add_entities([KNXSensor(sensor)])
class KNXSensor(Entity):
"""Representation of a KNX sensor."""
def __init__(self, hass, device):
def __init__(self, device):
"""Initialize of a KNX sensor."""
self.device = device
self.hass = hass
self.async_register_callbacks()
@callback
def async_register_callbacks(self):
@@ -76,6 +74,10 @@ class KNXSensor(Entity):
await self.async_update_ha_state()
self.device.register_device_updated_cb(after_update_callback)
async def async_added_to_hass(self):
"""Store register state change callback."""
self.async_register_callbacks()
@property
def name(self):
"""Return the name of the KNX device."""