diff --git a/homeassistant/components/luftdaten/sensor.py b/homeassistant/components/luftdaten/sensor.py index 055820de3a0..5333d86a708 100644 --- a/homeassistant/components/luftdaten/sensor.py +++ b/homeassistant/components/luftdaten/sensor.py @@ -97,6 +97,7 @@ class SensorCommunitySensor(CoordinatorEntity, SensorEntity): """Implementation of a Sensor.Community sensor.""" _attr_attribution = "Data provided by Sensor.Community" + _attr_has_entity_name = True _attr_should_poll = False def __init__( diff --git a/tests/components/luftdaten/test_sensor.py b/tests/components/luftdaten/test_sensor.py index 3cf4426d500..f3d0f1c0b1f 100644 --- a/tests/components/luftdaten/test_sensor.py +++ b/tests/components/luftdaten/test_sensor.py @@ -29,71 +29,73 @@ async def test_luftdaten_sensors( entity_registry = er.async_get(hass) device_registry = dr.async_get(hass) - entry = entity_registry.async_get("sensor.temperature") + entry = entity_registry.async_get("sensor.sensor_12345_temperature") assert entry assert entry.device_id assert entry.unique_id == "12345_temperature" - state = hass.states.get("sensor.temperature") + state = hass.states.get("sensor.sensor_12345_temperature") assert state assert state.state == "22.3" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Temperature" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 Temperature" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS assert ATTR_ICON not in state.attributes - entry = entity_registry.async_get("sensor.humidity") + entry = entity_registry.async_get("sensor.sensor_12345_humidity") assert entry assert entry.device_id assert entry.unique_id == "12345_humidity" - state = hass.states.get("sensor.humidity") + state = hass.states.get("sensor.sensor_12345_humidity") assert state assert state.state == "34.7" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Humidity" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 Humidity" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.HUMIDITY assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE assert ATTR_ICON not in state.attributes - entry = entity_registry.async_get("sensor.pressure") + entry = entity_registry.async_get("sensor.sensor_12345_pressure") assert entry assert entry.device_id assert entry.unique_id == "12345_pressure" - state = hass.states.get("sensor.pressure") + state = hass.states.get("sensor.sensor_12345_pressure") assert state assert state.state == "98545.0" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Pressure" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 Pressure" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PRESSURE_PA assert ATTR_ICON not in state.attributes - entry = entity_registry.async_get("sensor.pressure_at_sealevel") + entry = entity_registry.async_get("sensor.sensor_12345_pressure_at_sealevel") assert entry assert entry.device_id assert entry.unique_id == "12345_pressure_at_sealevel" - state = hass.states.get("sensor.pressure_at_sealevel") + state = hass.states.get("sensor.sensor_12345_pressure_at_sealevel") assert state assert state.state == "103102.13" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Pressure at sealevel" + assert ( + state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 Pressure at sealevel" + ) assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PRESSURE_PA assert ATTR_ICON not in state.attributes - entry = entity_registry.async_get("sensor.pm10") + entry = entity_registry.async_get("sensor.sensor_12345_pm10") assert entry assert entry.device_id assert entry.unique_id == "12345_P1" - state = hass.states.get("sensor.pm10") + state = hass.states.get("sensor.sensor_12345_pm10") assert state assert state.state == "8.5" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "PM10" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 PM10" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10 assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert ( @@ -102,15 +104,15 @@ async def test_luftdaten_sensors( ) assert ATTR_ICON not in state.attributes - entry = entity_registry.async_get("sensor.pm2_5") + entry = entity_registry.async_get("sensor.sensor_12345_pm2_5") assert entry assert entry.device_id assert entry.unique_id == "12345_P2" - state = hass.states.get("sensor.pm2_5") + state = hass.states.get("sensor.sensor_12345_pm2_5") assert state assert state.state == "4.07" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "PM2.5" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 PM2.5" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25 assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert (