From 25968925e7af48a76d630e7d8a7c35e7c69bb74e Mon Sep 17 00:00:00 2001 From: DeerMaximum <43999966+DeerMaximum@users.noreply.github.com> Date: Sun, 22 Jun 2025 23:57:33 +0200 Subject: [PATCH] Use has_entity_name in NINA (#146755) * Comply with has-entity-name rule. * Fix tests --- .../components/nina/binary_sensor.py | 1 + tests/components/nina/test_binary_sensor.py | 60 +++++++++---------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/homeassistant/components/nina/binary_sensor.py b/homeassistant/components/nina/binary_sensor.py index be7e5995fbc..be37a802d47 100644 --- a/homeassistant/components/nina/binary_sensor.py +++ b/homeassistant/components/nina/binary_sensor.py @@ -56,6 +56,7 @@ class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEnti """Representation of an NINA warning.""" _attr_device_class = BinarySensorDeviceClass.SAFETY + _attr_has_entity_name = True def __init__( self, diff --git a/tests/components/nina/test_binary_sensor.py b/tests/components/nina/test_binary_sensor.py index 6ed1aee7e9d..d18b7562b53 100644 --- a/tests/components/nina/test_binary_sensor.py +++ b/tests/components/nina/test_binary_sensor.py @@ -66,8 +66,8 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) assert conf_entry.state is ConfigEntryState.LOADED - state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1") - entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1") + state_w1 = hass.states.get("binary_sensor.nina_warning_aach_stadt_1") + entry_w1 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_1") assert state_w1.state == STATE_ON assert state_w1.attributes.get(ATTR_HEADLINE) == "Ausfall Notruf 112" @@ -91,8 +91,8 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) assert entry_w1.unique_id == "083350000000-1" assert state_w1.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w2 = hass.states.get("binary_sensor.warning_aach_stadt_2") - entry_w2 = entity_registry.async_get("binary_sensor.warning_aach_stadt_2") + state_w2 = hass.states.get("binary_sensor.nina_warning_aach_stadt_2") + entry_w2 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_2") assert state_w2.state == STATE_OFF assert state_w2.attributes.get(ATTR_HEADLINE) is None @@ -110,8 +110,8 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) assert entry_w2.unique_id == "083350000000-2" assert state_w2.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w3 = hass.states.get("binary_sensor.warning_aach_stadt_3") - entry_w3 = entity_registry.async_get("binary_sensor.warning_aach_stadt_3") + state_w3 = hass.states.get("binary_sensor.nina_warning_aach_stadt_3") + entry_w3 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_3") assert state_w3.state == STATE_OFF assert state_w3.attributes.get(ATTR_HEADLINE) is None @@ -129,8 +129,8 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) assert entry_w3.unique_id == "083350000000-3" assert state_w3.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w4 = hass.states.get("binary_sensor.warning_aach_stadt_4") - entry_w4 = entity_registry.async_get("binary_sensor.warning_aach_stadt_4") + state_w4 = hass.states.get("binary_sensor.nina_warning_aach_stadt_4") + entry_w4 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_4") assert state_w4.state == STATE_OFF assert state_w4.attributes.get(ATTR_HEADLINE) is None @@ -148,8 +148,8 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) assert entry_w4.unique_id == "083350000000-4" assert state_w4.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w5 = hass.states.get("binary_sensor.warning_aach_stadt_5") - entry_w5 = entity_registry.async_get("binary_sensor.warning_aach_stadt_5") + state_w5 = hass.states.get("binary_sensor.nina_warning_aach_stadt_5") + entry_w5 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_5") assert state_w5.state == STATE_OFF assert state_w5.attributes.get(ATTR_HEADLINE) is None @@ -187,8 +187,8 @@ async def test_sensors_without_corona_filter( assert conf_entry.state is ConfigEntryState.LOADED - state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1") - entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1") + state_w1 = hass.states.get("binary_sensor.nina_warning_aach_stadt_1") + entry_w1 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_1") assert state_w1.state == STATE_ON assert ( @@ -218,8 +218,8 @@ async def test_sensors_without_corona_filter( assert entry_w1.unique_id == "083350000000-1" assert state_w1.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w2 = hass.states.get("binary_sensor.warning_aach_stadt_2") - entry_w2 = entity_registry.async_get("binary_sensor.warning_aach_stadt_2") + state_w2 = hass.states.get("binary_sensor.nina_warning_aach_stadt_2") + entry_w2 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_2") assert state_w2.state == STATE_ON assert state_w2.attributes.get(ATTR_HEADLINE) == "Ausfall Notruf 112" @@ -243,8 +243,8 @@ async def test_sensors_without_corona_filter( assert entry_w2.unique_id == "083350000000-2" assert state_w2.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w3 = hass.states.get("binary_sensor.warning_aach_stadt_3") - entry_w3 = entity_registry.async_get("binary_sensor.warning_aach_stadt_3") + state_w3 = hass.states.get("binary_sensor.nina_warning_aach_stadt_3") + entry_w3 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_3") assert state_w3.state == STATE_OFF assert state_w3.attributes.get(ATTR_HEADLINE) is None @@ -262,8 +262,8 @@ async def test_sensors_without_corona_filter( assert entry_w3.unique_id == "083350000000-3" assert state_w3.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w4 = hass.states.get("binary_sensor.warning_aach_stadt_4") - entry_w4 = entity_registry.async_get("binary_sensor.warning_aach_stadt_4") + state_w4 = hass.states.get("binary_sensor.nina_warning_aach_stadt_4") + entry_w4 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_4") assert state_w4.state == STATE_OFF assert state_w4.attributes.get(ATTR_HEADLINE) is None @@ -281,8 +281,8 @@ async def test_sensors_without_corona_filter( assert entry_w4.unique_id == "083350000000-4" assert state_w4.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w5 = hass.states.get("binary_sensor.warning_aach_stadt_5") - entry_w5 = entity_registry.async_get("binary_sensor.warning_aach_stadt_5") + state_w5 = hass.states.get("binary_sensor.nina_warning_aach_stadt_5") + entry_w5 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_5") assert state_w5.state == STATE_OFF assert state_w5.attributes.get(ATTR_HEADLINE) is None @@ -320,40 +320,40 @@ async def test_sensors_with_area_filter( assert conf_entry.state is ConfigEntryState.LOADED - state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1") - entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1") + state_w1 = hass.states.get("binary_sensor.nina_warning_aach_stadt_1") + entry_w1 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_1") assert state_w1.state == STATE_ON assert entry_w1.unique_id == "083350000000-1" assert state_w1.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w2 = hass.states.get("binary_sensor.warning_aach_stadt_2") - entry_w2 = entity_registry.async_get("binary_sensor.warning_aach_stadt_2") + state_w2 = hass.states.get("binary_sensor.nina_warning_aach_stadt_2") + entry_w2 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_2") assert state_w2.state == STATE_OFF assert entry_w2.unique_id == "083350000000-2" assert state_w2.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w3 = hass.states.get("binary_sensor.warning_aach_stadt_3") - entry_w3 = entity_registry.async_get("binary_sensor.warning_aach_stadt_3") + state_w3 = hass.states.get("binary_sensor.nina_warning_aach_stadt_3") + entry_w3 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_3") assert state_w3.state == STATE_OFF assert entry_w3.unique_id == "083350000000-3" assert state_w3.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w4 = hass.states.get("binary_sensor.warning_aach_stadt_4") - entry_w4 = entity_registry.async_get("binary_sensor.warning_aach_stadt_4") + state_w4 = hass.states.get("binary_sensor.nina_warning_aach_stadt_4") + entry_w4 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_4") assert state_w4.state == STATE_OFF assert entry_w4.unique_id == "083350000000-4" assert state_w4.attributes.get("device_class") == BinarySensorDeviceClass.SAFETY - state_w5 = hass.states.get("binary_sensor.warning_aach_stadt_5") - entry_w5 = entity_registry.async_get("binary_sensor.warning_aach_stadt_5") + state_w5 = hass.states.get("binary_sensor.nina_warning_aach_stadt_5") + entry_w5 = entity_registry.async_get("binary_sensor.nina_warning_aach_stadt_5") assert state_w5.state == STATE_OFF