Skip to content

Commit

Permalink
Improved °C to °F conversion
Browse files Browse the repository at this point in the history
Adjusted the set_temperature function to improve °C to °F conversion
  • Loading branch information
plmilord authored Apr 21, 2024
1 parent 744339c commit 3c2c2a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion custom_components/spaclient/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ def target_temperature(self):

async def async_set_temperature(self, **kwargs):
temperature = kwargs[ATTR_TEMPERATURE]
if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS:
if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS and self._spaclient.temp_scale == "Fahrenheit":
temperature = round(TemperatureConverter.convert(temperature, UnitOfTemperature.CELSIUS, UnitOfTemperature.FAHRENHEIT))
if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS and self._spaclient.temp_scale == "Celsius":
temperature = temperature * 2
if self.hass.config.units.temperature_unit == UnitOfTemperature.FAHRENHEIT and self._spaclient.temp_scale == "Celsius":
temperature = round(TemperatureConverter.convert(temperature, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS) * 2)
await self._spaclient.set_temperature(temperature)

async def async_set_hvac_mode(self, hvac_mode):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/spaclient/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://github.com/plmilord/Hass.io-custom-component-spaclient",
"iot_class": "local_push",
"issue_tracker": "https://github.com/plmilord/Hass.io-custom-component-spaclient/issues",
"version": "2.82"
"version": "2.83"
}
2 changes: 0 additions & 2 deletions custom_components/spaclient/spaclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,6 @@ def send_toggle_message(self, item):
self.send_message(b'\x0a\xbf\x11', bytes([item]) + b'\x00')

async def set_temperature(self, temp):
if self.temp_scale == "Celsius":
temp = round(TemperatureConverter.convert(temp, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS) * 2)
self.send_message(b'\x0a\xbf\x20', bytes([int(temp)]))

async def set_current_time(self):
Expand Down

0 comments on commit 3c2c2a4

Please sign in to comment.