-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensor.py
36 lines (27 loc) · 955 Bytes
/
sensor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from . import LOGGER, CONST, DOMAIN
from nordigen_lib.sensor import build_sensors
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the sensor platform via discovery only."""
if discovery_info is None:
return
LOGGER.info(
"Nordigen will attempt to configure [%s] accounts",
len(discovery_info["accounts"]),
)
entities = []
for account in discovery_info.get("accounts"):
LOGGER.debug("Registering sensor for account :%s", account)
entities.extend(
await build_sensors(
hass=hass,
LOGGER=LOGGER,
account=account,
CONST=CONST,
)
)
if not len(entities):
return False
LOGGER.info("Total of [%s] Nordigen account sensors configured", len(entities))
LOGGER.debug("entities :%s", entities)
add_entities(entities)
return True