Skip to content

Commit

Permalink
* Fix wrong climate state while luxtronik defrost state.
Browse files Browse the repository at this point in the history
* Rename status to heatpump.
* Change target temperature step from 0.5 to 0.1.
* Cleanup double hass object in climate.
  • Loading branch information
BenPru committed Dec 4, 2022
1 parent 98940ea commit 24b0bbc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
25 changes: 15 additions & 10 deletions custom_components/luxtronik/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def async_setup_entry(
text_heating = get_sensor_text(lang, 'heating')
entities += [
LuxtronikHeatingThermostat(
hass, luxtronik, deviceInfoHeating, name=text_heating, control_mode_home_assistant=control_mode_home_assistant,
luxtronik, deviceInfoHeating, name=text_heating, control_mode_home_assistant=control_mode_home_assistant,
current_temperature_sensor=ha_sensor_indoor_temperature, entity_category=None)
]

Expand All @@ -102,7 +102,7 @@ async def async_setup_entry(
text_domestic_water = get_sensor_text(lang, 'domestic_water')
entities += [
LuxtronikDomesticWaterThermostat(
hass, luxtronik, deviceInfoDomesticWater, name=text_domestic_water, control_mode_home_assistant=control_mode_home_assistant,
luxtronik, deviceInfoDomesticWater, name=text_domestic_water, control_mode_home_assistant=control_mode_home_assistant,
current_temperature_sensor=LUX_SENSOR_DOMESTIC_WATER_CURRENT_TEMPERATURE, entity_category=None)
]

Expand All @@ -111,7 +111,7 @@ async def async_setup_entry(
text_cooling = get_sensor_text(lang, 'cooling')
entities += [
LuxtronikCoolingThermostat(
hass, luxtronik, deviceInfoCooling, name=text_cooling, control_mode_home_assistant=control_mode_home_assistant,
luxtronik, deviceInfoCooling, name=text_cooling, control_mode_home_assistant=control_mode_home_assistant,
current_temperature_sensor=LUX_SENSOR_OUTDOOR_TEMPERATURE, entity_category=None)
]

Expand Down Expand Up @@ -141,14 +141,14 @@ class LuxtronikThermostat(ClimateEntity, RestoreEntity):
_target_temperature_sensor: str = None

_heat_status = [LUX_STATUS_HEATING, LUX_STATUS_DOMESTIC_WATER, LUX_STATUS_COOLING]
_last_status: str = None

_cold_tolerance = DEFAULT_TOLERANCE
_hot_tolerance = DEFAULT_TOLERANCE

_last_lux_mode: LuxMode = None

def __init__(self, hass: HomeAssistant, luxtronik: LuxtronikDevice, deviceInfo: DeviceInfo, name: str, control_mode_home_assistant: bool, current_temperature_sensor: str, entity_category: ENTITY_CATEGORIES = None):
self._hass = hass
def __init__(self, luxtronik: LuxtronikDevice, deviceInfo: DeviceInfo, name: str, control_mode_home_assistant: bool, current_temperature_sensor: str, entity_category: ENTITY_CATEGORIES = None):
self._luxtronik = luxtronik
self._attr_device_info = deviceInfo
self._attr_name = name
Expand All @@ -169,7 +169,7 @@ def current_temperature(self) -> float:
self._attr_current_temperature = self._luxtronik.get_value(
self._current_temperature_sensor)
else:
current_temperature_sensor = self._hass.states.get(
current_temperature_sensor = self.hass.states.get(
self._current_temperature_sensor)
if current_temperature_sensor is None or current_temperature_sensor.state is None or current_temperature_sensor.state == 'unknown':
self._attr_current_temperature = None
Expand All @@ -186,7 +186,7 @@ def target_temperature(self) -> float:
self._attr_target_temperature = self._luxtronik.get_value(
self._target_temperature_sensor)
else:
self._attr_target_temperature = float(self._hass.states.get(
self._attr_target_temperature = float(self.hass.states.get(
self._target_temperature_sensor).state)
return self._attr_target_temperature

Expand All @@ -212,7 +212,7 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
if not await self._async_control_heating() and changed:
self.schedule_update_ha_state(force_refresh=True)
# endregion Temperatures

def _is_heating_on(self) -> bool:
status = self._luxtronik.get_value(self._status_sensor)
# region Workaround Luxtronik Bug: Status shows heating but status 3 = no request!
Expand All @@ -231,7 +231,12 @@ def _is_heating_on(self) -> bool:
# endregion Workaround Luxtronik Bug: Status shows heating but status 3 = no request!
# 211123 LOGGER.info("climate._is_heating_on2 %s self._heat_status: %s status: %s result: %s",
# self._attr_unique_id, self._heat_status, status, status in self._heat_status or status in [LUX_STATUS_DEFROST, LUX_STATUS_SWIMMING_POOL_SOLAR, LUX_STATUS_HEATING_EXTERNAL_SOURCE])
return status in self._heat_status or (status in [LUX_STATUS_DEFROST, LUX_STATUS_SWIMMING_POOL_SOLAR, LUX_STATUS_HEATING_EXTERNAL_SOURCE] and self._attr_hvac_mode != HVAC_MODE_OFF)
result = status in self._heat_status or (status in [LUX_STATUS_SWIMMING_POOL_SOLAR, LUX_STATUS_HEATING_EXTERNAL_SOURCE] and self._attr_hvac_mode != HVAC_MODE_OFF)
if not result and status == LUX_STATUS_DEFROST and self._attr_hvac_mode != HVAC_MODE_OFF and self._last_status == self._heat_status:
result = True
if self._last_status is None or self._last_status != status:
self._last_status = status
return result

@property
def hvac_action(self):
Expand Down Expand Up @@ -392,7 +397,7 @@ class LuxtronikHeatingThermostat(LuxtronikThermostat):
_attr_device_class: Final = f"{DOMAIN}__{_attr_unique_id}"

#_attr_target_temperature = 20.5
_attr_target_temperature_step = 0.5
_attr_target_temperature_step = 0.1
_attr_min_temp = -5.0
_attr_max_temp = +5.0

Expand Down
2 changes: 1 addition & 1 deletion custom_components/luxtronik/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "luxtronik2",
"name": "Luxtronik",
"version": "2022.12.03",
"version": "2022.12.04",
"integration_type": "hub",
"config_flow": true,
"iot_class": "local_polling",
Expand Down
7 changes: 4 additions & 3 deletions custom_components/luxtronik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async def async_setup_entry(
# Build Sensor names with local language:
lang = config_entry.options.get(CONF_LANGUAGE_SENSOR_NAMES)
hass.data[f"{DOMAIN}_language"] = lang
text_heatpump = get_sensor_text(lang, "heatpump")
text_time = get_sensor_text(lang, "time")
text_temp = get_sensor_text(lang, "temperature")
text_external = get_sensor_text(lang, "external")
Expand All @@ -158,7 +159,7 @@ async def async_setup_entry(
text_hot_gas = get_sensor_text(lang, "hot_gas")
text_suction_compressor = get_sensor_text(lang, "suction_compressor")
text_suction_evaporator = get_sensor_text(lang, "suction_evaporator")
text_compressor_heating = get_sensor_text(lang, "compressor_heating")
text_compressor = get_sensor_text(lang, "compressor")
text_overheating = get_sensor_text(lang, "overheating")
text_overheating_target = get_sensor_text(lang, "overheating_target")
text_high_pressure = get_sensor_text(lang, "high_pressure")
Expand All @@ -183,7 +184,7 @@ async def async_setup_entry(
device_info,
LUX_SENSOR_STATUS,
"status",
"Status",
text_heatpump,
LUX_STATE_ICON_MAP,
f"{DOMAIN}__status",
None,
Expand Down Expand Up @@ -335,7 +336,7 @@ async def async_setup_entry(
device_info,
"calculations.ID_WEB_LIN_VDH",
"compressor_heating_temperature",
f"{text_compressor_heating}",
text_compressor,
entity_category=None,
),
LuxtronikSensor(
Expand Down
1 change: 0 additions & 1 deletion custom_components/luxtronik/translations/texts.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"hot_gas": "Heissgas",
"suction_compressor": "Ansaug Verdichter",
"suction_evaporator": "Ansaug Verdampfer",
"compressor_heating": "Verdichter Heizung",
"pump_optimization": "Pumpenoptimierung",
"pump_optimization_time": "Pumpenoptimierung",
"efficiency_pump": "Effizienzpumpe",
Expand Down
1 change: 0 additions & 1 deletion custom_components/luxtronik/translations/texts.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"hot_gas": "Hot gas",
"suction_compressor": "Suction compressor",
"suction_evaporator": "Suction evaporator",
"compressor_heating": "Compressor heating",
"pump_optimization": "Pump optimization",
"pump_optimization_time": "Pump optimization",
"efficiency_pump": "Efficiency pump",
Expand Down

0 comments on commit 24b0bbc

Please sign in to comment.