mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Async generic thermostat tests (#18111)
This commit is contained in:
parent
283407fe6c
commit
dd938d7460
@ -11,9 +11,25 @@ from homeassistant.components.climate import (
|
|||||||
SERVICE_SET_FAN_MODE, SERVICE_SET_OPERATION_MODE, SERVICE_SET_SWING_MODE)
|
SERVICE_SET_FAN_MODE, SERVICE_SET_OPERATION_MODE, SERVICE_SET_SWING_MODE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE)
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE)
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_away_mode(hass, away_mode, entity_id=None):
|
||||||
|
"""Turn all or specified climate devices away mode on."""
|
||||||
|
data = {
|
||||||
|
ATTR_AWAY_MODE: away_mode
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity_id:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_AWAY_MODE, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_away_mode(hass, away_mode, entity_id=None):
|
def set_away_mode(hass, away_mode, entity_id=None):
|
||||||
"""Turn all or specified climate devices away mode on."""
|
"""Turn all or specified climate devices away mode on."""
|
||||||
@ -27,6 +43,21 @@ def set_away_mode(hass, away_mode, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_AWAY_MODE, data)
|
hass.services.call(DOMAIN, SERVICE_SET_AWAY_MODE, data)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_hold_mode(hass, hold_mode, entity_id=None):
|
||||||
|
"""Set new hold mode."""
|
||||||
|
data = {
|
||||||
|
ATTR_HOLD_MODE: hold_mode
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity_id:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_HOLD_MODE, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_hold_mode(hass, hold_mode, entity_id=None):
|
def set_hold_mode(hass, hold_mode, entity_id=None):
|
||||||
"""Set new hold mode."""
|
"""Set new hold mode."""
|
||||||
@ -40,6 +71,21 @@ def set_hold_mode(hass, hold_mode, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_HOLD_MODE, data)
|
hass.services.call(DOMAIN, SERVICE_SET_HOLD_MODE, data)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_aux_heat(hass, aux_heat, entity_id=None):
|
||||||
|
"""Turn all or specified climate devices auxiliary heater on."""
|
||||||
|
data = {
|
||||||
|
ATTR_AUX_HEAT: aux_heat
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity_id:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_AUX_HEAT, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_aux_heat(hass, aux_heat, entity_id=None):
|
def set_aux_heat(hass, aux_heat, entity_id=None):
|
||||||
"""Turn all or specified climate devices auxiliary heater on."""
|
"""Turn all or specified climate devices auxiliary heater on."""
|
||||||
@ -53,6 +99,26 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_temperature(hass, temperature=None, entity_id=None,
|
||||||
|
target_temp_high=None, target_temp_low=None,
|
||||||
|
operation_mode=None):
|
||||||
|
"""Set new target temperature."""
|
||||||
|
kwargs = {
|
||||||
|
key: value for key, value in [
|
||||||
|
(ATTR_TEMPERATURE, temperature),
|
||||||
|
(ATTR_TARGET_TEMP_HIGH, target_temp_high),
|
||||||
|
(ATTR_TARGET_TEMP_LOW, target_temp_low),
|
||||||
|
(ATTR_ENTITY_ID, entity_id),
|
||||||
|
(ATTR_OPERATION_MODE, operation_mode)
|
||||||
|
] if value is not None
|
||||||
|
}
|
||||||
|
_LOGGER.debug("set_temperature start data=%s", kwargs)
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_TEMPERATURE, kwargs))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
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,
|
||||||
@ -71,6 +137,19 @@ def set_temperature(hass, temperature=None, entity_id=None,
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_TEMPERATURE, kwargs)
|
hass.services.call(DOMAIN, SERVICE_SET_TEMPERATURE, kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_humidity(hass, humidity, entity_id=None):
|
||||||
|
"""Set new target humidity."""
|
||||||
|
data = {ATTR_HUMIDITY: humidity}
|
||||||
|
|
||||||
|
if entity_id is not None:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_HUMIDITY, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_humidity(hass, humidity, entity_id=None):
|
def set_humidity(hass, humidity, entity_id=None):
|
||||||
"""Set new target humidity."""
|
"""Set new target humidity."""
|
||||||
@ -82,6 +161,19 @@ def set_humidity(hass, humidity, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_HUMIDITY, data)
|
hass.services.call(DOMAIN, SERVICE_SET_HUMIDITY, data)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_fan_mode(hass, fan, entity_id=None):
|
||||||
|
"""Set all or specified climate devices fan mode on."""
|
||||||
|
data = {ATTR_FAN_MODE: fan}
|
||||||
|
|
||||||
|
if entity_id:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_FAN_MODE, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_fan_mode(hass, fan, entity_id=None):
|
def set_fan_mode(hass, fan, entity_id=None):
|
||||||
"""Set all or specified climate devices fan mode on."""
|
"""Set all or specified climate devices fan mode on."""
|
||||||
@ -93,6 +185,19 @@ def set_fan_mode(hass, fan, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_FAN_MODE, data)
|
hass.services.call(DOMAIN, SERVICE_SET_FAN_MODE, data)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_operation_mode(hass, operation_mode, entity_id=None):
|
||||||
|
"""Set new target operation mode."""
|
||||||
|
data = {ATTR_OPERATION_MODE: operation_mode}
|
||||||
|
|
||||||
|
if entity_id is not None:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_OPERATION_MODE, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_operation_mode(hass, operation_mode, entity_id=None):
|
def set_operation_mode(hass, operation_mode, entity_id=None):
|
||||||
"""Set new target operation mode."""
|
"""Set new target operation mode."""
|
||||||
@ -104,6 +209,19 @@ def set_operation_mode(hass, operation_mode, entity_id=None):
|
|||||||
hass.services.call(DOMAIN, SERVICE_SET_OPERATION_MODE, data)
|
hass.services.call(DOMAIN, SERVICE_SET_OPERATION_MODE, data)
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
@bind_hass
|
||||||
|
def async_set_swing_mode(hass, swing_mode, entity_id=None):
|
||||||
|
"""Set new target swing mode."""
|
||||||
|
data = {ATTR_SWING_MODE: swing_mode}
|
||||||
|
|
||||||
|
if entity_id is not None:
|
||||||
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
|
hass.async_create_task(
|
||||||
|
hass.services.async_call(DOMAIN, SERVICE_SET_SWING_MODE, data))
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def set_swing_mode(hass, swing_mode, entity_id=None):
|
def set_swing_mode(hass, swing_mode, entity_id=None):
|
||||||
"""Set new target swing mode."""
|
"""Set new target swing mode."""
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user