Fix min/max temp and humidity for homekit_controller climate (#23421)

* Fix min/max temp and humidity for homekit_controller climate.

* Fix typo
This commit is contained in:
Jc2k 2019-04-30 23:08:31 +01:00 committed by Martin Hjelmare
parent b0843f4a38
commit 1c4367e5a9
4 changed files with 59 additions and 1 deletions

View file

@ -4,7 +4,8 @@ import logging
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import (
STATE_COOL, STATE_HEAT, STATE_IDLE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_HUMIDITY)
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_HUMIDITY,
SUPPORT_TARGET_HUMIDITY_HIGH, SUPPORT_TARGET_HUMIDITY_LOW)
from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, TEMP_CELSIUS
from . import KNOWN_DEVICES, HomeKitEntity
@ -43,6 +44,10 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
self._target_temp = None
self._current_humidity = None
self._target_humidity = None
self._min_target_temp = None
self._max_target_temp = None
self._min_target_humidity = None
self._max_target_humidity = None
super().__init__(*args)
def get_characteristic_types(self):
@ -86,9 +91,23 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
def _setup_temperature_target(self, characteristic):
self._features |= SUPPORT_TARGET_TEMPERATURE
if 'minValue' in characteristic:
self._min_target_temp = characteristic['minValue']
if 'maxValue' in characteristic:
self._max_target_temp = characteristic['maxValue']
def _setup_relative_humidity_target(self, characteristic):
self._features |= SUPPORT_TARGET_HUMIDITY
if 'minValue' in characteristic:
self._min_target_humidity = characteristic['minValue']
self._features |= SUPPORT_TARGET_HUMIDITY_LOW
if 'maxValue' in characteristic:
self._max_target_humidity = characteristic['maxValue']
self._features |= SUPPORT_TARGET_HUMIDITY_HIGH
def _update_heating_cooling_current(self, value):
self._state = MODE_HOMEKIT_TO_HASS.get(value)
@ -152,6 +171,20 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
"""Return the temperature we try to reach."""
return self._target_temp
@property
def min_temp(self):
"""Return the minimum target temp."""
if self._max_target_temp:
return self._min_target_temp
return super().min_temp
@property
def max_temp(self):
"""Return the maximum target temp."""
if self._max_target_temp:
return self._max_target_temp
return super().max_temp
@property
def current_humidity(self):
"""Return the current humidity."""
@ -162,6 +195,16 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
"""Return the humidity we try to reach."""
return self._target_humidity
@property
def min_humidity(self):
"""Return the minimum humidity."""
return self._min_target_humidity
@property
def max_humidity(self):
"""Return the maximum humidity."""
return self._max_target_humidity
@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""