Skip to content

Commit

Permalink
Only update the target temperature if the new temperature is different
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Tree committed Jan 11, 2024
1 parent fa20a8a commit 9fa1b8d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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.1.3"
VERSION = "0.1.4"
ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/"

LAMBDA_TEMP = 'temps'
Expand Down
19 changes: 18 additions & 1 deletion custom_components/optispark/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ async def update_heat_pump_temperature(self, data):
climate_entity = get_entity(self.hass, self._climate_entity_id)

try:
if self.heat_pump_target_temperature == temp:
return
LOGGER.debug('Change in target temperature!')
if climate_entity.hvac_mode == HVACMode.HEAT_COOL:
await climate_entity.async_set_temperature(
target_temp_low=self.convert_climate_from_celcius(climate_entity, temp),
Expand Down Expand Up @@ -189,9 +192,23 @@ def postcode(self):
"""Postcode."""
return self._postcode

@property
def heat_pump_target_temperature(self):
"""The current target temperature that the heat pump is set to.
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
return temperature

@property
def house_temperature(self):
"""Power usage of the heat pump."""
"""Internal temperature of the heat pump."""
entity = get_entity(self.hass, self._climate_entity_id)
out = self.convert_climate_from_farenheit(entity, entity.current_temperature)
return out
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.1.3"
"version": "0.1.4"
}

0 comments on commit 9fa1b8d

Please sign in to comment.