1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 00:20:30 +01:00

Fix incomplete device info in laundrify sensor (#164824)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Erik Montnemery
2026-03-05 17:08:31 +01:00
committed by GitHub
parent ae90c5fa92
commit bc138b3485
2 changed files with 18 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
from .const import DOMAIN, MANUFACTURER, MODELS
from .coordinator import LaundrifyConfigEntry, LaundrifyUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
@@ -47,7 +47,14 @@ class LaundrifyBaseSensor(SensorEntity):
def __init__(self, device: LaundrifyDevice) -> None:
"""Initialize the sensor."""
self._device = device
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, device.id)})
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device.id)},
name=device.name,
manufacturer=MANUFACTURER,
model=MODELS[device.model],
sw_version=device.firmwareVersion,
configuration_url=f"http://{device.internalIP}",
)
self._attr_unique_id = f"{device.id}_{self._attr_device_class}"

View File

@@ -1,5 +1,6 @@
"""Test the laundrify sensor platform."""
from collections.abc import AsyncGenerator
from datetime import timedelta
import logging
from unittest.mock import patch
@@ -19,6 +20,7 @@ from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_UNIT_OF_MEASUREMENT,
STATE_UNKNOWN,
Platform,
UnitOfPower,
)
from homeassistant.core import HomeAssistant
@@ -28,6 +30,13 @@ from homeassistant.util import slugify
from tests.common import MockConfigEntry, async_fire_time_changed
@pytest.fixture(autouse=True)
async def platforms() -> AsyncGenerator[None]:
"""Return the platforms to be loaded for this test."""
with patch("homeassistant.components.laundrify.PLATFORMS", [Platform.SENSOR]):
yield
async def test_laundrify_sensor_init(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,