From 866297965005a20c614b4f1c7895ca9c86cf5e46 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 31 Dec 2023 14:21:57 +0100 Subject: [PATCH] Update plant_thresholds.py fix #122, #124 --- custom_components/plant/plant_thresholds.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/plant/plant_thresholds.py b/custom_components/plant/plant_thresholds.py index b68ab1f..d898186 100644 --- a/custom_components/plant/plant_thresholds.py +++ b/custom_components/plant/plant_thresholds.py @@ -12,8 +12,7 @@ LIGHT_LUX, PERCENTAGE, STATE_UNKNOWN, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import Event, HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -282,8 +281,8 @@ def state_attributes_changed(self, old_attributes, new_attributes): new_state = round( TemperatureConverter.convert( temperature=float(self.state), - from_unit=TEMP_FAHRENHEIT, - to_unit=TEMP_CELSIUS, + from_unit=UnitOfTemperature.FAHRENHEIT, + to_unit=UnitOfTemperature.CELSIUS, ) ) _LOGGER.debug( @@ -299,8 +298,8 @@ def state_attributes_changed(self, old_attributes, new_attributes): new_state = round( TemperatureConverter.convert( temperature=float(self.state), - from_unit=TEMP_CELSIUS, - to_unit=TEMP_FAHRENHEIT, + from_unit=UnitOfTemperature.CELSIUS, + to_unit=UnitOfTemperature.FAHRENHEIT, ) ) _LOGGER.debug( @@ -374,8 +373,8 @@ def state_attributes_changed(self, old_attributes, new_attributes): new_state = round( TemperatureConverter.convert( temperature=float(self.state), - from_unit=TEMP_FAHRENHEIT, - to_unit=TEMP_CELSIUS, + from_unit=UnitOfTemperature.FAHRENHEIT, + to_unit=UnitOfTemperature.CELSIUS, ) ) _LOGGER.debug( @@ -393,8 +392,8 @@ def state_attributes_changed(self, old_attributes, new_attributes): new_state = round( TemperatureConverter.convert( temperature=float(self.state), - from_unit=TEMP_CELSIUS, - to_unit=TEMP_FAHRENHEIT, + from_unit=UnitOfTemperature.CELSIUS, + to_unit=UnitOfTemperature.FAHRENHEIT, ) ) _LOGGER.debug(