Skip to content

Commit

Permalink
Fixed TARGET_TEMPERATURE_RANGE bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Tree committed Mar 29, 2024
1 parent bb577ae commit 00f09fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions custom_components/optispark/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ async def _api_wrapper(
self,
method: str,
url: str,
data: dict | None = None,
data: dict,
):
"""Call the Lambda function."""
try:
if 'dynamo_data' in data:
data['dynamo_data'] = floats_to_decimal(data['dynamo_data'])
data = self.json_serialisable(data)
data_serialised = self.json_serialisable(data)

async with async_timeout.timeout(40):
response = await self._session.request(
method=method,
url=url,
json=data,
json=data_serialised,
)
if response.status in (401, 403):
raise OptisparkApiClientAuthenticationError(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/optispark/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

NAME = "Optispark"
DOMAIN = "optispark"
VERSION = "0.2.4"
VERSION = "0.2.5"
ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/"

LAMBDA_TEMP_CONTROLS = 'temp_controls'
Expand Down
16 changes: 9 additions & 7 deletions custom_components/optispark/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DataUpdateCoordinator,
UpdateFailed,
)
from homeassistant.components.climate import HVACMode
from homeassistant.components.climate import ClimateEntityFeature
from homeassistant.exceptions import ConfigEntryAuthFailed

from .api import (
Expand Down Expand Up @@ -136,7 +136,8 @@ async def update_heat_pump_temperature(self, data):
if self.heat_pump_target_temperature == temp:
return
LOGGER.debug('Change in target temperature!')
if climate_entity.hvac_mode == HVACMode.HEAT_COOL:
supports_target_temperature_range = climate_entity.supported_features & ClimateEntityFeature.TARGET_TEMPERATURE_RANGE == ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
if supports_target_temperature_range:
await climate_entity.async_set_temperature(
target_temp_low=self.convert_climate_from_celcius(climate_entity, temp),
target_temp_high=climate_entity.target_temperature_high)
Expand Down Expand Up @@ -209,11 +210,12 @@ def heat_pump_target_temperature(self):
Assumes that the heat pump is being used for heating.
"""
climate_entity = get_entity(self.hass, self._climate_entity_id)
match climate_entity.hvac_mode:
case HVACMode.HEAT_COOL:
temperature = climate_entity.target_temperature_low
case _:
temperature = climate_entity.target_temperature
supports_target_temperature_range = climate_entity.supported_features & ClimateEntityFeature.TARGET_TEMPERATURE_RANGE == ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
if supports_target_temperature_range:
temperature = climate_entity.target_temperature_low
else:
temperature = climate_entity.target_temperature

return temperature

@property
Expand Down
2 changes: 1 addition & 1 deletion custom_components/optispark/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Big-Tree/HomeAssistant-OptiSpark/issues",
"requirements": ["geopy==2.4.1"],
"version": "0.2.4"
"version": "0.2.5"
}

0 comments on commit 00f09fb

Please sign in to comment.