mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add possibility to set temperature to a given operation_mode (#3646)
* Add possibility to set temperature to a given operation_mode * Correctly break * Review changes
This commit is contained in:
parent
e4e13b59cf
commit
b2354f45be
@ -79,6 +79,7 @@ SET_TEMPERATURE_SCHEMA = vol.Schema({
|
|||||||
vol.Inclusive(ATTR_TARGET_TEMP_HIGH, 'temperature'): vol.Coerce(float),
|
vol.Inclusive(ATTR_TARGET_TEMP_HIGH, 'temperature'): vol.Coerce(float),
|
||||||
vol.Inclusive(ATTR_TARGET_TEMP_LOW, 'temperature'): vol.Coerce(float),
|
vol.Inclusive(ATTR_TARGET_TEMP_LOW, 'temperature'): vol.Coerce(float),
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Optional(ATTR_OPERATION_MODE): cv.string,
|
||||||
})
|
})
|
||||||
SET_FAN_MODE_SCHEMA = vol.Schema({
|
SET_FAN_MODE_SCHEMA = vol.Schema({
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
@ -122,8 +123,10 @@ def set_aux_heat(hass, aux_heat, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_AUX_HEAT, data)
|
hass.services.call(DOMAIN, SERVICE_SET_AUX_HEAT, data)
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
def set_temperature(hass, temperature=None, entity_id=None,
|
def set_temperature(hass, temperature=None, entity_id=None,
|
||||||
target_temp_high=None, target_temp_low=None):
|
target_temp_high=None, target_temp_low=None,
|
||||||
|
operation_mode=None):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
kwargs = {
|
kwargs = {
|
||||||
key: value for key, value in [
|
key: value for key, value in [
|
||||||
@ -131,6 +134,7 @@ def set_temperature(hass, temperature=None, entity_id=None,
|
|||||||
(ATTR_TARGET_TEMP_HIGH, target_temp_high),
|
(ATTR_TARGET_TEMP_HIGH, target_temp_high),
|
||||||
(ATTR_TARGET_TEMP_LOW, target_temp_low),
|
(ATTR_TARGET_TEMP_LOW, target_temp_low),
|
||||||
(ATTR_ENTITY_ID, entity_id),
|
(ATTR_ENTITY_ID, entity_id),
|
||||||
|
(ATTR_OPERATION_MODE, operation_mode)
|
||||||
] if value is not None
|
] if value is not None
|
||||||
}
|
}
|
||||||
_LOGGER.debug("set_temperature start data=%s", kwargs)
|
_LOGGER.debug("set_temperature start data=%s", kwargs)
|
||||||
|
@ -34,6 +34,18 @@ set_temperature:
|
|||||||
description: New target temperature for hvac
|
description: New target temperature for hvac
|
||||||
example: 25
|
example: 25
|
||||||
|
|
||||||
|
target_temp_high:
|
||||||
|
description: New target high tempereature for hvac
|
||||||
|
example: 26
|
||||||
|
|
||||||
|
target_temp_low:
|
||||||
|
description: New target low temperature for hvac
|
||||||
|
example: 20
|
||||||
|
|
||||||
|
operation_mode:
|
||||||
|
description: Operation mode to set temperature to. This defaults to current_operation mode if not set, or set incorrectly.
|
||||||
|
example: 'Heat'
|
||||||
|
|
||||||
set_humidity:
|
set_humidity:
|
||||||
description: Set target humidity of climate device
|
description: Set target humidity of climate device
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ https://home-assistant.io/components/climate.zwave/
|
|||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.components.climate import DOMAIN
|
from homeassistant.components.climate import DOMAIN
|
||||||
from homeassistant.components.climate import ClimateDevice
|
from homeassistant.components.climate import (
|
||||||
|
ClimateDevice, ATTR_OPERATION_MODE)
|
||||||
from homeassistant.components.zwave import ZWaveDeviceEntity
|
from homeassistant.components.zwave import ZWaveDeviceEntity
|
||||||
from homeassistant.components import zwave
|
from homeassistant.components import zwave
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -243,10 +244,20 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
|
|||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
operation_mode = kwargs.get(ATTR_OPERATION_MODE)
|
||||||
|
_LOGGER.debug("set_temperature operation_mode=%s", operation_mode)
|
||||||
|
|
||||||
for value in (self._node.get_values(
|
for value in (self._node.get_values(
|
||||||
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_SETPOINT)
|
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_SETPOINT)
|
||||||
.values()):
|
.values()):
|
||||||
|
if operation_mode is not None:
|
||||||
|
setpoint_mode = SET_TEMP_TO_INDEX.get(operation_mode)
|
||||||
|
if value.index != setpoint_mode:
|
||||||
|
continue
|
||||||
|
_LOGGER.debug("setpoint_mode=%s", setpoint_mode)
|
||||||
|
value.data = temperature
|
||||||
|
break
|
||||||
|
|
||||||
if self.current_operation is not None:
|
if self.current_operation is not None:
|
||||||
if self._hrt4_zw and self.current_operation == 'Off':
|
if self._hrt4_zw and self.current_operation == 'Off':
|
||||||
# HRT4-ZW can change setpoint when off.
|
# HRT4-ZW can change setpoint when off.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user