* Moved econet to water_heater * Wink and Econet are now in water heater! * Removed away mode from econet and added demo water heater * Added demo tests * Updated coveragerc * Fix lint issues. * updated requirements all * Requirements all actually updated. * Reset wink and econet and fixed service. * Reset wink and econet to the correct dev state * Reset requirements_all and .coveragerc and removed the new econet and wink water_heater files * Removed @bind_hass service methods * Actually reset the .coverage file * Fixed the tests * Addressed @MartinHjelmare's comments * Removed unused import * Switched to async_add_executor_job * Fixed lint * Removed is_on * Added celsius demo water heater and tests. * Removed metric import
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Collection of helper methods.
|
|
|
|
All containing methods are legacy helpers that should not be used by new
|
|
components. Instead call the service directly.
|
|
"""
|
|
from homeassistant.components.water_heater import (
|
|
_LOGGER, ATTR_AWAY_MODE,
|
|
ATTR_OPERATION_MODE, DOMAIN, SERVICE_SET_AWAY_MODE,
|
|
SERVICE_SET_TEMPERATURE, SERVICE_SET_OPERATION_MODE)
|
|
from homeassistant.const import (
|
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE)
|
|
from homeassistant.loader import bind_hass
|
|
|
|
|
|
@bind_hass
|
|
def set_away_mode(hass, away_mode, entity_id=None):
|
|
"""Turn all or specified water_heater devices away mode on."""
|
|
data = {
|
|
ATTR_AWAY_MODE: away_mode
|
|
}
|
|
|
|
if entity_id:
|
|
data[ATTR_ENTITY_ID] = entity_id
|
|
|
|
hass.services.call(DOMAIN, SERVICE_SET_AWAY_MODE, data)
|
|
|
|
|
|
@bind_hass
|
|
def set_temperature(hass, temperature=None, entity_id=None,
|
|
operation_mode=None):
|
|
"""Set new target temperature."""
|
|
kwargs = {
|
|
key: value for key, value in [
|
|
(ATTR_TEMPERATURE, temperature),
|
|
(ATTR_ENTITY_ID, entity_id),
|
|
(ATTR_OPERATION_MODE, operation_mode)
|
|
] if value is not None
|
|
}
|
|
_LOGGER.debug("set_temperature start data=%s", kwargs)
|
|
hass.services.call(DOMAIN, SERVICE_SET_TEMPERATURE, kwargs)
|
|
|
|
|
|
@bind_hass
|
|
def 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.services.call(DOMAIN, SERVICE_SET_OPERATION_MODE, data)
|