Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions switchbot/const/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class SmartThermostatRadiatorMode(Enum):
SCHEDULE = 0
MANUAL = 1
OFF = 2
ECONOMIC = 3
ECO = 3
COMFORT = 4
FAST_HEATING = 5
BOOST = 5

@property
def lname(self) -> str:
Expand Down
10 changes: 4 additions & 6 deletions switchbot/devices/smart_thermostat_radiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
# fast heating default use max temperature
COMMAND_SET_TEMP = {
STRMode.MANUAL.lname: "570F7801{temp:04X}",
STRMode.ECONOMIC.lname: "570F7802{temp:02X}",
STRMode.ECO.lname: "570F7802{temp:02X}",
STRMode.COMFORT.lname: "570F7803{temp:02X}",
STRMode.SCHEDULE.lname: "570F7806{temp:04X}",
}

MODE_TEMP_RANGE = {
STRMode.ECONOMIC.lname: (10.0, 20.0),
STRMode.ECO.lname: (10.0, 20.0),
STRMode.COMFORT.lname: (10.0, 25.0),
}

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

temp_value = int(temperature * 10)
cmd = COMMAND_SET_TEMP[self.preset_mode].format(temp=temp_value)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_smart_thermostat_radiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ async def test_set_hvac_mode_commands(mode, expected_command) -> None:
(STRMode.SCHEDULE.lname, COMMAND_SET_MODE[STRMode.SCHEDULE.lname]),
(STRMode.MANUAL.lname, COMMAND_SET_MODE[STRMode.MANUAL.lname]),
(STRMode.OFF.lname, COMMAND_SET_MODE[STRMode.OFF.lname]),
(STRMode.ECONOMIC.lname, COMMAND_SET_MODE[STRMode.ECONOMIC.lname]),
(STRMode.ECO.lname, COMMAND_SET_MODE[STRMode.ECO.lname]),
(STRMode.COMFORT.lname, COMMAND_SET_MODE[STRMode.COMFORT.lname]),
(STRMode.FAST_HEATING.lname, COMMAND_SET_MODE[STRMode.FAST_HEATING.lname]),
(STRMode.BOOST.lname, COMMAND_SET_MODE[STRMode.BOOST.lname]),
],
)
@pytest.mark.asyncio
Expand All @@ -131,7 +131,7 @@ async def test_set_target_temperature_command() -> None:
("mode", "match"),
[
(STRMode.OFF.lname, "Cannot set temperature when mode is OFF."),
(STRMode.FAST_HEATING.lname, "Fast Heating mode defaults to max temperature."),
(STRMode.BOOST.lname, "Boost mode defaults to max temperature."),
],
)
async def test_set_target_temperature_with_invalid_mode(mode, match) -> None:
Expand Down Expand Up @@ -180,7 +180,7 @@ async def test_get_basic_info_none() -> None:
0.8,
62,
"comfort",
"economic",
"eco",
24.0,
4.0,
13.0,
Expand Down