From e5c1ce65df2d5775f16b11b4d7ec90885927d7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Fri, 23 Jun 2023 14:26:38 +0200 Subject: [PATCH] Use entity name in Airzone Cloud sensors (#95102) --- homeassistant/components/airzone_cloud/sensor.py | 11 +++-------- tests/components/airzone_cloud/test_sensor.py | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/airzone_cloud/sensor.py b/homeassistant/components/airzone_cloud/sensor.py index ee162ef5fec..2bc3f7fbda4 100644 --- a/homeassistant/components/airzone_cloud/sensor.py +++ b/homeassistant/components/airzone_cloud/sensor.py @@ -6,7 +6,6 @@ from typing import Any, Final from aioairzone_cloud.const import ( AZD_AIDOOS, AZD_HUMIDITY, - AZD_NAME, AZD_TEMP, AZD_WEBSERVERS, AZD_WIFI_RSSI, @@ -42,7 +41,6 @@ AIDOO_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( SensorEntityDescription( device_class=SensorDeviceClass.TEMPERATURE, key=AZD_TEMP, - name="Temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), @@ -53,9 +51,7 @@ WEBSERVER_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( device_class=SensorDeviceClass.SIGNAL_STRENGTH, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, - has_entity_name=True, key=AZD_WIFI_RSSI, - name="RSSI", native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, state_class=SensorStateClass.MEASUREMENT, ), @@ -65,14 +61,12 @@ ZONE_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( SensorEntityDescription( device_class=SensorDeviceClass.TEMPERATURE, key=AZD_TEMP, - name="Temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( device_class=SensorDeviceClass.HUMIDITY, key=AZD_HUMIDITY, - name="Humidity", native_unit_of_measurement=PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, ), @@ -161,7 +155,7 @@ class AirzoneAidooSensor(AirzoneAidooEntity, AirzoneSensor): """Initialize.""" super().__init__(coordinator, entry, aidoo_id, aidoo_data) - self._attr_name = f"{aidoo_data[AZD_NAME]} {description.name}" + self._attr_has_entity_name = True self._attr_unique_id = f"{aidoo_id}_{description.key}" self.entity_description = description @@ -182,6 +176,7 @@ class AirzoneWebServerSensor(AirzoneWebServerEntity, AirzoneSensor): """Initialize.""" super().__init__(coordinator, entry, ws_id, ws_data) + self._attr_has_entity_name = True self._attr_unique_id = f"{ws_id}_{description.key}" self.entity_description = description @@ -202,7 +197,7 @@ class AirzoneZoneSensor(AirzoneZoneEntity, AirzoneSensor): """Initialize.""" super().__init__(coordinator, entry, zone_id, zone_data) - self._attr_name = f"{zone_data[AZD_NAME]} {description.name}" + self._attr_has_entity_name = True self._attr_unique_id = f"{zone_id}_{description.key}" self.entity_description = description diff --git a/tests/components/airzone_cloud/test_sensor.py b/tests/components/airzone_cloud/test_sensor.py index 41807fac78b..d9b19f93f7d 100644 --- a/tests/components/airzone_cloud/test_sensor.py +++ b/tests/components/airzone_cloud/test_sensor.py @@ -17,10 +17,10 @@ async def test_airzone_create_sensors( assert state.state == "21.0" # WebServers - state = hass.states.get("sensor.webserver_11_22_33_44_55_66_rssi") + state = hass.states.get("sensor.webserver_11_22_33_44_55_66_signal_strength") assert state.state == "-56" - state = hass.states.get("sensor.webserver_11_22_33_44_55_67_rssi") + state = hass.states.get("sensor.webserver_11_22_33_44_55_67_signal_strength") assert state.state == "-77" # Zones