mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Implement support for additional ecobee hold modes (#40520)
* useEndTime2hour - 2 hours * useEndTime4hour - 4 hours * indefinite - Until I change it These changes have been tested with an ecobee3 lite running firmware version 4.5.81.200 Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
parent
c54a0f80af
commit
3b184ad11c
@ -617,6 +617,7 @@ class Thermostat(ClimateEntity):
|
|||||||
cool_temp_setpoint,
|
cool_temp_setpoint,
|
||||||
heat_temp_setpoint,
|
heat_temp_setpoint,
|
||||||
self.hold_preference(),
|
self.hold_preference(),
|
||||||
|
self.hold_hours(),
|
||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Setting ecobee hold_temp to: heat=%s, is=%s, cool=%s, is=%s",
|
"Setting ecobee hold_temp to: heat=%s, is=%s, cool=%s, is=%s",
|
||||||
@ -717,15 +718,32 @@ class Thermostat(ClimateEntity):
|
|||||||
|
|
||||||
def hold_preference(self):
|
def hold_preference(self):
|
||||||
"""Return user preference setting for hold time."""
|
"""Return user preference setting for hold time."""
|
||||||
# Values returned from thermostat are 'useEndTime4hour',
|
# Values returned from thermostat are:
|
||||||
# 'useEndTime2hour', 'nextTransition', 'indefinite', 'askMe'
|
# "useEndTime2hour", "useEndTime4hour"
|
||||||
default = self.thermostat["settings"]["holdAction"]
|
# "nextPeriod", "askMe"
|
||||||
if default == "nextTransition":
|
# "indefinite"
|
||||||
return default
|
device_preference = self.thermostat["settings"]["holdAction"]
|
||||||
# add further conditions if other hold durations should be
|
# Currently supported pyecobee holdTypes:
|
||||||
# supported; note that this should not include 'indefinite'
|
# dateTime, nextTransition, indefinite, holdHours
|
||||||
# as an indefinite away hold is interpreted as away_mode
|
hold_pref_map = {
|
||||||
return "nextTransition"
|
"useEndTime2hour": "holdHours",
|
||||||
|
"useEndTime4hour": "holdHours",
|
||||||
|
"indefinite": "indefinite",
|
||||||
|
}
|
||||||
|
return hold_pref_map.get(device_preference, "nextTransition")
|
||||||
|
|
||||||
|
def hold_hours(self):
|
||||||
|
"""Return user preference setting for hold duration in hours."""
|
||||||
|
# Values returned from thermostat are:
|
||||||
|
# "useEndTime2hour", "useEndTime4hour"
|
||||||
|
# "nextPeriod", "askMe"
|
||||||
|
# "indefinite"
|
||||||
|
device_preference = self.thermostat["settings"]["holdAction"]
|
||||||
|
hold_hours_map = {
|
||||||
|
"useEndTime2hour": 2,
|
||||||
|
"useEndTime4hour": 4,
|
||||||
|
}
|
||||||
|
return hold_hours_map.get(device_preference, 0)
|
||||||
|
|
||||||
def create_vacation(self, service_data):
|
def create_vacation(self, service_data):
|
||||||
"""Create a vacation with user-specified parameters."""
|
"""Create a vacation with user-specified parameters."""
|
||||||
|
@ -208,26 +208,32 @@ async def test_set_temperature(ecobee_fixture, thermostat, data):
|
|||||||
# Auto -> Auto
|
# Auto -> Auto
|
||||||
data.reset_mock()
|
data.reset_mock()
|
||||||
thermostat.set_temperature(target_temp_low=20, target_temp_high=30)
|
thermostat.set_temperature(target_temp_low=20, target_temp_high=30)
|
||||||
data.ecobee.set_hold_temp.assert_has_calls([mock.call(1, 30, 20, "nextTransition")])
|
data.ecobee.set_hold_temp.assert_has_calls(
|
||||||
|
[mock.call(1, 30, 20, "nextTransition", 0)]
|
||||||
|
)
|
||||||
|
|
||||||
# Auto -> Hold
|
# Auto -> Hold
|
||||||
data.reset_mock()
|
data.reset_mock()
|
||||||
thermostat.set_temperature(temperature=20)
|
thermostat.set_temperature(temperature=20)
|
||||||
data.ecobee.set_hold_temp.assert_has_calls([mock.call(1, 25, 15, "nextTransition")])
|
data.ecobee.set_hold_temp.assert_has_calls(
|
||||||
|
[mock.call(1, 25, 15, "nextTransition", 0)]
|
||||||
|
)
|
||||||
|
|
||||||
# Cool -> Hold
|
# Cool -> Hold
|
||||||
data.reset_mock()
|
data.reset_mock()
|
||||||
ecobee_fixture["settings"]["hvacMode"] = "cool"
|
ecobee_fixture["settings"]["hvacMode"] = "cool"
|
||||||
thermostat.set_temperature(temperature=20.5)
|
thermostat.set_temperature(temperature=20.5)
|
||||||
data.ecobee.set_hold_temp.assert_has_calls(
|
data.ecobee.set_hold_temp.assert_has_calls(
|
||||||
[mock.call(1, 20.5, 20.5, "nextTransition")]
|
[mock.call(1, 20.5, 20.5, "nextTransition", 0)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Heat -> Hold
|
# Heat -> Hold
|
||||||
data.reset_mock()
|
data.reset_mock()
|
||||||
ecobee_fixture["settings"]["hvacMode"] = "heat"
|
ecobee_fixture["settings"]["hvacMode"] = "heat"
|
||||||
thermostat.set_temperature(temperature=20)
|
thermostat.set_temperature(temperature=20)
|
||||||
data.ecobee.set_hold_temp.assert_has_calls([mock.call(1, 20, 20, "nextTransition")])
|
data.ecobee.set_hold_temp.assert_has_calls(
|
||||||
|
[mock.call(1, 20, 20, "nextTransition", 0)]
|
||||||
|
)
|
||||||
|
|
||||||
# Heat -> Auto
|
# Heat -> Auto
|
||||||
data.reset_mock()
|
data.reset_mock()
|
||||||
@ -280,16 +286,32 @@ async def test_resume_program(thermostat, data):
|
|||||||
|
|
||||||
async def test_hold_preference(ecobee_fixture, thermostat):
|
async def test_hold_preference(ecobee_fixture, thermostat):
|
||||||
"""Test hold preference."""
|
"""Test hold preference."""
|
||||||
assert thermostat.hold_preference() == "nextTransition"
|
ecobee_fixture["settings"]["holdAction"] = "indefinite"
|
||||||
|
assert thermostat.hold_preference() == "indefinite"
|
||||||
|
for action in ["useEndTime2hour", "useEndTime4hour"]:
|
||||||
|
ecobee_fixture["settings"]["holdAction"] = action
|
||||||
|
assert thermostat.hold_preference() == "holdHours"
|
||||||
|
for action in [
|
||||||
|
"nextPeriod",
|
||||||
|
"askMe",
|
||||||
|
]:
|
||||||
|
ecobee_fixture["settings"]["holdAction"] = action
|
||||||
|
assert thermostat.hold_preference() == "nextTransition"
|
||||||
|
|
||||||
|
|
||||||
|
def test_hold_hours(ecobee_fixture, thermostat):
|
||||||
|
"""Test hold hours preference."""
|
||||||
|
ecobee_fixture["settings"]["holdAction"] = "useEndTime2hour"
|
||||||
|
assert thermostat.hold_hours() == 2
|
||||||
|
ecobee_fixture["settings"]["holdAction"] = "useEndTime4hour"
|
||||||
|
assert thermostat.hold_hours() == 4
|
||||||
for action in [
|
for action in [
|
||||||
"useEndTime4hour",
|
|
||||||
"useEndTime2hour",
|
|
||||||
"nextPeriod",
|
"nextPeriod",
|
||||||
"indefinite",
|
"indefinite",
|
||||||
"askMe",
|
"askMe",
|
||||||
]:
|
]:
|
||||||
ecobee_fixture["settings"]["holdAction"] = action
|
ecobee_fixture["settings"]["holdAction"] = action
|
||||||
assert thermostat.hold_preference() == "nextTransition"
|
assert thermostat.hold_hours() == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_set_fan_mode_on(thermostat, data):
|
async def test_set_fan_mode_on(thermostat, data):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user