diff --git a/homeassistant/components/tellduslive/binary_sensor.py b/homeassistant/components/tellduslive/binary_sensor.py index 1e7a30d6174..4abe1dfd174 100644 --- a/homeassistant/components/tellduslive/binary_sensor.py +++ b/homeassistant/components/tellduslive/binary_sensor.py @@ -34,6 +34,8 @@ async def async_setup_entry( class TelldusLiveSensor(TelldusLiveEntity, BinarySensorEntity): """Representation of a Tellstick sensor.""" + _attr_name = None + @property def is_on(self): """Return true if switch is on.""" diff --git a/homeassistant/components/tellduslive/cover.py b/homeassistant/components/tellduslive/cover.py index 4934bf811af..2a32756aa1b 100644 --- a/homeassistant/components/tellduslive/cover.py +++ b/homeassistant/components/tellduslive/cover.py @@ -35,6 +35,8 @@ async def async_setup_entry( class TelldusLiveCover(TelldusLiveEntity, CoverEntity): """Representation of a cover.""" + _attr_name = None + @property def is_closed(self) -> bool: """Return the current position of the cover.""" diff --git a/homeassistant/components/tellduslive/entry.py b/homeassistant/components/tellduslive/entry.py index ce9c5222fd5..fdacc02bfca 100644 --- a/homeassistant/components/tellduslive/entry.py +++ b/homeassistant/components/tellduslive/entry.py @@ -9,7 +9,6 @@ from homeassistant.const import ( ATTR_MANUFACTURER, ATTR_MODEL, ATTR_VIA_DEVICE, - DEVICE_DEFAULT_NAME, ) from homeassistant.core import callback from homeassistant.helpers.device_registry import DeviceInfo @@ -27,12 +26,12 @@ class TelldusLiveEntity(Entity): """Base class for all Telldus Live entities.""" _attr_should_poll = False + _attr_has_entity_name = True def __init__(self, client, device_id): """Initialize the entity.""" self._id = device_id self._client = client - self._name = self.device.name self._async_unsub_dispatcher_connect = None async def async_added_to_hass(self): @@ -50,8 +49,6 @@ class TelldusLiveEntity(Entity): @callback def _update_callback(self): """Return the property of the device might have changed.""" - if self.device.name: - self._name = self.device.name self.async_write_ha_state() @property @@ -74,11 +71,6 @@ class TelldusLiveEntity(Entity): """Return true if unable to access real state of entity.""" return True - @property - def name(self): - """Return name of device.""" - return self._name or DEVICE_DEFAULT_NAME - @property def available(self): """Return true if device is not offline.""" diff --git a/homeassistant/components/tellduslive/light.py b/homeassistant/components/tellduslive/light.py index 3b69b58966c..8284b386250 100644 --- a/homeassistant/components/tellduslive/light.py +++ b/homeassistant/components/tellduslive/light.py @@ -37,6 +37,7 @@ async def async_setup_entry( class TelldusLiveLight(TelldusLiveEntity, LightEntity): """Representation of a Tellstick Net light.""" + _attr_name = None _attr_color_mode = ColorMode.BRIGHTNESS _attr_supported_color_modes = {ColorMode.BRIGHTNESS} diff --git a/homeassistant/components/tellduslive/sensor.py b/homeassistant/components/tellduslive/sensor.py index d52fded3932..e15f89888b1 100644 --- a/homeassistant/components/tellduslive/sensor.py +++ b/homeassistant/components/tellduslive/sensor.py @@ -43,80 +43,73 @@ SENSOR_TYPE_BAROMETRIC_PRESSURE = "barpress" SENSOR_TYPES: dict[str, SensorEntityDescription] = { SENSOR_TYPE_TEMPERATURE: SensorEntityDescription( key=SENSOR_TYPE_TEMPERATURE, - name="Temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_HUMIDITY: SensorEntityDescription( key=SENSOR_TYPE_HUMIDITY, - name="Humidity", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.HUMIDITY, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_RAINRATE: SensorEntityDescription( key=SENSOR_TYPE_RAINRATE, - name="Rain rate", native_unit_of_measurement=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.PRECIPITATION_INTENSITY, ), SENSOR_TYPE_RAINTOTAL: SensorEntityDescription( key=SENSOR_TYPE_RAINTOTAL, - name="Rain total", native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.TOTAL_INCREASING, ), SENSOR_TYPE_WINDDIRECTION: SensorEntityDescription( key=SENSOR_TYPE_WINDDIRECTION, - name="Wind direction", + translation_key="wind_direction", ), SENSOR_TYPE_WINDAVERAGE: SensorEntityDescription( key=SENSOR_TYPE_WINDAVERAGE, - name="Wind average", + translation_key="wind_average", native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND, device_class=SensorDeviceClass.WIND_SPEED, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_WINDGUST: SensorEntityDescription( key=SENSOR_TYPE_WINDGUST, - name="Wind gust", + translation_key="wind_gust", native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND, device_class=SensorDeviceClass.WIND_SPEED, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_UV: SensorEntityDescription( key=SENSOR_TYPE_UV, - name="UV", + translation_key="uv", native_unit_of_measurement=UV_INDEX, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_WATT: SensorEntityDescription( key=SENSOR_TYPE_WATT, - name="Power", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_LUMINANCE: SensorEntityDescription( key=SENSOR_TYPE_LUMINANCE, - name="Luminance", native_unit_of_measurement=LIGHT_LUX, device_class=SensorDeviceClass.ILLUMINANCE, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_DEW_POINT: SensorEntityDescription( key=SENSOR_TYPE_DEW_POINT, - name="Dew Point", + translation_key="dew_point", native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), SENSOR_TYPE_BAROMETRIC_PRESSURE: SensorEntityDescription( key=SENSOR_TYPE_BAROMETRIC_PRESSURE, - name="Barometric Pressure", native_unit_of_measurement=UnitOfPressure.KPA, device_class=SensorDeviceClass.PRESSURE, state_class=SensorStateClass.MEASUREMENT, @@ -151,6 +144,8 @@ class TelldusLiveSensor(TelldusLiveEntity, SensorEntity): super().__init__(client, device_id) if desc := SENSOR_TYPES.get(self._type): self.entity_description = desc + else: + self._attr_name = None @property def device_id(self): @@ -182,14 +177,6 @@ class TelldusLiveSensor(TelldusLiveEntity, SensorEntity): """Return the value as humidity.""" return int(round(float(self._value))) - @property - def name(self): - """Return the name of the sensor.""" - quantity_name = ( - self.entity_description.name if hasattr(self, "entity_description") else "" - ) - return "{} {}".format(super().name, quantity_name or "").strip() - @property def native_value(self): """Return the state of the sensor.""" diff --git a/homeassistant/components/tellduslive/strings.json b/homeassistant/components/tellduslive/strings.json index 27e74d6d938..1dbea7a0e6c 100644 --- a/homeassistant/components/tellduslive/strings.json +++ b/homeassistant/components/tellduslive/strings.json @@ -21,5 +21,24 @@ "title": "Pick endpoint." } } + }, + "entity": { + "sensor": { + "wind_direction": { + "name": "Wind direction" + }, + "wind_average": { + "name": "Wind average" + }, + "wind_gust": { + "name": "Wind gust" + }, + "uv": { + "name": "UV" + }, + "dew_point": { + "name": "Dew point" + } + } } } diff --git a/homeassistant/components/tellduslive/switch.py b/homeassistant/components/tellduslive/switch.py index fbecda2e775..5ae5a904689 100644 --- a/homeassistant/components/tellduslive/switch.py +++ b/homeassistant/components/tellduslive/switch.py @@ -34,6 +34,8 @@ async def async_setup_entry( class TelldusLiveSwitch(TelldusLiveEntity, SwitchEntity): """Representation of a Tellstick switch.""" + _attr_name = None + @property def is_on(self): """Return true if switch is on."""