mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Change naming of MQTT entities to correspond with HA guidelines (#95159)
* Set has_entity_name if device_name is set * revert unneeded formatting change * Add image platform * Follow up comment * Don't set `has_entity_name` without device name * Only set has_entity_name if a valid name is set * Follow device_class name and add tests * Follow up comments add extra tests * Move to helper - Log a warning * fix test * Allow to assign None as name explictly * Refactor * Log info messages when device name is not set * Revert scene schema change - no device link * Always set has_entity_name with device mapping * Always set `_attr_has_entity_name` * Cleanup
This commit is contained in:
@@ -48,6 +48,7 @@ from .test_common import (
|
||||
help_test_entity_device_info_with_identifier,
|
||||
help_test_entity_id_update_discovery_update,
|
||||
help_test_entity_id_update_subscriptions,
|
||||
help_test_entity_name,
|
||||
help_test_publishing_with_custom_encoding,
|
||||
help_test_reloadable,
|
||||
help_test_setting_attribute_via_mqtt_json_message,
|
||||
@@ -1121,3 +1122,21 @@ async def test_unload_entry(
|
||||
await help_test_unload_config_entry_with_platform(
|
||||
hass, mqtt_mock_entry, domain, config
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("expected_friendly_name", "device_class"),
|
||||
[("test", None), ("Humidity", "humidity"), ("Temperature", "temperature")],
|
||||
)
|
||||
async def test_entity_name(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
expected_friendly_name: str | None,
|
||||
device_class: str | None,
|
||||
) -> None:
|
||||
"""Test the entity name setup."""
|
||||
domain = number.DOMAIN
|
||||
config = DEFAULT_CONFIG
|
||||
await help_test_entity_name(
|
||||
hass, mqtt_mock_entry, domain, config, expected_friendly_name, device_class
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user