diff --git a/homeassistant/components/daikin/climate.py b/homeassistant/components/daikin/climate.py index 02107205e70..bd4763d3254 100644 --- a/homeassistant/components/daikin/climate.py +++ b/homeassistant/components/daikin/climate.py @@ -116,6 +116,8 @@ def format_target_temperature(target_temperature): class DaikinClimate(ClimateEntity): """Representation of a Daikin HVAC.""" + _attr_name = None + _attr_has_entity_name = True _attr_temperature_unit = TEMP_CELSIUS def __init__(self, api: DaikinApi) -> None: @@ -173,11 +175,6 @@ class DaikinClimate(ClimateEntity): if values: await self._api.device.set(values) - @property - def name(self): - """Return the name of the thermostat, if any.""" - return self._api.name - @property def unique_id(self): """Return a unique ID.""" diff --git a/homeassistant/components/daikin/const.py b/homeassistant/components/daikin/const.py index fbd838b9e47..a978e96178d 100644 --- a/homeassistant/components/daikin/const.py +++ b/homeassistant/components/daikin/const.py @@ -4,12 +4,17 @@ DOMAIN = "daikin" ATTR_TARGET_TEMPERATURE = "target_temperature" ATTR_INSIDE_TEMPERATURE = "inside_temperature" ATTR_OUTSIDE_TEMPERATURE = "outside_temperature" -ATTR_TOTAL_POWER = "total_power" + +ATTR_TARGET_HUMIDITY = "target_humidity" +ATTR_HUMIDITY = "humidity" + +ATTR_COMPRESSOR_FREQUENCY = "compressor_frequency" + +ATTR_ENERGY_TODAY = "energy_today" ATTR_COOL_ENERGY = "cool_energy" ATTR_HEAT_ENERGY = "heat_energy" -ATTR_HUMIDITY = "humidity" -ATTR_TARGET_HUMIDITY = "target_humidity" -ATTR_COMPRESSOR_FREQUENCY = "compressor_frequency" + +ATTR_TOTAL_POWER = "total_power" ATTR_TOTAL_ENERGY_TODAY = "total_energy_today" ATTR_STATE_ON = "on" diff --git a/homeassistant/components/daikin/sensor.py b/homeassistant/components/daikin/sensor.py index 1adacd322cc..3d9deba59ab 100644 --- a/homeassistant/components/daikin/sensor.py +++ b/homeassistant/components/daikin/sensor.py @@ -29,6 +29,7 @@ from . import DOMAIN as DAIKIN_DOMAIN, DaikinApi from .const import ( ATTR_COMPRESSOR_FREQUENCY, ATTR_COOL_ENERGY, + ATTR_ENERGY_TODAY, ATTR_HEAT_ENERGY, ATTR_HUMIDITY, ATTR_INSIDE_TEMPERATURE, @@ -54,7 +55,7 @@ class DaikinSensorEntityDescription(SensorEntityDescription, DaikinRequiredKeysM SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( DaikinSensorEntityDescription( key=ATTR_INSIDE_TEMPERATURE, - name="Inside Temperature", + name="Inside temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=TEMP_CELSIUS, @@ -62,7 +63,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( ), DaikinSensorEntityDescription( key=ATTR_OUTSIDE_TEMPERATURE, - name="Outside Temperature", + name="Outside temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=TEMP_CELSIUS, @@ -78,7 +79,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( ), DaikinSensorEntityDescription( key=ATTR_TARGET_HUMIDITY, - name="Target Humidity", + name="Target humidity", device_class=SensorDeviceClass.HUMIDITY, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=PERCENTAGE, @@ -86,7 +87,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( ), DaikinSensorEntityDescription( key=ATTR_TOTAL_POWER, - name="Estimated Power Consumption", + name="Compressor estimated power consumption", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=POWER_KILO_WATT, @@ -94,35 +95,47 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( ), DaikinSensorEntityDescription( key=ATTR_COOL_ENERGY, - name="Cool Energy Consumption", + name="Cool energy consumption", icon="mdi:snowflake", device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + entity_registry_enabled_default=False, value_func=lambda device: round(device.last_hour_cool_energy_consumption, 2), ), DaikinSensorEntityDescription( key=ATTR_HEAT_ENERGY, - name="Heat Energy Consumption", + name="Heat energy consumption", icon="mdi:fire", device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + entity_registry_enabled_default=False, value_func=lambda device: round(device.last_hour_heat_energy_consumption, 2), ), + DaikinSensorEntityDescription( + key=ATTR_ENERGY_TODAY, + name="Energy consumption", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + value_func=lambda device: round(device.today_energy_consumption, 2), + ), DaikinSensorEntityDescription( key=ATTR_COMPRESSOR_FREQUENCY, - name="Compressor Frequency", + name="Compressor frequency", icon="mdi:fan", device_class=SensorDeviceClass.FREQUENCY, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=FREQUENCY_HERTZ, + entity_registry_enabled_default=False, value_func=lambda device: device.compressor_frequency, ), DaikinSensorEntityDescription( key=ATTR_TOTAL_ENERGY_TODAY, - name="Today's Total Energy Consumption", + name="Compressor energy consumption", device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + entity_registry_enabled_default=False, value_func=lambda device: round(device.today_total_energy_consumption, 2), ), ) @@ -150,9 +163,10 @@ async def async_setup_entry( if daikin_api.device.support_outside_temperature: sensors.append(ATTR_OUTSIDE_TEMPERATURE) if daikin_api.device.support_energy_consumption: - sensors.append(ATTR_TOTAL_POWER) + sensors.append(ATTR_ENERGY_TODAY) sensors.append(ATTR_COOL_ENERGY) sensors.append(ATTR_HEAT_ENERGY) + sensors.append(ATTR_TOTAL_POWER) sensors.append(ATTR_TOTAL_ENERGY_TODAY) if daikin_api.device.support_humidity: sensors.append(ATTR_HUMIDITY) @@ -171,6 +185,7 @@ async def async_setup_entry( class DaikinSensor(SensorEntity): """Representation of a Sensor.""" + _attr_has_entity_name = True entity_description: DaikinSensorEntityDescription def __init__( @@ -179,7 +194,6 @@ class DaikinSensor(SensorEntity): """Initialize the sensor.""" self.entity_description = description self._api = api - self._attr_name = f"{api.name} {description.name}" @property def unique_id(self) -> str: diff --git a/homeassistant/components/daikin/switch.py b/homeassistant/components/daikin/switch.py index 23b4b526f9a..a7c8b6549e4 100644 --- a/homeassistant/components/daikin/switch.py +++ b/homeassistant/components/daikin/switch.py @@ -56,6 +56,9 @@ async def async_setup_entry( class DaikinZoneSwitch(SwitchEntity): """Representation of a zone.""" + _attr_icon = ZONE_ICON + _attr_has_entity_name = True + def __init__(self, daikin_api: DaikinApi, zone_id): """Initialize the zone.""" self._api = daikin_api @@ -66,15 +69,10 @@ class DaikinZoneSwitch(SwitchEntity): """Return a unique ID.""" return f"{self._api.device.mac}-zone{self._zone_id}" - @property - def icon(self): - """Icon to use in the frontend, if any.""" - return ZONE_ICON - @property def name(self) -> str: """Return the name of the sensor.""" - return f"{self._api.name} {self._api.device.zones[self._zone_id][0]}" + return self._api.device.zones[self._zone_id][0] @property def is_on(self) -> bool: @@ -102,6 +100,10 @@ class DaikinZoneSwitch(SwitchEntity): class DaikinStreamerSwitch(SwitchEntity): """Streamer state.""" + _attr_icon = STREAMER_ICON + _attr_name = "Streamer" + _attr_has_entity_name = True + def __init__(self, daikin_api: DaikinApi) -> None: """Initialize streamer switch.""" self._api = daikin_api @@ -111,16 +113,6 @@ class DaikinStreamerSwitch(SwitchEntity): """Return a unique ID.""" return f"{self._api.device.mac}-streamer" - @property - def icon(self): - """Icon to use in the frontend, if any.""" - return STREAMER_ICON - - @property - def name(self) -> str: - """Return the name of the sensor.""" - return f"{self._api.name} streamer" - @property def is_on(self) -> bool: """Return the state of the sensor."""