Skip to content

Commit

Permalink
* Fix nullpointer in new evu calculation for heatpupmps without evu.
Browse files Browse the repository at this point in the history
* Rename maximum_circulation_pump_speed to heating_maximum_circulation_pump_speed and disable it by default. User can activate it himself.
* Rename heating_difference_temperature_o* to solar_pump_o*_difference_temperature, move it to device domestic water and create only if solar is present.

* Add param solar_pump_off_max_difference_temperature_boiler (parameters.ID_Einst_TDC_Max_akt) and create only if solar is present.
* Add param solar_pump_max_temperature_collector (parameters.ID_Einst_TDC_Koll_Max_akt) and create only if solar is present.

* Add new off icons for heating and domestic water switch.
* Hide status_time and status_line_1-3 by default. User can change the visibility it himself.
* Disable pump_heat_control, suction_compressor_temperature, suction_evaporator_temperature, overheating_temperature, overheating_target_temperature, high_pressure, low_pressure, analog_out1 and analog_out2 by default. User can activate it himself.
* Change device class to energy for analog_out1 and analog_out2.
* Move circulation_pump from heatpump device to domestic water device.
* Move additional_circulation_pump from heatpump device to heating device.

* Optimize detecting real heatpump startup vs. compressor heater runs.
* Change some icons.
* Remove unnecessary hass object in class constructors.
  • Loading branch information
BenPru committed Nov 30, 2022
1 parent a2b0f9b commit 99a3e0e
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 154 deletions.
92 changes: 50 additions & 42 deletions custom_components/luxtronik/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
CONF_VISIBILITIES,
DEFAULT_DEVICE_CLASS,
DEVICE_CLASSES, DOMAIN, LOGGER,
LUX_BINARY_SENSOR_ADDITIONAL_CIRCULATION_PUMP,
LUX_BINARY_SENSOR_CIRCULATION_PUMP,
LUX_BINARY_SENSOR_EVU_UNLOCKED,
LUX_BINARY_SENSOR_SOLAR_PUMP
)
Expand Down Expand Up @@ -107,7 +109,6 @@ async def async_setup_platform(
)
entities += [
LuxtronikBinarySensor(
hass,
luxtronik,
deviceInfo=deviceInfo,
sensor_key=f"{group}.{sensor_id}",
Expand Down Expand Up @@ -161,7 +162,6 @@ async def async_setup_entry(

entities = [
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key=LUX_BINARY_SENSOR_EVU_UNLOCKED,
Expand All @@ -171,7 +171,6 @@ async def async_setup_entry(
device_class=DEVICE_CLASS_LOCK,
),
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key='calculations.ID_WEB_VD1out',
Expand All @@ -180,30 +179,9 @@ async def async_setup_entry(
icon="mdi:arrow-collapse-all",
device_class=DEVICE_CLASS_RUNNING,
),
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key='calculations.ID_WEB_ZIPout',
unique_id="circulation_pump",
name=text_circulation_pump,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key='calculations.ID_WEB_ZUPout',
unique_id="additional_circulation_pump",
name=text_additional_circulation_pump,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
# Soleumwälzpumpe
# Umwälzpumpe Ventilator, Brunnen- oder Sole
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key='calculations.ID_WEB_VBOout',
Expand All @@ -213,7 +191,6 @@ async def async_setup_entry(
device_class=DEVICE_CLASS_RUNNING,
),
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfo,
sensor_key='calculations.ID_WEB_LIN_VDH_out',
Expand All @@ -237,56 +214,73 @@ async def async_setup_entry(
if deviceInfoHeating is not None:
entities += [
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfoHeating,
sensor_key='calculations.ID_WEB_HUPout',
sensor_key=LUX_BINARY_SENSOR_CIRCULATION_PUMP,
unique_id="circulation_pump_heating",
name=text_circulation_pump_heating,
icon="mdi:car-turbocharger",
device_class=DEVICE_CLASS_RUNNING,
),
LuxtronikBinarySensor(
luxtronik=luxtronik,
deviceInfo=deviceInfoHeating,
sensor_key=LUX_BINARY_SENSOR_ADDITIONAL_CIRCULATION_PUMP,
unique_id="additional_circulation_pump",
name=text_additional_circulation_pump,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
]

deviceInfoDomesticWater = hass.data[f"{DOMAIN}_DeviceInfo_Domestic_Water"]
solar_present = luxtronik.detect_solar_present()
if (deviceInfoDomesticWater is not None) & (solar_present):
if deviceInfoDomesticWater is not None:
text_solar_pump = get_sensor_text(lang, "solar_pump")
entities += [
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfoDomesticWater,
sensor_key=LUX_BINARY_SENSOR_SOLAR_PUMP,
unique_id="solar_pump",
name=text_solar_pump,
sensor_key='calculations.ID_WEB_BUPout',
unique_id="circulation_pump_domestic_water",
name=text_circulation_pump_domestic_water,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfoDomesticWater,
sensor_key='calculations.ID_WEB_BUPout',
unique_id="circulation_pump_domestic_water",
name=text_circulation_pump_domestic_water,
sensor_key='calculations.ID_WEB_ZIPout',
unique_id="circulation_pump",
name=text_circulation_pump,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
]
solar_present = luxtronik.detect_solar_present()
if solar_present:
entities += [
LuxtronikBinarySensor(
luxtronik=luxtronik,
deviceInfo=deviceInfoDomesticWater,
sensor_key=LUX_BINARY_SENSOR_SOLAR_PUMP,
unique_id="solar_pump",
name=text_solar_pump,
icon="mdi:pump",
device_class=DEVICE_CLASS_RUNNING,
),
]

deviceInfoCooling = hass.data[f"{DOMAIN}_DeviceInfo_Cooling"]
if deviceInfoCooling is not None:
text_approval_cooling = get_sensor_text(lang, "approval_cooling")
entities += [
LuxtronikBinarySensor(
hass=hass,
luxtronik=luxtronik,
deviceInfo=deviceInfoCooling,
sensor_key="calculations.ID_WEB_FreigabKuehl",
unique_id="approval_cooling",
name=text_approval_cooling,
icon="mdi:lock",
_icon="mdi:lock",
device_class=DEVICE_CLASS_LOCK,
)
]
Expand All @@ -298,9 +292,11 @@ async def async_setup_entry(
class LuxtronikBinarySensor(BinarySensorEntity, RestoreEntity):
"""Representation of a Luxtronik binary sensor."""

_icon_off: str = None
_on_state: str = True

def __init__(
self,
hass: HomeAssistant,
luxtronik: LuxtronikDevice,
deviceInfo: DeviceInfo,
sensor_key: str,
Expand All @@ -311,9 +307,13 @@ def __init__(
state_class: str = None,
entity_category: ENTITY_CATEGORIES = None,
invert_state: bool = False,
entity_registry_enabled_default = True,
*args: Any,
**kwargs: Any,
) -> None:
"""Initialize a new Luxtronik binary sensor."""
self.hass = hass
# super().__init__(*args)
# self.hass = hass
self._luxtronik = luxtronik

self._sensor_key = sensor_key
Expand All @@ -326,15 +326,23 @@ def __init__(
self._attr_state_class = state_class
self._attr_entity_category = entity_category
self._invert = invert_state
self._attr_entity_registry_enabled_default = entity_registry_enabled_default
self._attr_extra_state_attributes = { ATTR_EXTRA_STATE_ATTRIBUTE_LUXTRONIK_KEY: sensor_key }


@property
def is_on(self):
"""Return true if binary sensor is on."""
value = self._luxtronik.get_value(self._sensor_key)
value = self._luxtronik.get_value(self._sensor_key) == self._on_state
return not value if self._invert else value

@property
def icon(self): # -> str | None:
"""Return the icon to be used for this entity."""
if not self.is_on and self._icon_off is not None:
return self._icon_off
return self._attr_icon

def update(self):
"""Get the latest status and use it to update our sensor state."""
self._luxtronik.update()
10 changes: 5 additions & 5 deletions custom_components/luxtronik/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
LUX_SENSOR_DOMESTIC_WATER_CURRENT_TEMPERATURE,
LUX_SENSOR_DOMESTIC_WATER_TARGET_TEMPERATURE,
LUX_SENSOR_HEATING_TARGET_CORRECTION,
LUX_SENSOR_COOLING_TARGET,
LUX_SENSOR_COOLING_THRESHOLD,
LUX_SENSOR_OUTDOOR_TEMPERATURE,

Expand All @@ -48,8 +47,7 @@
LUX_STATUS_HEATING,
LUX_STATUS_HEATING_EXTERNAL_SOURCE,
LUX_STATUS_NO_REQUEST, LUX_STATUS_SWIMMING_POOL_SOLAR,
PRESET_SECOND_HEATSOURCE, PRESET_AUTO,
LuxMode)
PRESET_SECOND_HEATSOURCE, LuxMode)
from .helpers.helper import get_sensor_text

# endregion Imports
Expand Down Expand Up @@ -173,8 +171,10 @@ def current_temperature(self) -> float:
else:
current_temperature_sensor = self._hass.states.get(
self._current_temperature_sensor)
self._attr_current_temperature = None if current_temperature_sensor is None else float(
current_temperature_sensor.state)
if current_temperature_sensor is None or current_temperature_sensor.state is None or current_temperature_sensor.state == 'unknown':
self._attr_current_temperature = None
else:
self._attr_current_temperature = float(current_temperature_sensor.state)
return self._attr_current_temperature

@property
Expand Down
12 changes: 7 additions & 5 deletions custom_components/luxtronik/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ class LuxMode(Enum):
LUX_STATE_ICON_MAP: Final[dict[str, str]] = {
LUX_STATUS_HEATING: "mdi:radiator",
LUX_STATUS_DOMESTIC_WATER: "mdi:waves",
LUX_STATUS_SWIMMING_POOL_SOLAR: None,
LUX_STATUS_SWIMMING_POOL_SOLAR: "mdi:pool",
LUX_STATUS_EVU: "mdi:power-plug-off",
LUX_STATUS_DEFROST: "mdi:car-defrost-rear",
LUX_STATUS_NO_REQUEST: "mdi:radiator-disabled",
LUX_STATUS_HEATING_EXTERNAL_SOURCE: None,
LUX_STATUS_NO_REQUEST: "mdi:heat-pump-outline", #"mdi:radiator-disabled",
LUX_STATUS_HEATING_EXTERNAL_SOURCE: "mdi:patio-heater",
LUX_STATUS_COOLING: "mdi:air-conditioner",
}

Expand All @@ -203,7 +203,7 @@ class LuxMode(Enum):
LUX_SENSOR_OUTDOOR_TEMPERATURE: Final = "calculations.ID_WEB_Temperatur_TA"

LUX_SENSOR_PUMP_OPTIMIZATION_TIME: Final = "parameters.ID_Einst_Popt_Nachlauf_akt"
LUX_SENSOR_MAXIMUM_CIRCULATION_PUMP_SPEED: Final = "parameters.ID_Einst_P155_PumpHeat_Max"
LUX_SENSOR_HEATING_MAXIMUM_CIRCULATION_PUMP_SPEED: Final = "parameters.ID_Einst_P155_PumpHeat_Max"
LUX_SENSOR_HEATING_TARGET_CORRECTION: Final = "parameters.ID_Einst_WK_akt"
LUX_SENSOR_HEATING_ROOM_TEMPERATURE_IMPACT_FACTOR: Final = "parameters.ID_RBE_Einflussfaktor_RT_akt"
LUX_SENSOR_HEATING_THRESHOLD: Final = "parameters.ID_Einst_Heizgrenze"
Expand All @@ -229,7 +229,9 @@ class LuxMode(Enum):
LUX_SENSOR_MODE_FAN: Final = "parameters.ID_Einst_BA_Lueftung_akt"
LUX_BINARY_SENSOR_EVU_UNLOCKED: Final = "calculations.ID_WEB_EVUin"
LUX_BINARY_SENSOR_SOLAR_PUMP: Final = "calculations.ID_WEB_SLPout"
LUX_BINARY_SENSOR_Circulation_Pump: Final = "calculations.ID_WEB_HUPout"
LUX_BINARY_SENSOR_CIRCULATION_PUMP: Final = "calculations.ID_WEB_HUPout"
LUX_BINARY_SENSOR_ADDITIONAL_CIRCULATION_PUMP: Final = "calculations.ID_WEB_ZUPout"

# Future use:

# LUX_SENSOR_MODE_???: Final = 'parameters.ID_Ba_Sw_akt'
Expand Down
3 changes: 2 additions & 1 deletion custom_components/luxtronik/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"domain": "luxtronik2",
"name": "Luxtronik",
"version": "2022.11.20",
"version": "2022.11.30",
"integration_type": "hub",
"config_flow": true,
"iot_class": "local_polling",
"documentation": "https://www.home-assistant.io/integrations/luxtronik",
Expand Down
Loading

0 comments on commit 99a3e0e

Please sign in to comment.