Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -5,10 +5,14 @@ from homeassistant.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
from .const import (ATTR_SENSOR_STATE,
|
||||
ATTR_SENSOR_TYPE_SENSOR as ENTITY_TYPE,
|
||||
ATTR_SENSOR_UNIQUE_ID, ATTR_SENSOR_UOM, DATA_DEVICES,
|
||||
DOMAIN)
|
||||
from .const import (
|
||||
ATTR_SENSOR_STATE,
|
||||
ATTR_SENSOR_TYPE_SENSOR as ENTITY_TYPE,
|
||||
ATTR_SENSOR_UNIQUE_ID,
|
||||
ATTR_SENSOR_UOM,
|
||||
DATA_DEVICES,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
from .entity import MobileAppEntity, sensor_id
|
||||
|
||||
@@ -34,23 +38,24 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
if data[CONF_WEBHOOK_ID] != webhook_id:
|
||||
return
|
||||
|
||||
unique_id = sensor_id(data[CONF_WEBHOOK_ID],
|
||||
data[ATTR_SENSOR_UNIQUE_ID])
|
||||
unique_id = sensor_id(data[CONF_WEBHOOK_ID], data[ATTR_SENSOR_UNIQUE_ID])
|
||||
|
||||
entity = hass.data[DOMAIN][ENTITY_TYPE][unique_id]
|
||||
|
||||
if 'added' in entity:
|
||||
if "added" in entity:
|
||||
return
|
||||
|
||||
entity['added'] = True
|
||||
entity["added"] = True
|
||||
|
||||
device = hass.data[DOMAIN][DATA_DEVICES][data[CONF_WEBHOOK_ID]]
|
||||
|
||||
async_add_entities([MobileAppSensor(data, device, config_entry)])
|
||||
|
||||
async_dispatcher_connect(hass,
|
||||
'{}_{}_register'.format(DOMAIN, ENTITY_TYPE),
|
||||
partial(handle_sensor_registration, webhook_id))
|
||||
async_dispatcher_connect(
|
||||
hass,
|
||||
"{}_{}_register".format(DOMAIN, ENTITY_TYPE),
|
||||
partial(handle_sensor_registration, webhook_id),
|
||||
)
|
||||
|
||||
|
||||
class MobileAppSensor(MobileAppEntity):
|
||||
|
||||
Reference in new issue
Block a user