Fix Daikin power sensors (#35428)
* Fix factory class not defined for SENSOR_TYPE_ENERGY * Round power sensors' state
This commit is contained in:
parent
9e3a8899c8
commit
08087b0f99
1 changed files with 5 additions and 3 deletions
|
@ -17,6 +17,7 @@ from .const import (
|
|||
ATTR_INSIDE_TEMPERATURE,
|
||||
ATTR_OUTSIDE_TEMPERATURE,
|
||||
ATTR_TOTAL_POWER,
|
||||
SENSOR_TYPE_ENERGY,
|
||||
SENSOR_TYPE_POWER,
|
||||
SENSOR_TYPE_TEMPERATURE,
|
||||
SENSOR_TYPES,
|
||||
|
@ -55,6 +56,7 @@ class DaikinSensor(Entity):
|
|||
cls = {
|
||||
SENSOR_TYPE_TEMPERATURE: DaikinClimateSensor,
|
||||
SENSOR_TYPE_POWER: DaikinPowerSensor,
|
||||
SENSOR_TYPE_ENERGY: DaikinPowerSensor,
|
||||
}[SENSOR_TYPES[monitored_state][CONF_TYPE]]
|
||||
return cls(api, monitored_state)
|
||||
|
||||
|
@ -125,9 +127,9 @@ class DaikinPowerSensor(DaikinSensor):
|
|||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
if self._device_attribute == ATTR_TOTAL_POWER:
|
||||
return self._api.device.current_total_power_consumption
|
||||
return round(self._api.device.current_total_power_consumption, 3)
|
||||
if self._device_attribute == ATTR_COOL_ENERGY:
|
||||
return self._api.device.last_hour_cool_power_consumption
|
||||
return round(self._api.device.last_hour_cool_power_consumption, 3)
|
||||
if self._device_attribute == ATTR_HEAT_ENERGY:
|
||||
return self._api.device.last_hour_heat_power_consumption
|
||||
return round(self._api.device.last_hour_heat_power_consumption, 3)
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue