Use has_entity_name in NINA (#146755)

* Comply with has-entity-name rule.

* Fix tests
This commit is contained in:
DeerMaximum 2025-06-22 23:57:33 +02:00 committed by GitHub
parent fcba1183f8
commit 25968925e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 30 deletions

View File

@ -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,

View File

@ -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