Add model ID to awair (#125373)

* Add model ID to awair

* less diff
This commit is contained in:
Paulus Schoutsen 2024-09-05 19:42:50 -04:00 committed by GitHub
parent 0677a256ec
commit aa619c5594
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 8 deletions

View File

@ -293,6 +293,7 @@ class AwairSensor(CoordinatorEntity[AwairDataUpdateCoordinator], SensorEntity):
identifiers={(DOMAIN, self._device.uuid)},
manufacturer="Awair",
model=self._device.model,
model_id=self._device.device_type,
name=(
self._device.name
or cast(ConfigEntry, self.coordinator.config_entry).title

View File

@ -29,7 +29,7 @@ from homeassistant.const import (
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.entity_component import async_update_entity
from . import setup_awair
@ -48,16 +48,24 @@ SENSOR_TYPES_MAP = {
def assert_expected_properties(
hass: HomeAssistant,
registry: er.RegistryEntry,
name,
unique_id,
state_value,
entity_registry: er.RegistryEntry,
name: str,
unique_id: str,
state_value: str,
attributes: dict,
model="Awair",
model_id="awair",
):
"""Assert expected properties from a dict."""
entity_entry = entity_registry.async_get(name)
assert entity_entry.unique_id == unique_id
device_registry = dr.async_get(hass)
device_entry = device_registry.async_get(entity_entry.device_id)
assert device_entry is not None
assert device_entry.model == model
assert device_entry.model_id == model_id
entry = registry.async_get(name)
assert entry.unique_id == unique_id
state = hass.states.get(name)
assert state
assert state.state == state_value
@ -201,7 +209,10 @@ async def test_awair_gen2_sensors(
async def test_local_awair_sensors(
hass: HomeAssistant, entity_registry: er.EntityRegistry, local_devices, local_data
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
local_devices,
local_data,
) -> None:
"""Test expected sensors on a local Awair."""
@ -215,6 +226,8 @@ async def test_local_awair_sensors(
f"{local_devices['device_uuid']}_{SENSOR_TYPES_MAP[API_SCORE].unique_id_tag}",
"94",
{},
model="Awair Element",
model_id="awair-element",
)