mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
iaqualink: enable _attr_has_entity_name (#167810)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
co-authored by
Joost Lekkerkerker
parent
073d22d046
commit
8695d32b32
@@ -42,7 +42,6 @@ class HassAqualinkBinarySensor(
|
||||
) -> None:
|
||||
"""Initialize AquaLink binary sensor."""
|
||||
super().__init__(coordinator, dev)
|
||||
self._attr_name = dev.label
|
||||
if dev.label == "Freeze Protection":
|
||||
self._attr_device_class = BinarySensorDeviceClass.COLD
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ class HassAqualinkThermostat(AqualinkEntity[AqualinkThermostat], ClimateEntity):
|
||||
) -> None:
|
||||
"""Initialize AquaLink thermostat."""
|
||||
super().__init__(coordinator, dev)
|
||||
self._attr_name = dev.label.split(" ")[0]
|
||||
self._attr_temperature_unit = (
|
||||
UnitOfTemperature.FAHRENHEIT
|
||||
if dev.unit == "F"
|
||||
|
||||
@@ -22,6 +22,9 @@ class AqualinkEntity[AqualinkDeviceT: AqualinkDevice](
|
||||
entity update flow.
|
||||
"""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self, coordinator: AqualinkDataUpdateCoordinator, dev: AqualinkDeviceT
|
||||
) -> None:
|
||||
|
||||
@@ -46,7 +46,6 @@ class HassAqualinkLight(AqualinkEntity[AqualinkLight], LightEntity):
|
||||
) -> None:
|
||||
"""Initialize AquaLink light."""
|
||||
super().__init__(coordinator, dev)
|
||||
self._attr_name = dev.label
|
||||
if dev.supports_effect:
|
||||
self._attr_effect_list = list(dev.supported_effects)
|
||||
self._attr_supported_features = LightEntityFeature.EFFECT
|
||||
|
||||
@@ -38,7 +38,6 @@ class HassAqualinkSensor(AqualinkEntity[AqualinkSensor], SensorEntity):
|
||||
) -> None:
|
||||
"""Initialize AquaLink sensor."""
|
||||
super().__init__(coordinator, dev)
|
||||
self._attr_name = dev.label
|
||||
if not dev.name.endswith("_temp"):
|
||||
return
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
|
||||
@@ -40,7 +40,7 @@ class HassAqualinkSwitch(AqualinkEntity[AqualinkSwitch], SwitchEntity):
|
||||
) -> None:
|
||||
"""Initialize AquaLink switch."""
|
||||
super().__init__(coordinator, dev)
|
||||
name = self._attr_name = dev.label
|
||||
name = dev.label
|
||||
if name == "Cleaner":
|
||||
self._attr_icon = "mdi:robot-vacuum"
|
||||
elif name == "Waterfall" or name.endswith("Dscnt"):
|
||||
|
||||
@@ -34,6 +34,7 @@ from homeassistant.const import (
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import get_aqualink_device, get_aqualink_system
|
||||
@@ -82,8 +83,11 @@ async def test_system_refresh_failure_marks_entities_unavailable(
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
name = f"{LIGHT_DOMAIN}.{light.name}"
|
||||
state = hass.states.get(name)
|
||||
entity_ids = hass.states.async_entity_ids(LIGHT_DOMAIN)
|
||||
assert len(entity_ids) == 1
|
||||
entity_id = entity_ids[0]
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
@@ -95,7 +99,7 @@ async def test_system_refresh_failure_marks_entities_unavailable(
|
||||
|
||||
await _advance_coordinator_time(hass, freezer)
|
||||
|
||||
state = hass.states.get(name)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
@@ -140,7 +144,10 @@ async def test_light_service_calls_update_entity_state(
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_id = f"{LIGHT_DOMAIN}.{light.name}"
|
||||
entity_ids = hass.states.async_entity_ids(LIGHT_DOMAIN)
|
||||
assert len(entity_ids) == 1
|
||||
entity_id = entity_ids[0]
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_ON
|
||||
@@ -408,6 +415,7 @@ async def test_setup_all_good_all_device_types(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
client: AqualinkClient,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test setup ending in one device of each type recognized."""
|
||||
config_entry.add_to_hass(hass)
|
||||
@@ -469,6 +477,18 @@ async def test_setup_all_good_all_device_types(
|
||||
assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 1
|
||||
assert len(hass.states.async_entity_ids(SWITCH_DOMAIN)) == 1
|
||||
|
||||
for domain in (
|
||||
BINARY_SENSOR_DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SENSOR_DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
):
|
||||
for entity_id in hass.states.async_entity_ids(domain):
|
||||
entry = entity_registry.async_get(entity_id)
|
||||
assert entry is not None
|
||||
assert entry.has_entity_name is True
|
||||
|
||||
assert await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -511,7 +531,9 @@ async def test_multiple_updates(
|
||||
|
||||
assert config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
entity_id = f"{LIGHT_DOMAIN}.{light.name}"
|
||||
entity_ids = hass.states.async_entity_ids(LIGHT_DOMAIN)
|
||||
assert len(entity_ids) == 1
|
||||
entity_id = entity_ids[0]
|
||||
|
||||
def assert_state(expected_state: str) -> None:
|
||||
state = hass.states.get(entity_id)
|
||||
@@ -632,9 +654,10 @@ async def test_entity_assumed_and_available(
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids(LIGHT_DOMAIN)) == 1
|
||||
entity_ids = hass.states.async_entity_ids(LIGHT_DOMAIN)
|
||||
assert len(entity_ids) == 1
|
||||
|
||||
name = f"{LIGHT_DOMAIN}.{light.name}"
|
||||
name = entity_ids[0]
|
||||
|
||||
# None means maybe.
|
||||
light.system.online = None
|
||||
|
||||
Reference in New Issue
Block a user