mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Use model details data from library for Amazon Devices (#145601)
* Log warning for unknown models for Amazon Devices * use method from library * apply review comment * Fix --------- Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
parent
51562e5ab4
commit
15a7d13768
@ -1,9 +1,7 @@
|
|||||||
"""Defines a base Amazon Devices entity."""
|
"""Defines a base Amazon Devices entity."""
|
||||||
|
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from aioamazondevices.api import AmazonDevice
|
from aioamazondevices.api import AmazonDevice
|
||||||
from aioamazondevices.const import DEVICE_TYPE_TO_MODEL, SPEAKER_GROUP_MODEL
|
from aioamazondevices.const import SPEAKER_GROUP_MODEL
|
||||||
|
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity import EntityDescription
|
from homeassistant.helpers.entity import EntityDescription
|
||||||
@ -27,9 +25,7 @@ class AmazonEntity(CoordinatorEntity[AmazonDevicesCoordinator]):
|
|||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._serial_num = serial_num
|
self._serial_num = serial_num
|
||||||
model_details: dict[str, str] = cast(
|
model_details = coordinator.api.get_model_details(self.device)
|
||||||
"dict", DEVICE_TYPE_TO_MODEL.get(self.device.device_type)
|
|
||||||
)
|
|
||||||
model = model_details["model"] if model_details else None
|
model = model_details["model"] if model_details else None
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, serial_num)},
|
identifiers={(DOMAIN, serial_num)},
|
||||||
|
@ -29,5 +29,5 @@
|
|||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["aioamazondevices"],
|
"loggers": ["aioamazondevices"],
|
||||||
"quality_scale": "bronze",
|
"quality_scale": "bronze",
|
||||||
"requirements": ["aioamazondevices==2.0.1"]
|
"requirements": ["aioamazondevices==2.1.1"]
|
||||||
}
|
}
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -182,7 +182,7 @@ aioairzone-cloud==0.6.12
|
|||||||
aioairzone==1.0.0
|
aioairzone==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.amazon_devices
|
# homeassistant.components.amazon_devices
|
||||||
aioamazondevices==2.0.1
|
aioamazondevices==2.1.1
|
||||||
|
|
||||||
# homeassistant.components.ambient_network
|
# homeassistant.components.ambient_network
|
||||||
# homeassistant.components.ambient_station
|
# homeassistant.components.ambient_station
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -170,7 +170,7 @@ aioairzone-cloud==0.6.12
|
|||||||
aioairzone==1.0.0
|
aioairzone==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.amazon_devices
|
# homeassistant.components.amazon_devices
|
||||||
aioamazondevices==2.0.1
|
aioamazondevices==2.1.1
|
||||||
|
|
||||||
# homeassistant.components.ambient_network
|
# homeassistant.components.ambient_network
|
||||||
# homeassistant.components.ambient_station
|
# homeassistant.components.ambient_station
|
||||||
|
@ -4,6 +4,7 @@ from collections.abc import Generator
|
|||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from aioamazondevices.api import AmazonDevice
|
from aioamazondevices.api import AmazonDevice
|
||||||
|
from aioamazondevices.const import DEVICE_TYPE_TO_MODEL
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.amazon_devices.const import CONF_LOGIN_DATA, DOMAIN
|
from homeassistant.components.amazon_devices.const import CONF_LOGIN_DATA, DOMAIN
|
||||||
@ -57,6 +58,9 @@ def mock_amazon_devices_client() -> Generator[AsyncMock]:
|
|||||||
bluetooth_state=True,
|
bluetooth_state=True,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
client.get_model_details = lambda device: DEVICE_TYPE_TO_MODEL.get(
|
||||||
|
device.device_type
|
||||||
|
)
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user