Add model to Teslemetry Wall Connectors (#119251)

This commit is contained in:
Brett Adams 2024-06-10 15:48:09 +10:00 committed by GitHub
parent 8a0cc55278
commit 159503b8d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 6 deletions

View file

@ -211,6 +211,14 @@ class TeslemetryWallConnectorEntity(
"""Initialize common aspects of a Teslemetry entity."""
self.din = din
self._attr_unique_id = f"{data.id}-{din}-{key}"
# Find the model from the info coordinator
model: str | None = None
for wc in data.info_coordinator.data.get("components_wall_connectors", []):
if wc["din"] == din:
model = wc.get("part_name")
break
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, din)},
manufacturer="Tesla",
@ -218,6 +226,7 @@ class TeslemetryWallConnectorEntity(
name="Wall Connector",
via_device=(DOMAIN, str(data.id)),
serial_number=din.split("-")[-1],
model=model,
)
super().__init__(data.live_coordinator, data.api, key)

View file

@ -82,12 +82,14 @@
"wall_connectors": [
{
"device_id": "123abc",
"din": "abc123",
"din": "abd-123",
"part_name": "Gen 3 Wall Connector",
"is_active": true
},
{
"device_id": "234bcd",
"din": "bcd234",
"din": "bcd-234",
"part_name": "Gen 3 Wall Connector",
"is_active": true
}
],

View file

@ -76,13 +76,15 @@
'components_wall_connectors': list([
dict({
'device_id': '123abc',
'din': 'abc123',
'din': 'abd-123',
'is_active': True,
'part_name': 'Gen 3 Wall Connector',
}),
dict({
'device_id': '234bcd',
'din': 'bcd234',
'din': 'bcd-234',
'is_active': True,
'part_name': 'Gen 3 Wall Connector',
}),
]),
'components_wifi_commissioning_enabled': True,

View file

@ -80,7 +80,7 @@
'labels': set({
}),
'manufacturer': 'Tesla',
'model': None,
'model': 'Gen 3 Wall Connector',
'name': 'Wall Connector',
'name_by_user': None,
'serial_number': '123',
@ -110,7 +110,7 @@
'labels': set({
}),
'manufacturer': 'Tesla',
'model': None,
'model': 'Gen 3 Wall Connector',
'name': 'Wall Connector',
'name_by_user': None,
'serial_number': '234',