Skip to content

Commit

Permalink
Add config params:
Browse files Browse the repository at this point in the history
* heating_night_lowering_to_temperature (parameters.ID_Einst_TAbsMin_akt)
* heating_difference_temperature_on (parameters.ID_Einst_TDC_Ein_akt)
* heating_difference_temperature_off (parameters.ID_Einst_TDC_Aus_akt)
* domestic_water_thermal_desinfection_target (parameters.ID_Einst_LGST_akt)

Add sensor values:
* analog_out1 (calculations.ID_WEB_AnalogOut1)
* analog_out2 (calculations.ID_WEB_AnalogOut2)

* Show next evu event in status text
* Fix null pointer in number factor calculation
* Correct flow icons
* Add flow_out_temperature_external sensor only if it hs not the default value
  • Loading branch information
BenPru committed Nov 28, 2022
1 parent d79cbe9 commit 03ee041
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 33 deletions.
6 changes: 3 additions & 3 deletions custom_components/luxtronik/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,19 @@ class LuxMkTypes(Enum):
LuxtronikSensorEntityDescription(
key="flow_in_temperature",
# f"{text_flow_in} {text_temp}",
icon="mdi:waves-arrow-left",
icon="mdi:waves-arrow-right",
sensor_key="calculations.ID_WEB_Temperatur_TVL",
),
LuxtronikSensorEntityDescription(
key="flow_out_temperature",
# f"{text_flow_out} {text_temp}",
icon="mdi:waves-arrow-right",
icon="mdi:waves-arrow-left",
sensor_key="calculations.ID_WEB_Temperatur_TRL",
),
LuxtronikSensorEntityDescription(
key="flow_out_temperature_external",
# f"{text_flow_out} {text_temp} ({text_external})",
icon="mdi:waves-arrow-right",
icon="mdi:waves-arrow-left",
sensor_key="calculations.ID_WEB_Temperatur_TRL_ext",
),
LuxtronikSensorEntityDescription(
Expand Down
45 changes: 38 additions & 7 deletions custom_components/luxtronik/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
STATE_CLASS_MEASUREMENT)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORIES,
PERCENTAGE, TEMP_CELSIUS, TIME_HOURS,
TIME_MINUTES)
PERCENTAGE, TEMP_CELSIUS, TEMP_KELVIN,
TIME_HOURS, TIME_MINUTES)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -87,7 +87,9 @@ async def async_setup_entry(
text_heating_circuit_curve1_temperature = get_sensor_text(lang, 'circuit_curve1_temperature')
text_heating_circuit_curve2_temperature = get_sensor_text(lang, 'circuit_curve2_temperature')
text_heating_circuit_curve_night_temperature = get_sensor_text(lang, 'circuit_curve_night_temperature')
has_room_temp = luxtronik.get_value("parameters.ID_Einst_RFVEinb_akt") != 0
text_heating_night_lowering_to_temperature = get_sensor_text(lang, 'heating_night_lowering_to_temperature')
text_heating_difference_temperature_on = get_sensor_text(lang, 'heating_difference_temperature_on')
text_heating_difference_temperature_off = get_sensor_text(lang, 'heating_difference_temperature_off')
entities += [
LuxtronikNumber(
hass, luxtronik, deviceInfoHeating,
Expand Down Expand Up @@ -118,29 +120,55 @@ async def async_setup_entry(
hass, luxtronik, deviceInfoHeating,
number_key=LUX_SENSOR_HEATING_CIRCUIT_CURVE_NIGHT_TEMPERATURE,
unique_id='heating_circuit_curve_night_temperature', name=f"{text_heating_circuit_curve_night_temperature}",
icon='mdi:chart-bell-curve', unit_of_measurement=TEMP_CELSIUS, min_value=-15.0, max_value=10.0, step=0.5, mode=NumberMode.BOX, entity_category=EntityCategory.CONFIG)
icon='mdi:chart-bell-curve', unit_of_measurement=TEMP_CELSIUS, min_value=-15.0, max_value=10.0, step=0.5, mode=NumberMode.BOX, entity_category=EntityCategory.CONFIG),
LuxtronikNumber(
hass, luxtronik, deviceInfoHeating,
number_key='parameters.ID_Einst_TAbsMin_akt',
unique_id='heating_night_lowering_to_temperature', name=f"{text_heating_night_lowering_to_temperature}",
icon='mdi:thermometer-low', unit_of_measurement=TEMP_CELSIUS, min_value=-20.0, max_value=10.0, step=0.5, mode=NumberMode.BOX, entity_category=EntityCategory.CONFIG, factor=0.1),
LuxtronikNumber(
hass, luxtronik, deviceInfoHeating,
number_key='parameters.ID_Einst_TDC_Ein_akt',
unique_id='heating_difference_temperature_on', name=f"{text_heating_difference_temperature_on}",
icon='mdi:radiator', unit_of_measurement=TEMP_KELVIN, min_value=2.0, max_value=15.0, step=0.1, mode=NumberMode.BOX, entity_category=None),
LuxtronikNumber(
hass, luxtronik, deviceInfoHeating,
number_key='parameters.ID_Einst_TDC_Aus_akt',
unique_id='heating_difference_temperature_off', name=f"{text_heating_difference_temperature_off}",
icon='mdi:radiator-off', unit_of_measurement=TEMP_KELVIN, min_value=0.5, max_value=10.0, step=0.1, mode=NumberMode.BOX, entity_category=None),
# ID_Einst_HysHzExEn_akt TEE Heizung 2 1-15
# ID_Einst_HysBwExEn_akt TEE Warmw. 5 1-15
# T-Diff. Speicher max 70 20-95
# T-Diff. Koll. max 110 90-120
]

has_room_temp = luxtronik.get_value("parameters.ID_Einst_RFVEinb_akt") != 0
if has_room_temp:
text_heating_room_temperature_impact_factor = get_sensor_text(lang, 'heating_room_temperature_impact_factor')
entities += [
LuxtronikNumber(
hass, luxtronik, deviceInfoHeating,
number_key=LUX_SENSOR_HEATING_ROOM_TEMPERATURE_IMPACT_FACTOR,
unique_id='heating_room_temperature_impact_factor', name=f"{text_heating_room_temperature_impact_factor}",
icon='mdi:thermometer-chevron-up', unit_of_measurement=PERCENTAGE, min_value=100, max_value=200, step=10, mode=NumberMode.BOX, entity_category=EntityCategory.CONFIG)
icon='mdi:thermometer-chevron-up', unit_of_measurement=PERCENTAGE, min_value=100, max_value=200, step=10, mode=NumberMode.BOX, entity_category=EntityCategory.CONFIG),
]

deviceInfoDomesticWater = hass.data[f"{DOMAIN}_DeviceInfo_Domestic_Water"]
if deviceInfoDomesticWater is not None:
text_target = get_sensor_text(lang, 'target')
text_domestic_water = get_sensor_text(lang, 'domestic_water')
text_thermal_desinfection = get_sensor_text(lang, 'thermal_desinfection')
entities += [
LuxtronikNumber(
hass, luxtronik, deviceInfoDomesticWater,
number_key=LUX_SENSOR_DOMESTIC_WATER_TARGET_TEMPERATURE,
unique_id='domestic_water_target_temperature', name=f"{text_domestic_water} {text_target}",
icon='mdi:water-boiler', unit_of_measurement=TEMP_CELSIUS, min_value=40.0, max_value=60.0, step=1.0, mode=NumberMode.BOX)
icon='mdi:water-boiler', unit_of_measurement=TEMP_CELSIUS, min_value=40.0, max_value=60.0, step=1.0, mode=NumberMode.BOX),
LuxtronikNumber(
hass, luxtronik, deviceInfoDomesticWater,
number_key='parameters.ID_Einst_LGST_akt',
unique_id='domestic_water_thermal_desinfection_target', name=f"{text_domestic_water} {text_thermal_desinfection} {text_target}",
icon='mdi:thermometer-high', unit_of_measurement=TEMP_CELSIUS, min_value=50.0, max_value=70.0, step=1.0, mode=NumberMode.BOX, factor=0.1, entity_category=EntityCategory.CONFIG),
]

deviceInfoCooling = hass.data[f"{DOMAIN}_DeviceInfo_Cooling"]
Expand Down Expand Up @@ -253,7 +281,10 @@ def update(self):
@property
def native_value(self):
"""Return the current value."""
return self._luxtronik.get_value(self._number_key) * self._factor
value = self._luxtronik.get_value(self._number_key)
if value is None:
return None
return value * self._factor

# @property
# def value(self) -> float:
Expand Down
74 changes: 55 additions & 19 deletions custom_components/luxtronik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from homeassistant.const import (CONF_FRIENDLY_NAME, CONF_ICON, CONF_ID,
CONF_SENSORS, DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENTITY_CATEGORIES,
EVENT_HOMEASSISTANT_STOP, POWER_WATT,
STATE_UNAVAILABLE, TEMP_CELSIUS, TEMP_KELVIN,
Expand Down Expand Up @@ -161,6 +162,7 @@ async def async_setup_entry(
text_high_pressure = get_sensor_text(lang, "high_pressure")
text_low_pressure = get_sensor_text(lang, "low_pressure")
text_operation_hours_additional_heat_generator = get_sensor_text(lang, "operation_hours_additional_heat_generator")
text_analog_out = get_sensor_text(lang, "analog_out")
# entities: list[LuxtronikSensor] = [
# LuxtronikStatusSensor(hass, luxtronik, device_info, description)
# for description in GLOBAL_STATUS_SENSOR_TYPES
Expand Down Expand Up @@ -397,6 +399,30 @@ async def async_setup_entry(
entity_category=EntityCategory.DIAGNOSTIC,
factor=SECOUND_TO_HOUR_FACTOR,
),
LuxtronikSensor(
hass,
luxtronik,
device_info,
sensor_key="calculations.ID_WEB_AnalogOut1",
unique_id="analog_out1",
name=f"{text_analog_out} 1",
icon="mdi:alpha-v-circle-outline",
device_class=DEVICE_CLASS_ENERGY,

This comment has been minimized.

Copy link
@Kars-de-Jong

Kars-de-Jong Nov 28, 2022

Contributor

That’s not right. Should be DEVICE_CLASS_MEASUREMENT.

unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
factor=0.1,
),
LuxtronikSensor(
hass,
luxtronik,
device_info,
sensor_key="calculations.ID_WEB_AnalogOut2",
unique_id="analog_out2",
name=f"{text_analog_out} 2",
icon="mdi:alpha-v-circle-outline",
device_class=DEVICE_CLASS_ENERGY,

This comment has been minimized.

Copy link
@Kars-de-Jong

Kars-de-Jong Nov 28, 2022

Contributor

Ditto.

unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
factor=0.1,
),
]
if luxtronik.get_value("calculations.Heat_Output") is not None:
entities += [
Expand Down Expand Up @@ -485,7 +511,7 @@ async def async_setup_entry(
"room_target_temperature",
f"{text_room} {text_target}",
entity_category=None,
)
),
]

entities += [
Expand All @@ -496,7 +522,7 @@ async def async_setup_entry(
"calculations.ID_WEB_Temperatur_TVL",
"flow_in_temperature",
f"{text_flow_in}",
"mdi:waves-arrow-left",
"mdi:waves-arrow-right",
entity_category=None,
),
LuxtronikSensor(
Expand All @@ -506,17 +532,7 @@ async def async_setup_entry(
"calculations.ID_WEB_Temperatur_TRL",
"flow_out_temperature",
f"{text_flow_out}",
"mdi:waves-arrow-right",
entity_category=None,
),
LuxtronikSensor(
hass,
luxtronik,
device_info_heating,
"calculations.ID_WEB_Temperatur_TRL_ext",
"flow_out_temperature_external",
f"{text_flow_out} ({text_external})",
"mdi:waves-arrow-right",
"mdi:waves-arrow-left",
entity_category=None,
),
LuxtronikSensor(
Expand Down Expand Up @@ -557,6 +573,20 @@ async def async_setup_entry(
),
]

if luxtronik.get_value("calculations.ID_WEB_Temperatur_TRL_ext") != 5.0:
entities += [
LuxtronikSensor(
hass,
luxtronik,
device_info_heating,
"calculations.ID_WEB_Temperatur_TRL_ext",
"flow_out_temperature_external",
f"{text_flow_out} ({text_external})",
"mdi:waves-arrow-right",
entity_category=None,
),
]

device_info_domestic_water = hass.data[f"{DOMAIN}_DeviceInfo_Domestic_Water"]
if device_info_domestic_water is not None:
text_collector = get_sensor_text(lang, "collector")
Expand All @@ -569,7 +599,6 @@ async def async_setup_entry(
text_heat_amount_domestic_water = get_sensor_text(
lang, "heat_amount_domestic_water"
)
solar_present = luxtronik.detect_solar_present()

entities += [
LuxtronikSensor(
Expand Down Expand Up @@ -610,6 +639,8 @@ async def async_setup_entry(
entity_category=EntityCategory.DIAGNOSTIC,
),
]

solar_present = luxtronik.detect_solar_present()
if solar_present:
entities += [
LuxtronikSensor(
Expand Down Expand Up @@ -822,13 +853,13 @@ class LuxtronikStatusSensor(LuxtronikSensor, RestoreEntity):
def update(self):
LuxtronikSensor.update(self)
time_now = time(datetime.utcnow().hour, datetime.utcnow().minute)
if self.native_value == LUX_STATUS_EVU and self._last_state != LUX_STATUS_EVU:
if self.native_value is not None and self._last_state is not None and self.native_value == LUX_STATUS_EVU and self._last_state != LUX_STATUS_EVU:
# evu start
if self._first_evu_start_time is None or time_now.hour <= self._first_evu_start_time.hour:
self._first_evu_start_time = time_now
else:
self._second_evu_start_time = time_now
elif self.native_value != LUX_STATUS_EVU and self._last_state == LUX_STATUS_EVU:
elif self.native_value is not None and self._last_state is not None and self.native_value != LUX_STATUS_EVU and self._last_state == LUX_STATUS_EVU:
# evu end
if self._first_evu_end_time is None or time_now.hour <= self._first_evu_end_time.hour:
self._first_evu_end_time = time_now
Expand Down Expand Up @@ -867,8 +898,14 @@ def _build_status_text(self) -> str:
lang = self.hass.data[f"{DOMAIN}_language"]
line_1 = get_sensor_value_text(lang, f"{DOMAIN}__status_line_1", line_1)
line_2 = get_sensor_value_text(lang, f"{DOMAIN}__status_line_2", line_2)
# TODO: Show evu end time if available
# if
# Show evu end time if available
evu_event_minutes = self._calc_next_evu_event_minutes()
if self.native_value == LUX_STATUS_EVU:
evu_until = get_sensor_text(lang, 'evu_until').format(evu_time = evu_event_minutes)
return f"{evu_until}. {line_1} {line_2} {status_time}."
elif evu_event_minutes <= 30:
evu_in = get_sensor_text(lang, 'evu_in').format(evu_time = evu_event_minutes)
return f"{line_1} {line_2} {status_time}. {evu_in}."
return f"{line_1} {line_2} {status_time}."

def _calc_next_evu_event_minutes_text(self) -> str:
Expand Down Expand Up @@ -928,7 +965,6 @@ async def async_added_to_hass(self) -> None:
return
self._state = state.state

# ADDED CODE HERE
if 'EVU first start time' in state.attributes:
self._first_evu_start_time = self._restore_value(state.attributes['EVU first start time'])
self._first_evu_end_time = self._restore_value(state.attributes['EVU first end time'])
Expand Down
13 changes: 10 additions & 3 deletions custom_components/luxtronik/translations/texts.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"efficiency_pump": "Effizienzpumpe",
"maximum_circulation_pump_speed": "Maximale Pumpen Zirkulations Geschwindigkeit",
"heating_room_temperature_impact_factor": "Raum Temperatur Einflussfaktor",
"overheating": "\u00d6berhitzung",
"overheating_target": "\u00d6berhitzung Soll",
"overheating": "\u00dcberhitzung",
"overheating_target": "\u00dcberhitzung Soll",
"high_pressure": "Hochdruck",
"low_pressure": "Niederdruck",
"circulation_pump": "Zirkulationspumpe",
Expand All @@ -66,5 +66,12 @@
"pump_flow": "Soleumw\u00e4lzpumpe",
"compressor_heater": "Verdichterheizung",
"additional_heat_generator_amount_counter": "Zus\u00e4tzlicher W\u00e4rmeerzeuger W\u00e4rmemenge",
"operation_hours_additional_heat_generator": "Zus\u00e4tzlicher W\u00e4rmeerzeuger Betriebsstunden"
"operation_hours_additional_heat_generator": "Zus\u00e4tzlicher W\u00e4rmeerzeuger Betriebsstunden",
"analog_out": "Analog Ausgang",
"thermal_desinfection": "Thermische Desinfektion",
"heating_night_lowering_to_temperature": "Absenkung bis Aussentemperatur",
"heating_difference_temperature_on": "Einschalt Differenz R\u00fccklauf",
"heating_difference_temperature_off": "Ausschalt Differenz R\u00fccklauf",
"evu_until": "Noch {evu_time} Minuten Netzsperre.",
"evu_in": "Netzsperre in {evu_time} Minuten."
}
9 changes: 8 additions & 1 deletion custom_components/luxtronik/translations/texts.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,12 @@
"pump_flow": "Pump flow",
"compressor_heater": "Compressor heater",
"additional_heat_generator_amount_counter": "Heat amount second/additional heat generator",
"operation_hours_additional_heat_generator": "Operation hours second/additional heat generator"
"operation_hours_additional_heat_generator": "Operation hours second/additional heat generator",
"analog_out": "Analog output",
"thermal_desinfection": "Thermal desinfection",
"heating_night_lowering_to_temperature": "Heating night lowering to temperature",
"heating_difference_temperature_on": "Switch-on differential return",
"heating_difference_temperature_off": "Switch-off differential return",
"evu_until": "{evu_time} minutes more locktime.",
"evu_in": "Locktime in {evu_time} minutes."
}

0 comments on commit 03ee041

Please sign in to comment.