|
19 | 19 |
|
20 | 20 | from matter_server.client.adapter import AbstractMatterAdapter
|
21 | 21 | from matter_server.common.json_utils import CHIPJSONDecoder, CHIPJSONEncoder
|
| 22 | +from matter_server.vendor import device_types |
22 | 23 | from matter_server.vendor.chip.clusters import Objects as all_clusters
|
23 | 24 |
|
24 | 25 | from .const import DOMAIN
|
@@ -91,6 +92,8 @@ def get_matter_store(hass: HomeAssistant, config_entry: ConfigEntry) -> MatterSt
|
91 | 92 |
|
92 | 93 |
|
93 | 94 | class MatterAdapter(AbstractMatterAdapter):
|
| 95 | + """Connect Matter into Home Assistant.""" |
| 96 | + |
94 | 97 | def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
95 | 98 | self.hass = hass
|
96 | 99 | self.config_entry = config_entry
|
@@ -134,18 +137,22 @@ async def setup_node(self, node: MatterNode) -> None:
|
134 | 137 |
|
135 | 138 | basic_info = node.root_device.get_cluster(all_clusters.Basic)
|
136 | 139 |
|
137 |
| - kwargs = {} |
138 |
| - if basic_info.nodeLabel: |
139 |
| - kwargs["name"] = basic_info.nodeLabel |
| 140 | + name = basic_info.nodeLabel |
| 141 | + if not name: |
| 142 | + for device in node.devices: |
| 143 | + if device.device_type is device_types.RootNode: |
| 144 | + continue |
| 145 | + |
| 146 | + name = device.device_type.__doc__[:-1] |
140 | 147 |
|
141 | 148 | dr.async_get(self.hass).async_get_or_create(
|
| 149 | + name=name, |
142 | 150 | config_entry_id=self.config_entry.entry_id,
|
143 | 151 | identifiers={(DOMAIN, basic_info.uniqueID)},
|
144 | 152 | hw_version=basic_info.hardwareVersionString,
|
145 | 153 | sw_version=basic_info.softwareVersionString,
|
146 | 154 | manufacturer=basic_info.vendorName,
|
147 | 155 | model=basic_info.productName,
|
148 |
| - **kwargs, |
149 | 156 | )
|
150 | 157 |
|
151 | 158 | for device in node.devices:
|
|
0 commit comments