|
3 | 3 | from dataclasses import dataclass |
4 | 4 |
|
5 | 5 | from pyHomee.const import AttributeChangedBy, AttributeType |
6 | | -from pyHomee.model import HomeeAttribute |
| 6 | +from pyHomee.model import HomeeAttribute, HomeeNode |
7 | 7 |
|
8 | 8 | from homeassistant.components.alarm_control_panel import ( |
9 | 9 | AlarmControlPanelEntity, |
|
17 | 17 |
|
18 | 18 | from . import DOMAIN, HomeeConfigEntry |
19 | 19 | from .entity import HomeeEntity |
20 | | -from .helpers import get_name_for_enum |
| 20 | +from .helpers import get_name_for_enum, setup_homee_platform |
21 | 21 |
|
22 | 22 | PARALLEL_UPDATES = 0 |
23 | 23 |
|
@@ -60,21 +60,32 @@ def get_supported_features( |
60 | 60 | return supported_features |
61 | 61 |
|
62 | 62 |
|
63 | | -async def async_setup_entry( |
64 | | - hass: HomeAssistant, |
| 63 | +async def add_alarm_control_panel_entities( |
65 | 64 | config_entry: HomeeConfigEntry, |
66 | 65 | async_add_entities: AddConfigEntryEntitiesCallback, |
| 66 | + nodes: list[HomeeNode], |
67 | 67 | ) -> None: |
68 | | - """Add the Homee platform for the alarm control panel component.""" |
69 | | - |
| 68 | + """Add homee alarm control panel entities.""" |
70 | 69 | async_add_entities( |
71 | 70 | HomeeAlarmPanel(attribute, config_entry, ALARM_DESCRIPTIONS[attribute.type]) |
72 | | - for node in config_entry.runtime_data.nodes |
| 71 | + for node in nodes |
73 | 72 | for attribute in node.attributes |
74 | 73 | if attribute.type in ALARM_DESCRIPTIONS and attribute.editable |
75 | 74 | ) |
76 | 75 |
|
77 | 76 |
|
| 77 | +async def async_setup_entry( |
| 78 | + hass: HomeAssistant, |
| 79 | + config_entry: HomeeConfigEntry, |
| 80 | + async_add_entities: AddConfigEntryEntitiesCallback, |
| 81 | +) -> None: |
| 82 | + """Add the homee platform for the alarm control panel component.""" |
| 83 | + |
| 84 | + await setup_homee_platform( |
| 85 | + add_alarm_control_panel_entities, async_add_entities, config_entry |
| 86 | + ) |
| 87 | + |
| 88 | + |
78 | 89 | class HomeeAlarmPanel(HomeeEntity, AlarmControlPanelEntity): |
79 | 90 | """Representation of a Homee alarm control panel.""" |
80 | 91 |
|
|
0 commit comments