From 7b1cdc6ed63b277e04bbc8277ccf60e5f301e45d Mon Sep 17 00:00:00 2001 From: Filip Pytloun Date: Fri, 5 Jun 2020 13:47:32 +0200 Subject: [PATCH] Fix target humidity --- src/components/daikin/const.py | 6 ++++-- src/components/daikin/sensor.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/daikin/const.py b/src/components/daikin/const.py index 141cad7..32e1c30 100644 --- a/src/components/daikin/const.py +++ b/src/components/daikin/const.py @@ -20,6 +20,8 @@ ATTR_OUTSIDE_TEMPERATURE = "outside_temperature" ATTR_TOTAL_POWER = "total_power" ATTR_COOL_ENERGY = "cool_energy" ATTR_HEAT_ENERGY = "heat_energy" +ATTR_HUMIDITY = "hhum" +ATTR_TARGET_HUMIDITY = "shum" ATTR_STATE_ON = "on" ATTR_STATE_OFF = "off" @@ -42,14 +44,14 @@ SENSOR_TYPES = { CONF_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE, CONF_UNIT_OF_MEASUREMENT: TEMP_CELSIUS, }, - "hhum": { + ATTR_HUMIDITY: { CONF_NAME: "Humidity", CONF_ICON: "mdi:percent", CONF_TYPE: SENSOR_TYPE_HUMIDITY, CONF_DEVICE_CLASS: DEVICE_CLASS_HUMIDITY, CONF_UNIT_OF_MEASUREMENT: UNIT_PERCENTAGE, }, - "shum": { + ATTR_TARGET_HUMIDITY: { CONF_NAME: "Target Humidity", CONF_ICON: "mdi:percent", CONF_TYPE: SENSOR_TYPE_HUMIDITY, diff --git a/src/components/daikin/sensor.py b/src/components/daikin/sensor.py index ff34563..053b996 100644 --- a/src/components/daikin/sensor.py +++ b/src/components/daikin/sensor.py @@ -16,6 +16,8 @@ from .const import ( ATTR_HEAT_ENERGY, ATTR_INSIDE_TEMPERATURE, ATTR_OUTSIDE_TEMPERATURE, + ATTR_HUMIDITY, + ATTR_TARGET_HUMIDITY, ATTR_TOTAL_POWER, SENSOR_TYPE_ENERGY, SENSOR_TYPE_POWER, @@ -45,9 +47,9 @@ async def async_setup_entry(hass, entry, async_add_entities): sensors.append(ATTR_TOTAL_POWER) sensors.append(ATTR_COOL_ENERGY) sensors.append(ATTR_HEAT_ENERGY) - if daikin_api.device.values.get("hhum").replace("-", ""): - sensors.append("hhum") - sensors.append("shum") + if daikin_api.device.values.get(ATTR_HUMIDITY).replace("-", ""): + sensors.append(ATTR_HUMIDITY) + sensors.append(ATTR_TARGET_HUMIDITY) async_add_entities([DaikinSensor.factory(daikin_api, sensor) for sensor in sensors]) @@ -123,10 +125,10 @@ class DaikinClimateSensor(DaikinSensor): if self._device_attribute == ATTR_OUTSIDE_TEMPERATURE: return self._api.device.outside_temperature - if self._device_attribute == "hhum": - return int(self._api.device.values.get("hhum").replace("-", "0")) - if self._device_attribute == "bhum": - return int(self._api.device.values.get("bhum").replace("-", "0")) + if self._device_attribute == ATTR_HUMIDITY: + return int(self._api.device.values.get(ATTR_HUMIDITY).replace("-", "0")) + if self._device_attribute == ATTR_TARGET_HUMIDITY: + return int(self._api.device.values.get(ATTR_TARGET_HUMIDITY).replace("-", "0")) return None