Ecobee service fix and new 'resume program' service (#4510)
* ecobee_set_fan_min_on_time: fix issue using 'entity_id' field and add service field help text * climate.ecobee: add 'resume_program' service * Add default value for resume_all and correct entity_id field name reference
This commit is contained in:
parent
c77b4a4806
commit
7b6503c017
3 changed files with 66 additions and 5 deletions
|
@ -22,16 +22,25 @@ _CONFIGURING = {}
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_FAN_MIN_ON_TIME = 'fan_min_on_time'
|
ATTR_FAN_MIN_ON_TIME = 'fan_min_on_time'
|
||||||
|
ATTR_RESUME_ALL = 'resume_all'
|
||||||
|
|
||||||
|
DEFAULT_RESUME_ALL = False
|
||||||
|
|
||||||
DEPENDENCIES = ['ecobee']
|
DEPENDENCIES = ['ecobee']
|
||||||
|
|
||||||
SERVICE_SET_FAN_MIN_ON_TIME = 'ecobee_set_fan_min_on_time'
|
SERVICE_SET_FAN_MIN_ON_TIME = 'ecobee_set_fan_min_on_time'
|
||||||
|
SERVICE_RESUME_PROGRAM = 'ecobee_resume_program'
|
||||||
|
|
||||||
SET_FAN_MIN_ON_TIME_SCHEMA = vol.Schema({
|
SET_FAN_MIN_ON_TIME_SCHEMA = vol.Schema({
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
vol.Required(ATTR_FAN_MIN_ON_TIME): vol.Coerce(int),
|
vol.Required(ATTR_FAN_MIN_ON_TIME): vol.Coerce(int),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
RESUME_PROGRAM_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Optional(ATTR_RESUME_ALL, default=DEFAULT_RESUME_ALL): cv.boolean,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Ecobee Thermostat Platform."""
|
"""Setup the Ecobee Thermostat Platform."""
|
||||||
|
@ -48,21 +57,36 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
||||||
def fan_min_on_time_set_service(service):
|
def fan_min_on_time_set_service(service):
|
||||||
"""Set the minimum fan on time on the target thermostats."""
|
"""Set the minimum fan on time on the target thermostats."""
|
||||||
entity_id = service.data.get('entity_id')
|
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||||
|
fan_min_on_time = service.data[ATTR_FAN_MIN_ON_TIME]
|
||||||
|
|
||||||
if entity_id:
|
if entity_id:
|
||||||
target_thermostats = [device for device in devices
|
target_thermostats = [device for device in devices
|
||||||
if device.entity_id == entity_id]
|
if device.entity_id in entity_id]
|
||||||
else:
|
else:
|
||||||
target_thermostats = devices
|
target_thermostats = devices
|
||||||
|
|
||||||
fan_min_on_time = service.data[ATTR_FAN_MIN_ON_TIME]
|
|
||||||
|
|
||||||
for thermostat in target_thermostats:
|
for thermostat in target_thermostats:
|
||||||
thermostat.set_fan_min_on_time(str(fan_min_on_time))
|
thermostat.set_fan_min_on_time(str(fan_min_on_time))
|
||||||
|
|
||||||
thermostat.update_ha_state(True)
|
thermostat.update_ha_state(True)
|
||||||
|
|
||||||
|
def resume_program_set_service(service):
|
||||||
|
"""Resume the program on the target thermostats."""
|
||||||
|
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||||
|
resume_all = service.data.get(ATTR_RESUME_ALL)
|
||||||
|
|
||||||
|
if entity_id:
|
||||||
|
target_thermostats = [device for device in devices
|
||||||
|
if device.entity_id in entity_id]
|
||||||
|
else:
|
||||||
|
target_thermostats = devices
|
||||||
|
|
||||||
|
for thermostat in target_thermostats:
|
||||||
|
thermostat.resume_program(resume_all)
|
||||||
|
|
||||||
|
thermostat.update_ha_state(True)
|
||||||
|
|
||||||
descriptions = load_yaml_config_file(
|
descriptions = load_yaml_config_file(
|
||||||
path.join(path.dirname(__file__), 'services.yaml'))
|
path.join(path.dirname(__file__), 'services.yaml'))
|
||||||
|
|
||||||
|
@ -71,6 +95,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
descriptions.get(SERVICE_SET_FAN_MIN_ON_TIME),
|
descriptions.get(SERVICE_SET_FAN_MIN_ON_TIME),
|
||||||
schema=SET_FAN_MIN_ON_TIME_SCHEMA)
|
schema=SET_FAN_MIN_ON_TIME_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(
|
||||||
|
DOMAIN, SERVICE_RESUME_PROGRAM, resume_program_set_service,
|
||||||
|
descriptions.get(SERVICE_RESUME_PROGRAM),
|
||||||
|
schema=RESUME_PROGRAM_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
class Thermostat(ClimateDevice):
|
class Thermostat(ClimateDevice):
|
||||||
"""A thermostat class for Ecobee."""
|
"""A thermostat class for Ecobee."""
|
||||||
|
@ -249,6 +278,12 @@ class Thermostat(ClimateDevice):
|
||||||
fan_min_on_time)
|
fan_min_on_time)
|
||||||
self.update_without_throttle = True
|
self.update_without_throttle = True
|
||||||
|
|
||||||
|
def resume_program(self, resume_all):
|
||||||
|
"""Resume the thermostat schedule program."""
|
||||||
|
self.data.ecobee.resume_program(self.thermostat_index,
|
||||||
|
str(resume_all).lower())
|
||||||
|
self.update_without_throttle = True
|
||||||
|
|
||||||
# Home and Sleep mode aren't used in UI yet:
|
# Home and Sleep mode aren't used in UI yet:
|
||||||
|
|
||||||
# def turn_home_mode_on(self):
|
# def turn_home_mode_on(self):
|
||||||
|
|
|
@ -94,3 +94,27 @@ set_swing_mode:
|
||||||
swing_mode:
|
swing_mode:
|
||||||
description: New value of swing mode
|
description: New value of swing mode
|
||||||
example: 1
|
example: 1
|
||||||
|
|
||||||
|
ecobee_set_fan_min_on_time:
|
||||||
|
description: Set the minimum fan on time
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of entities to change
|
||||||
|
example: 'climate.kitchen'
|
||||||
|
|
||||||
|
fan_min_on_time:
|
||||||
|
description: New value of fan min on time
|
||||||
|
example: 5
|
||||||
|
|
||||||
|
ecobee_resume_program:
|
||||||
|
description: Resume the programmed schedule
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of entities to change
|
||||||
|
example: 'climate.kitchen'
|
||||||
|
|
||||||
|
resume_all:
|
||||||
|
description: Resume all events and return to the scheduled program. This default to false which removes only the top event.
|
||||||
|
example: true
|
||||||
|
|
|
@ -22,7 +22,8 @@ from homeassistant.components.climate import (
|
||||||
SERVICE_SET_HUMIDITY, SERVICE_SET_OPERATION_MODE, SERVICE_SET_SWING_MODE,
|
SERVICE_SET_HUMIDITY, SERVICE_SET_OPERATION_MODE, SERVICE_SET_SWING_MODE,
|
||||||
SERVICE_SET_TEMPERATURE)
|
SERVICE_SET_TEMPERATURE)
|
||||||
from homeassistant.components.climate.ecobee import (
|
from homeassistant.components.climate.ecobee import (
|
||||||
ATTR_FAN_MIN_ON_TIME, SERVICE_SET_FAN_MIN_ON_TIME)
|
ATTR_FAN_MIN_ON_TIME, SERVICE_SET_FAN_MIN_ON_TIME,
|
||||||
|
ATTR_RESUME_ALL, SERVICE_RESUME_PROGRAM)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_ALARM_ARM_AWAY,
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_ALARM_ARM_AWAY,
|
||||||
SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_DISARM, SERVICE_ALARM_TRIGGER,
|
SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_DISARM, SERVICE_ALARM_TRIGGER,
|
||||||
|
@ -52,6 +53,7 @@ SERVICE_ATTRIBUTES = {
|
||||||
SERVICE_SET_AWAY_MODE: [ATTR_AWAY_MODE],
|
SERVICE_SET_AWAY_MODE: [ATTR_AWAY_MODE],
|
||||||
SERVICE_SET_FAN_MODE: [ATTR_FAN_MODE],
|
SERVICE_SET_FAN_MODE: [ATTR_FAN_MODE],
|
||||||
SERVICE_SET_FAN_MIN_ON_TIME: [ATTR_FAN_MIN_ON_TIME],
|
SERVICE_SET_FAN_MIN_ON_TIME: [ATTR_FAN_MIN_ON_TIME],
|
||||||
|
SERVICE_RESUME_PROGRAM: [ATTR_RESUME_ALL],
|
||||||
SERVICE_SET_TEMPERATURE: [ATTR_TEMPERATURE],
|
SERVICE_SET_TEMPERATURE: [ATTR_TEMPERATURE],
|
||||||
SERVICE_SET_HUMIDITY: [ATTR_HUMIDITY],
|
SERVICE_SET_HUMIDITY: [ATTR_HUMIDITY],
|
||||||
SERVICE_SET_SWING_MODE: [ATTR_SWING_MODE],
|
SERVICE_SET_SWING_MODE: [ATTR_SWING_MODE],
|
||||||
|
|
Loading…
Add table
Reference in a new issue