Fix NoEntitySpecifiedError during knx startup (#17366)
* Potential fix for #13699 * removed uneccessary initialization of hass * removed hass from signature
This commit is contained in:
1 parent
c5905ee5ca
commit
a71cc67efb
6 files changed
+42
-31
No files matched your search
@@ -69,7 +69,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(KNXBinarySensor(hass, device))
|
||||
entities.append(KNXBinarySensor(device))
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ def async_add_entities_config(hass, config, async_add_entities):
|
||||
reset_after=config.get(CONF_RESET_AFTER))
|
||||
hass.data[DATA_KNX].xknx.devices.add(binary_sensor)
|
||||
|
||||
entity = KNXBinarySensor(hass, binary_sensor)
|
||||
entity = KNXBinarySensor(binary_sensor)
|
||||
automations = config.get(CONF_AUTOMATION)
|
||||
if automations is not None:
|
||||
for automation in automations:
|
||||
@@ -103,11 +103,9 @@ def async_add_entities_config(hass, config, async_add_entities):
|
||||
class KNXBinarySensor(BinarySensorDevice):
|
||||
"""Representation of a KNX binary sensor."""
|
||||
|
||||
def __init__(self, hass, device):
|
||||
def __init__(self, device):
|
||||
"""Initialize of KNX binary sensor."""
|
||||
self.device = device
|
||||
self.hass = hass
|
||||
self.async_register_callbacks()
|
||||
self.automations = []
|
||||
|
||||
@callback
|
||||
@@ -118,6 +116,10 @@ class KNXBinarySensor(BinarySensorDevice):
|
||||
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."""
|
||||
|
||||
Reference in new issue
Block a user