Climate component: add supported_features (#10658)
* Implement supported_features for the climate component * Test supported features * Convert generic thermostat to supported features * Max / min temperature are not features * Fix lint * Min / max humidity are not features * Linting * Remove current temperature / humidity * Move c-hacker-style constants to boring integers. Booo! * Refactor all the climate platforms to use the new supported_features * Force all climate platforms to implement supported_features * Fix mistakes * Adapt hive platform * Move flags into a constant * Calm the hound
This commit is contained in:
parent
59fa4f18e4
commit
373508693a
28 changed files with 370 additions and 34 deletions
|
@ -15,7 +15,9 @@ import homeassistant.components.mqtt as mqtt
|
|||
from homeassistant.components.climate import (
|
||||
STATE_HEAT, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, ClimateDevice,
|
||||
PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA, STATE_AUTO,
|
||||
ATTR_OPERATION_MODE)
|
||||
ATTR_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_SWING_MODE, SUPPORT_FAN_MODE, SUPPORT_AWAY_MODE, SUPPORT_HOLD_MODE,
|
||||
SUPPORT_AUX_HEAT)
|
||||
from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, ATTR_TEMPERATURE, CONF_NAME)
|
||||
from homeassistant.components.mqtt import (CONF_QOS, CONF_RETAIN,
|
||||
|
@ -483,3 +485,38 @@ class MqttClimate(ClimateDevice):
|
|||
if self._topic[CONF_AUX_STATE_TOPIC] is None:
|
||||
self._aux = False
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
support = 0
|
||||
|
||||
if (self._topic[CONF_TEMPERATURE_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_TEMPERATURE_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
if (self._topic[CONF_MODE_COMMAND_TOPIC] is not None) or \
|
||||
(self._topic[CONF_MODE_STATE_TOPIC] is not None):
|
||||
support |= SUPPORT_OPERATION_MODE
|
||||
|
||||
if (self._topic[CONF_FAN_MODE_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_FAN_MODE_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_FAN_MODE
|
||||
|
||||
if (self._topic[CONF_SWING_MODE_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_SWING_MODE_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_SWING_MODE
|
||||
|
||||
if (self._topic[CONF_AWAY_MODE_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_AWAY_MODE_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_AWAY_MODE
|
||||
|
||||
if (self._topic[CONF_HOLD_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_HOLD_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_HOLD_MODE
|
||||
|
||||
if (self._topic[CONF_AUX_STATE_TOPIC] is not None) or \
|
||||
(self._topic[CONF_AUX_COMMAND_TOPIC] is not None):
|
||||
support |= SUPPORT_AUX_HEAT
|
||||
|
||||
return support
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue