Add Ecobee services (#38749)

Enable/disable automatic daylight savings time
Enable/disable the Alexa mic on the Ecobee 4
Enable/disable Smart Home/Away and follow me modes
pull/38757/head
Yehuda Davis 2020-08-11 04:31:38 -04:00 committed by GitHub
parent 9bc68b9a73
commit bd3f075060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 0 deletions

View File

@ -33,6 +33,7 @@ from homeassistant.const import (
STATE_ON,
TEMP_FAHRENHEIT,
)
from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv
from homeassistant.util.temperature import convert
@ -49,6 +50,10 @@ ATTR_RESUME_ALL = "resume_all"
ATTR_START_DATE = "start_date"
ATTR_START_TIME = "start_time"
ATTR_VACATION_NAME = "vacation_name"
ATTR_DST_ENABLED = "dst_enabled"
ATTR_MIC_ENABLED = "mic_enabled"
ATTR_AUTO_AWAY = "auto_away"
ATTR_FOLLOW_ME = "follow_me"
DEFAULT_RESUME_ALL = False
PRESET_TEMPERATURE = "temp"
@ -98,6 +103,9 @@ SERVICE_CREATE_VACATION = "create_vacation"
SERVICE_DELETE_VACATION = "delete_vacation"
SERVICE_RESUME_PROGRAM = "resume_program"
SERVICE_SET_FAN_MIN_ON_TIME = "set_fan_min_on_time"
SERVICE_SET_DST_MODE = "set_dst_mode"
SERVICE_SET_MIC_MODE = "set_mic_mode"
SERVICE_SET_OCCUPANCY_MODES = "set_occupancy_modes"
DTGROUP_INCLUSIVE_MSG = (
f"{ATTR_START_DATE}, {ATTR_START_TIME}, {ATTR_END_DATE}, "
@ -165,6 +173,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(devices, True)
platform = entity_platform.current_platform.get()
def create_vacation_service(service):
"""Create a vacation on the target thermostat."""
entity_id = service.data[ATTR_ENTITY_ID]
@ -248,6 +258,27 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
schema=RESUME_PROGRAM_SCHEMA,
)
platform.async_register_entity_service(
SERVICE_SET_DST_MODE,
{vol.Required(ATTR_DST_ENABLED): cv.boolean},
"set_dst_mode",
)
platform.async_register_entity_service(
SERVICE_SET_MIC_MODE,
{vol.Required(ATTR_MIC_ENABLED): cv.boolean},
"set_mic_mode",
)
platform.async_register_entity_service(
SERVICE_SET_OCCUPANCY_MODES,
{
vol.Optional(ATTR_AUTO_AWAY): cv.boolean,
vol.Optional(ATTR_FOLLOW_ME): cv.boolean,
},
"set_occupancy_modes",
)
class Thermostat(ClimateEntity):
"""A thermostat class for Ecobee."""
@ -720,3 +751,17 @@ class Thermostat(ClimateEntity):
self._last_active_hvac_mode,
)
self.set_hvac_mode(self._last_active_hvac_mode)
def set_dst_mode(self, dst_enabled):
"""Enable/disable automatic daylight savings time."""
self.data.ecobee.set_dst_mode(self.thermostat_index, dst_enabled)
def set_mic_mode(self, mic_enabled):
"""Enable/disable Alexa mic (only for Ecobee 4)."""
self.data.ecobee.set_mic_mode(self.thermostat_index, mic_enabled)
def set_occupancy_modes(self, auto_away=None, follow_me=None):
"""Enable/disable Smart Home/Away and Follow Me modes."""
self.data.ecobee.set_occupancy_modes(
self.thermostat_index, auto_away, follow_me
)

View File

@ -69,3 +69,36 @@ set_fan_min_on_time:
fan_min_on_time:
description: New value of fan min on time.
example: 5
set_dst_mode:
description: Enable/disable automatic daylight savings time.
fields:
entity_id:
description: Name(s) of entities to change.
example: "climate.kitchen"
dst_enabled:
description: Enable automatic daylight savings time.
example: "true"
set_mic_mode:
description: Enable/disable Alexa mic (only for Ecobee 4).
fields:
entity_id:
description: Name(s) of entities to change.
example: "climate.kitchen"
mic_enabled:
description: Enable Alexa mic.
example: "true"
set_occupancy_modes:
description: Enable/disable Smart Home/Away and Follow Me modes.
fields:
entity_id:
description: Name(s) of entities to change.
example: "climate.kitchen"
auto_away:
description: Enable Smart Home/Away mode.
example: "true"
follow_me:
description: Enable Follow Me mode.
example: "true"