From fb775ecb938325baeff1354770f15c484b17c377 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sun, 1 Sep 2024 15:32:11 -0400 Subject: [PATCH] Allow setting of temperature unit (F or C) when setting temperature (#39) Co-authored-by: Christopher H. Casebeer --- frigidaire/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frigidaire/__init__.py b/frigidaire/__init__.py index 20f30d7..46c8bbd 100644 --- a/frigidaire/__init__.py +++ b/frigidaire/__init__.py @@ -202,14 +202,17 @@ def set_humidity(cls, humidity: int) -> List[Component]: return [Component(Setting.TARGET_HUMIDITY, humidity)] @classmethod - def set_temperature(cls, temperature: int) -> List[Component]: + def set_temperature(cls, temperature: int, temperature_unit: Unit = Unit.FAHRENHEIT) -> List[Component]: # Note: Frigidaire sets limits for temperature which could cause this action to fail # Temperature ranges are below, inclusive of the endpoints # Fahrenheit: 60-90 # Celsius: 16-32 + logging.debug("Client setting target to {} {}".format(temperature, temperature_unit)) + temperature_unit_setting = Setting.TARGET_TEMPERATURE_F if temperature_unit == Unit.FAHRENHEIT else Setting.TARGET_TEMPERATURE_C + return [ - Component(Setting.TEMPERATURE_REPRESENTATION, Unit.FAHRENHEIT), - Component(Setting.TARGET_TEMPERATURE_F, temperature), + Component(Setting.TEMPERATURE_REPRESENTATION, temperature_unit), + Component(temperature_unit_setting, temperature), ]