parent
33cd59d3c2
commit
060102832e
4 changed files with 43 additions and 35 deletions
|
@ -116,6 +116,8 @@ def format_target_temperature(target_temperature):
|
||||||
class DaikinClimate(ClimateEntity):
|
class DaikinClimate(ClimateEntity):
|
||||||
"""Representation of a Daikin HVAC."""
|
"""Representation of a Daikin HVAC."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
|
_attr_has_entity_name = True
|
||||||
_attr_temperature_unit = TEMP_CELSIUS
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
def __init__(self, api: DaikinApi) -> None:
|
def __init__(self, api: DaikinApi) -> None:
|
||||||
|
@ -173,11 +175,6 @@ class DaikinClimate(ClimateEntity):
|
||||||
if values:
|
if values:
|
||||||
await self._api.device.set(values)
|
await self._api.device.set(values)
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the thermostat, if any."""
|
|
||||||
return self._api.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
|
|
|
@ -4,12 +4,17 @@ DOMAIN = "daikin"
|
||||||
ATTR_TARGET_TEMPERATURE = "target_temperature"
|
ATTR_TARGET_TEMPERATURE = "target_temperature"
|
||||||
ATTR_INSIDE_TEMPERATURE = "inside_temperature"
|
ATTR_INSIDE_TEMPERATURE = "inside_temperature"
|
||||||
ATTR_OUTSIDE_TEMPERATURE = "outside_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_COOL_ENERGY = "cool_energy"
|
||||||
ATTR_HEAT_ENERGY = "heat_energy"
|
ATTR_HEAT_ENERGY = "heat_energy"
|
||||||
ATTR_HUMIDITY = "humidity"
|
|
||||||
ATTR_TARGET_HUMIDITY = "target_humidity"
|
ATTR_TOTAL_POWER = "total_power"
|
||||||
ATTR_COMPRESSOR_FREQUENCY = "compressor_frequency"
|
|
||||||
ATTR_TOTAL_ENERGY_TODAY = "total_energy_today"
|
ATTR_TOTAL_ENERGY_TODAY = "total_energy_today"
|
||||||
|
|
||||||
ATTR_STATE_ON = "on"
|
ATTR_STATE_ON = "on"
|
||||||
|
|
|
@ -29,6 +29,7 @@ from . import DOMAIN as DAIKIN_DOMAIN, DaikinApi
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_COMPRESSOR_FREQUENCY,
|
ATTR_COMPRESSOR_FREQUENCY,
|
||||||
ATTR_COOL_ENERGY,
|
ATTR_COOL_ENERGY,
|
||||||
|
ATTR_ENERGY_TODAY,
|
||||||
ATTR_HEAT_ENERGY,
|
ATTR_HEAT_ENERGY,
|
||||||
ATTR_HUMIDITY,
|
ATTR_HUMIDITY,
|
||||||
ATTR_INSIDE_TEMPERATURE,
|
ATTR_INSIDE_TEMPERATURE,
|
||||||
|
@ -54,7 +55,7 @@ class DaikinSensorEntityDescription(SensorEntityDescription, DaikinRequiredKeysM
|
||||||
SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_INSIDE_TEMPERATURE,
|
key=ATTR_INSIDE_TEMPERATURE,
|
||||||
name="Inside Temperature",
|
name="Inside temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
@ -62,7 +63,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_OUTSIDE_TEMPERATURE,
|
key=ATTR_OUTSIDE_TEMPERATURE,
|
||||||
name="Outside Temperature",
|
name="Outside temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
@ -78,7 +79,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_TARGET_HUMIDITY,
|
key=ATTR_TARGET_HUMIDITY,
|
||||||
name="Target Humidity",
|
name="Target humidity",
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
@ -86,7 +87,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_TOTAL_POWER,
|
key=ATTR_TOTAL_POWER,
|
||||||
name="Estimated Power Consumption",
|
name="Compressor estimated power consumption",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
@ -94,35 +95,47 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_COOL_ENERGY,
|
key=ATTR_COOL_ENERGY,
|
||||||
name="Cool Energy Consumption",
|
name="Cool energy consumption",
|
||||||
icon="mdi:snowflake",
|
icon="mdi:snowflake",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
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),
|
value_func=lambda device: round(device.last_hour_cool_energy_consumption, 2),
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_HEAT_ENERGY,
|
key=ATTR_HEAT_ENERGY,
|
||||||
name="Heat Energy Consumption",
|
name="Heat energy consumption",
|
||||||
icon="mdi:fire",
|
icon="mdi:fire",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
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),
|
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(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_COMPRESSOR_FREQUENCY,
|
key=ATTR_COMPRESSOR_FREQUENCY,
|
||||||
name="Compressor Frequency",
|
name="Compressor frequency",
|
||||||
icon="mdi:fan",
|
icon="mdi:fan",
|
||||||
device_class=SensorDeviceClass.FREQUENCY,
|
device_class=SensorDeviceClass.FREQUENCY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
value_func=lambda device: device.compressor_frequency,
|
value_func=lambda device: device.compressor_frequency,
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
key=ATTR_TOTAL_ENERGY_TODAY,
|
key=ATTR_TOTAL_ENERGY_TODAY,
|
||||||
name="Today's Total Energy Consumption",
|
name="Compressor energy consumption",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
value_func=lambda device: round(device.today_total_energy_consumption, 2),
|
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:
|
if daikin_api.device.support_outside_temperature:
|
||||||
sensors.append(ATTR_OUTSIDE_TEMPERATURE)
|
sensors.append(ATTR_OUTSIDE_TEMPERATURE)
|
||||||
if daikin_api.device.support_energy_consumption:
|
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_COOL_ENERGY)
|
||||||
sensors.append(ATTR_HEAT_ENERGY)
|
sensors.append(ATTR_HEAT_ENERGY)
|
||||||
|
sensors.append(ATTR_TOTAL_POWER)
|
||||||
sensors.append(ATTR_TOTAL_ENERGY_TODAY)
|
sensors.append(ATTR_TOTAL_ENERGY_TODAY)
|
||||||
if daikin_api.device.support_humidity:
|
if daikin_api.device.support_humidity:
|
||||||
sensors.append(ATTR_HUMIDITY)
|
sensors.append(ATTR_HUMIDITY)
|
||||||
|
@ -171,6 +185,7 @@ async def async_setup_entry(
|
||||||
class DaikinSensor(SensorEntity):
|
class DaikinSensor(SensorEntity):
|
||||||
"""Representation of a Sensor."""
|
"""Representation of a Sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
entity_description: DaikinSensorEntityDescription
|
entity_description: DaikinSensorEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -179,7 +194,6 @@ class DaikinSensor(SensorEntity):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._api = api
|
self._api = api
|
||||||
self._attr_name = f"{api.name} {description.name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
|
|
@ -56,6 +56,9 @@ async def async_setup_entry(
|
||||||
class DaikinZoneSwitch(SwitchEntity):
|
class DaikinZoneSwitch(SwitchEntity):
|
||||||
"""Representation of a zone."""
|
"""Representation of a zone."""
|
||||||
|
|
||||||
|
_attr_icon = ZONE_ICON
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, daikin_api: DaikinApi, zone_id):
|
def __init__(self, daikin_api: DaikinApi, zone_id):
|
||||||
"""Initialize the zone."""
|
"""Initialize the zone."""
|
||||||
self._api = daikin_api
|
self._api = daikin_api
|
||||||
|
@ -66,15 +69,10 @@ class DaikinZoneSwitch(SwitchEntity):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return f"{self._api.device.mac}-zone{self._zone_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
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the sensor."""
|
"""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
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
@ -102,6 +100,10 @@ class DaikinZoneSwitch(SwitchEntity):
|
||||||
class DaikinStreamerSwitch(SwitchEntity):
|
class DaikinStreamerSwitch(SwitchEntity):
|
||||||
"""Streamer state."""
|
"""Streamer state."""
|
||||||
|
|
||||||
|
_attr_icon = STREAMER_ICON
|
||||||
|
_attr_name = "Streamer"
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, daikin_api: DaikinApi) -> None:
|
def __init__(self, daikin_api: DaikinApi) -> None:
|
||||||
"""Initialize streamer switch."""
|
"""Initialize streamer switch."""
|
||||||
self._api = daikin_api
|
self._api = daikin_api
|
||||||
|
@ -111,16 +113,6 @@ class DaikinStreamerSwitch(SwitchEntity):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return f"{self._api.device.mac}-streamer"
|
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
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue