Skip to content

Commit

Permalink
Add room himidity entity if available
Browse files Browse the repository at this point in the history
  • Loading branch information
droscy authored and rospogrigio committed Oct 28, 2022
1 parent db455ac commit 8b627ce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
11 changes: 10 additions & 1 deletion custom_components/daikin_residential/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
CONF_TYPE,
CONF_UNIT_OF_MEASUREMENT,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_SIGNAL_STRENGTH,
ENERGY_KILO_WATT_HOUR,
TEMP_CELSIUS,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
)

Expand All @@ -37,7 +39,7 @@
ATTR_MAC_ADDRESS = "mac_address"
ATTR_SERIAL_NUMBER = "serial_number"
ATTR_ENERGY_CONSUMPTION = "energy_consumption"
ATTR_HUMIDITY = "humidity"
ATTR_ROOM_HUMIDITY = "room_humidity"
ATTR_TARGET_HUMIDITY = "target_humidity"
ATTR_FAN_MODE = "fan_mode"
ATTR_FAN_SPEED = "fan_speed"
Expand Down Expand Up @@ -69,6 +71,7 @@
ATTR_OPERATION_MODE: [MP_CLIMATE, DP_OPERATION_MODE, ""],
ATTR_OUTSIDE_TEMPERATURE: [MP_CLIMATE, DP_SENSORS, "/outdoorTemperature"],
ATTR_INSIDE_TEMPERATURE: [MP_CLIMATE, DP_SENSORS, "/roomTemperature"],
ATTR_ROOM_HUMIDITY: [MP_CLIMATE, DP_SENSORS, "/roomHumidity"],
ATTR_TARGET_TEMPERATURE: [
MP_CLIMATE,
DP_TEMPERATURE,
Expand Down Expand Up @@ -142,6 +145,12 @@
CONF_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
CONF_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
},
ATTR_ROOM_HUMIDITY: {
CONF_NAME: "Room Humidity",
CONF_TYPE: SENSOR_TYPE_HUMIDITY,
CONF_DEVICE_CLASS: DEVICE_CLASS_HUMIDITY,
CONF_UNIT_OF_MEASUREMENT: PERCENTAGE,
},
ATTR_COOL_ENERGY: {
CONF_NAME: "Cool Energy Consumption",
CONF_TYPE: SENSOR_TYPE_ENERGY,
Expand Down
10 changes: 8 additions & 2 deletions custom_components/daikin_residential/daikin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
PRESET_STREAMER,
ATTR_INSIDE_TEMPERATURE,
ATTR_OUTSIDE_TEMPERATURE,
ATTR_ROOM_HUMIDITY,
ATTR_WIFI_STRENGTH,
ATTR_WIFI_SSID,
ATTR_LOCAL_SSID,
Expand Down Expand Up @@ -276,9 +277,14 @@ async def async_set_swing_mode(self, mode):
await self.setValue(ATTR_VSWING_MODE, new_vMode)

@property
def support_humidity(self):
def support_room_humidity(self):
"""Return True if the device has humidity sensor."""
return False
return self.getData(ATTR_ROOM_HUMIDITY) is not None

@property
def room_humidity(self):
"""Return current room humidity."""
return self.getValue(ATTR_ROOM_HUMIDITY) if self.support_room_humidity else None

@property
def support_inside_temperature(self):
Expand Down
7 changes: 7 additions & 0 deletions custom_components/daikin_residential/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ATTR_HEAT_ENERGY,
ATTR_INSIDE_TEMPERATURE,
ATTR_OUTSIDE_TEMPERATURE,
ATTR_ROOM_HUMIDITY,
ATTR_WIFI_STRENGTH,
ATTR_WIFI_SSID,
ATTR_LOCAL_SSID,
Expand Down Expand Up @@ -62,6 +63,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
_LOGGER.debug("device %s supports outside temperature", device.name)
sensor = DaikinSensor.factory(device, ATTR_OUTSIDE_TEMPERATURE)
sensors.append(sensor)
if device.support_room_humidity:
_LOGGER.debug("device %s supports room humidity", device.name)
sensor = DaikinSensor.factory(device, ATTR_ROOM_HUMIDITY)
sensors.append(sensor)
if device.support_energy_consumption:
_LOGGER.debug("device %s supports energy consumption", device.name)
for period in SENSOR_PERIODS:
Expand Down Expand Up @@ -177,6 +182,8 @@ def state(self):
return self._device.inside_temperature
if self._device_attribute == ATTR_OUTSIDE_TEMPERATURE:
return self._device.outside_temperature
if self._device_attribute == ATTR_ROOM_HUMIDITY:
return self._device.room_humidity
return None

@property
Expand Down

0 comments on commit 8b627ce

Please sign in to comment.