Skip to content

Commit a338b70

Browse files
Fix: use HA built-in mode name (#405)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1b58dc5 commit a338b70

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

switchbot/const/climate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class SmartThermostatRadiatorMode(Enum):
2929
SCHEDULE = 0
3030
MANUAL = 1
3131
OFF = 2
32-
ECONOMIC = 3
32+
ECO = 3
3333
COMFORT = 4
34-
FAST_HEATING = 5
34+
BOOST = 5
3535

3636
@property
3737
def lname(self) -> str:

switchbot/devices/smart_thermostat_radiator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
# fast heating default use max temperature
3333
COMMAND_SET_TEMP = {
3434
STRMode.MANUAL.lname: "570F7801{temp:04X}",
35-
STRMode.ECONOMIC.lname: "570F7802{temp:02X}",
35+
STRMode.ECO.lname: "570F7802{temp:02X}",
3636
STRMode.COMFORT.lname: "570F7803{temp:02X}",
3737
STRMode.SCHEDULE.lname: "570F7806{temp:04X}",
3838
}
3939

4040
MODE_TEMP_RANGE = {
41-
STRMode.ECONOMIC.lname: (10.0, 20.0),
41+
STRMode.ECO.lname: (10.0, 20.0),
4242
STRMode.COMFORT.lname: (10.0, 25.0),
4343
}
4444

@@ -139,10 +139,8 @@ async def set_target_temperature(self, temperature: float) -> bool:
139139
"""Send command to set target temperature."""
140140
if self.preset_mode == STRMode.OFF.lname:
141141
raise SwitchbotOperationError("Cannot set temperature when mode is OFF.")
142-
if self.preset_mode == STRMode.FAST_HEATING.lname:
143-
raise SwitchbotOperationError(
144-
"Fast Heating mode defaults to max temperature."
145-
)
142+
if self.preset_mode == STRMode.BOOST.lname:
143+
raise SwitchbotOperationError("Boost mode defaults to max temperature.")
146144

147145
temp_value = int(temperature * 10)
148146
cmd = COMMAND_SET_TEMP[self.preset_mode].format(temp=temp_value)

tests/test_smart_thermostat_radiator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ async def test_set_hvac_mode_commands(mode, expected_command) -> None:
103103
(STRMode.SCHEDULE.lname, COMMAND_SET_MODE[STRMode.SCHEDULE.lname]),
104104
(STRMode.MANUAL.lname, COMMAND_SET_MODE[STRMode.MANUAL.lname]),
105105
(STRMode.OFF.lname, COMMAND_SET_MODE[STRMode.OFF.lname]),
106-
(STRMode.ECONOMIC.lname, COMMAND_SET_MODE[STRMode.ECONOMIC.lname]),
106+
(STRMode.ECO.lname, COMMAND_SET_MODE[STRMode.ECO.lname]),
107107
(STRMode.COMFORT.lname, COMMAND_SET_MODE[STRMode.COMFORT.lname]),
108-
(STRMode.FAST_HEATING.lname, COMMAND_SET_MODE[STRMode.FAST_HEATING.lname]),
108+
(STRMode.BOOST.lname, COMMAND_SET_MODE[STRMode.BOOST.lname]),
109109
],
110110
)
111111
@pytest.mark.asyncio
@@ -131,7 +131,7 @@ async def test_set_target_temperature_command() -> None:
131131
("mode", "match"),
132132
[
133133
(STRMode.OFF.lname, "Cannot set temperature when mode is OFF."),
134-
(STRMode.FAST_HEATING.lname, "Fast Heating mode defaults to max temperature."),
134+
(STRMode.BOOST.lname, "Boost mode defaults to max temperature."),
135135
],
136136
)
137137
async def test_set_target_temperature_with_invalid_mode(mode, match) -> None:
@@ -180,7 +180,7 @@ async def test_get_basic_info_none() -> None:
180180
0.8,
181181
62,
182182
"comfort",
183-
"economic",
183+
"eco",
184184
24.0,
185185
4.0,
186186
13.0,

0 commit comments

Comments
 (0)