From e014d2e0955983c7e5a17910823019d61499da7f Mon Sep 17 00:00:00 2001 From: Olaf Strama Date: Thu, 5 Dec 2024 20:45:33 +0000 Subject: [PATCH] Added new calc sensor method, added token for webif, choose cubic splines when scipy available --- .../weishaupt_modbus/__init__.py | 11 +- .../weishaupt_modbus/config_flow.py | 10 +- custom_components/weishaupt_modbus/const.py | 13 +- .../weishaupt_modbus/entities.py | 120 +++++++++--------- custom_components/weishaupt_modbus/hpconst.py | 66 +++++----- .../weishaupt_modbus/kennfeld.py | 26 +++- custom_components/weishaupt_modbus/sensor.py | 2 +- .../weishaupt_modbus/strings.json | 32 +++-- .../weishaupt_modbus/translations/de.json | 32 +++-- .../weishaupt_modbus/translations/en.json | 32 +++-- .../weishaupt_modbus/webif_object.py | 8 +- 11 files changed, 193 insertions(+), 159 deletions(-) diff --git a/custom_components/weishaupt_modbus/__init__.py b/custom_components/weishaupt_modbus/__init__.py index 29a34a9..82e4880 100644 --- a/custom_components/weishaupt_modbus/__init__.py +++ b/custom_components/weishaupt_modbus/__init__.py @@ -2,7 +2,7 @@ import json import logging -from pathlib import Path +# from pathlib import Path from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -51,7 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: MyConfigEntry) -> bool: mbapi = ModbusAPI(config_entry=entry) if entry.data[CONF.CB_WEBIF]: - print + # print webapi = WebifConnection(config_entry=entry) await webapi.login() else: @@ -158,6 +158,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: MyConfigEntry): new_data[CONF.CB_WEBIF] = False new_data[CONF.USERNAME] = "" new_data[CONF.PASSWORD] = "" + new_data[CONF.WEBIF_TOKEN] = "" hass.config_entries.async_update_entry( config_entry, data=new_data, minor_version=1, version=5 ) @@ -242,7 +243,8 @@ def create_string_json() -> None: # ... # load strings.json into string - with Path.open( + # replaced Path.open by open + with open( file="config/custom_components/weishaupt_modbus/strings.json", encoding="utf-8", ) as file: @@ -252,7 +254,8 @@ def create_string_json() -> None: # overwrite entiy dict data_dict["entity"] = myEntity # write whole json to file again - with Path.open( + # replaced Path.open by open + with open( file="config/custom_components/weishaupt_modbus/strings.json", mode="w", encoding="utf-8", diff --git a/custom_components/weishaupt_modbus/config_flow.py b/custom_components/weishaupt_modbus/config_flow.py index d8d5269..8350cf0 100644 --- a/custom_components/weishaupt_modbus/config_flow.py +++ b/custom_components/weishaupt_modbus/config_flow.py @@ -64,7 +64,7 @@ async def validate_input(data: dict) -> dict[str, Any]: return {"title": data["host"]} -class ConfigFlow(config_entries.ConfigFlow, domain=CONST.DOMAIN): +class ConfigFlow(config_entries.ConfigFlow, domain=CONST.DOMAIN): # pylint: disable=W0223 """Class config flow.""" VERSION = 5 @@ -105,6 +105,7 @@ async def async_step_user(self, user_input=None) -> config_entries.ConfigFlowRes vol.Optional(schema=CONF.CB_WEBIF, default=False): bool, vol.Optional(schema=CONF.USERNAME, default=""): str, vol.Optional(schema=CONF.PASSWORD, default=""): str, + vol.Optional(schema=CONF.WEBIF_TOKEN, default=""): str, } ) @@ -119,7 +120,8 @@ async def async_step_user(self, user_input=None) -> config_entries.ConfigFlowRes except Exception: # noqa: BLE001 errors["base"] = "unknown error" - # If there is no user input or there were errors, show the form again, including any errors that were found with the input. + # If there is no user input or there were errors, show the form again, + # #including any errors that were found with the input. return self.async_show_form( step_id="user", data_schema=data_schema, errors=errors ) @@ -187,6 +189,10 @@ async def async_step_reconfigure( vol.Optional( schema=CONF.PASSWORD, default=reconfigure_entry.data[CONF.PASSWORD] ): str, + vol.Optional( + schema=CONF.WEBIF_TOKEN, + default=reconfigure_entry.data[CONF.WEBIF_TOKEN], + ): str, } ) diff --git a/custom_components/weishaupt_modbus/const.py b/custom_components/weishaupt_modbus/const.py index ab99d5e..635b46b 100644 --- a/custom_components/weishaupt_modbus/const.py +++ b/custom_components/weishaupt_modbus/const.py @@ -30,6 +30,7 @@ class ConfConstants: CB_WEBIF = "enable-webif" PASSWORD = CONF_PASSWORD USERNAME = CONF_USERNAME + WEBIF_TOKEN = "Web-IF-Token" CONF = ConfConstants() @@ -120,15 +121,3 @@ class DeviceNameConstants: DEVICENAMES = DeviceNameConstants() - - -@dataclass(frozen=True) -class CalcConstants: - """Main constants.""" - - POWER = "power" - QUOTIENT = "quotient" - DIFFERENCE = "difference" - - -CALCTYPES = CalcConstants() diff --git a/custom_components/weishaupt_modbus/entities.py b/custom_components/weishaupt_modbus/entities.py index 52ca26a..1398115 100644 --- a/custom_components/weishaupt_modbus/entities.py +++ b/custom_components/weishaupt_modbus/entities.py @@ -11,7 +11,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from .configentry import MyConfigEntry -from .const import CONF, CONST, FORMATS, CALCTYPES +from .const import CONF, CONST, FORMATS from .coordinator import MyCoordinator, MyWebIfCoordinator from .hpconst import reverse_device_list from .items import ModbusItem, WebItem @@ -85,7 +85,8 @@ def __init__( else: if self._api_item.params is not None: self._attr_state_class = self._api_item.params.get( - "stateclass",SensorStateClass.MEASUREMENT) + "stateclass", SensorStateClass.MEASUREMENT + ) self._attr_native_unit_of_measurement = self._api_item.params.get( "unit", "" ) @@ -212,8 +213,8 @@ class MyCalcSensorEntity(MySensorEntity): """ # calculates output from map - my_map = None - _calculation_type = None + _calculation_source = None + _calculation = None def __init__( self, @@ -224,11 +225,17 @@ def __init__( ) -> None: """Initialize MyCalcSensorEntity.""" MySensorEntity.__init__(self, config_entry, modbus_item, coordinator, idx) + if self._api_item.params is not None: - self._calculation_type = self._api_item.params.get("calculation_type", None) + self._calculation_source = self._api_item.params.get("calculation", None) - if self._calculation_type == CALCTYPES.POWER: - self.my_map = config_entry.runtime_data.powermap + if self._calculation_source is not None: + try: + self._calculation = compile( + self._calculation_source, "calulation", "eval" + ) + except SyntaxError: + log.warning("Syntax error %s", self._calculation_source) @callback def _handle_coordinator_update(self) -> None: @@ -237,64 +244,61 @@ def _handle_coordinator_update(self) -> None: self.async_write_ha_state() def translate_val(self, val): - if val is None: - return None - match self._calculation_type: - case CALCTYPES.POWER: - return self.power_val(val) - case CALCTYPES.QUOTIENT: - return self.quotient_val(val) - case CALCTYPES.DIFFERENCE: - return self.diff_val(val) - - def power_val(self, val): """Translate a value from the modbus.""" - val_0 = val / self._divider - val_x = self._config_entry.runtime_data.coordinator.get_value_from_item( - self._api_item.params.get("x", 1) - ) - if val_x is None: + if self._calculation_source is None: return None - val_y = self._config_entry.runtime_data.coordinator.get_value_from_item( - self._api_item.params.get("y", 1) - ) - if val_y is None: + if self._api_item.params is None: return None - return round( - (val_0 / 100) * self.my_map.map(val_x, val_y), - self._attr_suggested_display_precision, - ) + if "val_1" in self._calculation_source: + val_1 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_1", 1) + ) + if "val_2" in self._calculation_source: + val_2 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_2", 1) + ) + if "val_3" in self._calculation_source: + val_3 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_3", 1) + ) + if "val_4" in self._calculation_source: + val_4 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_4", 1) + ) + if "val_5" in self._calculation_source: + val_5 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_5", 1) + ) + if "val_6" in self._calculation_source: + val_6 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_6", 1) + ) + if "val_7" in self._calculation_source: + val_7 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_7", 1) + ) + if "val_8" in self._calculation_source: + val_8 = self._config_entry.runtime_data.coordinator.get_value_from_item( # noqa F841 pylint: disable=W0612 + self._api_item.params.get("val_8", 1) + ) + if "power" in self._calculation_source: + power = self._config_entry.runtime_data.powermap # noqa F841 pylint: disable=W0612 - def quotient_val(self, val): - """Translate a value from the modbus.""" - val_0 = val / self._divider - val_x = self._config_entry.runtime_data.coordinator.get_value_from_item( - self._api_item.params["denominator"] - ) - if val_x is None: + try: + val_0 = val / self._divider # noqa F841 pylint: disable=W0612 + y = eval(self._calculation) # pylint: disable=W0123 + except ZeroDivisionError: return None - if val_0 is None: + except NameError: + log.warning("Variable not defined %s", self._calculation_source) return None - if val_x == 0: + except TypeError: + log.warning("No valid calulation string") return None - return round(val_0 / val_x, self._attr_suggested_display_precision) - - def diff_val(self, val): - """Translate a value from the modbus.""" - val_0 = val / self._divider - val_x = self._config_entry.runtime_data.coordinator.get_value_from_item( - self._api_item.params["diff_val"] - ) - if val_x is None: - return None - if val_0 is None: - return None - return round( - val_0 - val_x / self._divider, self._attr_suggested_display_precision - ) + return round(y, self._attr_suggested_display_precision) -class MyNumberEntity(CoordinatorEntity, NumberEntity, MyEntity): +class MyNumberEntity(CoordinatorEntity, NumberEntity, MyEntity): # pylint: disable=W0223 """Represent a Number Entity. Class that represents a sensor entity derived from Sensorentity @@ -331,7 +335,7 @@ def device_info(self) -> DeviceInfo: return MyEntity.my_device_info(self) -class MySelectEntity(CoordinatorEntity, SelectEntity, MyEntity): +class MySelectEntity(CoordinatorEntity, SelectEntity, MyEntity): # pylint: disable=W0223 """Class that represents a sensor entity. Class that represents a sensor entity derived from Sensorentity @@ -433,7 +437,7 @@ def _handle_coordinator_update(self) -> None: "Update of %s failed. None response from server", self._api_item.name ) - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs): # pylint: disable=W0613 """Turn the light on. Example method how to request data updates. diff --git a/custom_components/weishaupt_modbus/hpconst.py b/custom_components/weishaupt_modbus/hpconst.py index 75a3bea..f6dbd8d 100644 --- a/custom_components/weishaupt_modbus/hpconst.py +++ b/custom_components/weishaupt_modbus/hpconst.py @@ -11,7 +11,7 @@ PERCENTAGE, ) -from .const import DEVICES, FORMATS, TYPES, CALCTYPES +from .const import DEVICES, FORMATS, TYPES from .items import ModbusItem, StatusItem, WebItem reverse_device_list: dict[str, str] = { @@ -711,7 +711,7 @@ "deviceclass": SensorDeviceClass.TEMPERATURE, "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_ROOMTEMP_LOW: dict = { @@ -724,7 +724,7 @@ "precision": 1, "icon": "mdi:thermometer-low", "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_ROOMTEMP_MID: dict = { @@ -737,7 +737,7 @@ "dynamic_max": "raum_soll_temp_komf", "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_ROOMTEMP_HIGH: dict = { @@ -750,7 +750,7 @@ "precision": 1, "icon": "mdi:thermometer-high", "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_WATERTEMP: dict = { @@ -762,7 +762,7 @@ "precision": 1, "icon": "mdi:thermometer-water", "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_WATERTEMP_LOW: dict = { @@ -775,7 +775,7 @@ "precision": 1, "icon": "mdi:thermometer-water", "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_WATERTEMP_HIGH: dict = { @@ -788,7 +788,7 @@ "precision": 1, "icon": "mdi:thermometer-water", "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } @@ -800,7 +800,7 @@ "deviceclass": SensorDeviceClass.TEMPERATURE, "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_BIVALENZTEMP: dict = { @@ -811,7 +811,7 @@ "deviceclass": SensorDeviceClass.TEMPERATURE, "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_STDTEMP: dict = { @@ -822,7 +822,7 @@ "deviceclass": SensorDeviceClass.TEMPERATURE, "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } @@ -833,7 +833,7 @@ "divider": 100, "precision": 2, "icon": "mdi:chart-line", - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_FLOWRATE: dict = { @@ -843,7 +843,7 @@ "divider": 100, "precision": 2, "unit": UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, } PARAMS_ENERGY: dict = { @@ -852,72 +852,70 @@ "deviceclass": SensorDeviceClass.ENERGY, "precision": 0, "unit": UnitOfEnergy.KILO_WATT_HOUR, - "stateclass": SensorStateClass.TOTAL_INCREASING, + "stateclass": SensorStateClass.TOTAL_INCREASING, } PARAMS_CALCPOWER: dict = { "min": 0, "max": 50000, - "x": "luftansautgemp", # 30002, - "y": "vl_temp", # 33104, - "x2": "aussentemp", # 30001, + "val_1": "luftansautgemp", # 30002, + "val_2": "vl_temp", # 33104, + "val_3": "aussentemp", # 30001, "deviceclass": SensorDeviceClass.POWER, - "calculation_type": CALCTYPES.POWER, "precision": 0, "unit": UnitOfPower.WATT, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, + "calculation": "(val_0 / 100) * power.map(val_1, val_2)", } PARAMS_CALCSPREIZUNG: dict = { "min": 0, "max": 50, "divider": 10, - "diff_val": "rl_temp", # 30001, + "val_1": "rl_temp", # 30001, "deviceclass": SensorDeviceClass.TEMPERATURE, - "calculation_type": CALCTYPES.DIFFERENCE, "precision": 1, "unit": UnitOfTemperature.CELSIUS, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, + "calculation": "val_0 - val_1/10", } PARAMS_CALCTAZ: dict = { "min": 0, "max": 50, - "denominator": "el_energie_heute", - "calculation_type": CALCTYPES.QUOTIENT, + "val_1": "el_energie_heute", "precision": 2, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, "icon": "mdi:sigma", + "calculation": "val_0 / val_1", } PARAMS_CALCTAZ2: dict = { "min": 0, "max": 50, - "denominator": "el_energie_gestern", - "calculation_type": CALCTYPES.QUOTIENT, + "val_1": "el_energie_gestern", "precision": 2, - "stateclass": SensorStateClass.MEASUREMENT, "icon": "mdi:sigma", + "calculation": "val_0 / val_1", } PARAMS_CALCMAZ: dict = { "min": 0, "max": 50, - "denominator": "el_energie_monat", - "calculation_type": CALCTYPES.QUOTIENT, + "val_1": "el_energie_monat", "precision": 2, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, "icon": "mdi:sigma", + "calculation": "val_0 / val_1", } PARAMS_CALCJAZ: dict = { "min": 0, "max": 50, "denominator": "el_energie_jahr", - "calculation_type": CALCTYPES.QUOTIENT, "precision": 2, - "stateclass": SensorStateClass.MEASUREMENT, + "stateclass": SensorStateClass.MEASUREMENT, "icon": "mdi:sigma", } @@ -979,7 +977,7 @@ ModbusItem( address=31101, name="Raumsolltemperatur", mformat=FORMATS.TEMPERATUR, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_ROOMTEMP, translation_key="raum_soll_temp"), ModbusItem( address=31102, name="Raumtemperatur", mformat=FORMATS.TEMPERATUR, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_ROOMTEMP, translation_key="raum_temp"), ModbusItem( address=31103, name="Raumfeuchte", mformat=FORMATS.PERCENTAGE, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_PERCENTAGE, translation_key="raum_feuchte"), - ModbusItem( address=31104, name="Vorlaufsolltemperatur", mformat=FORMATS.TEMPERATUR, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_STDTEMP, translation_key="vl_temp"), + ModbusItem( address=31104, name="Vorlaufsolltemperatur", mformat=FORMATS.TEMPERATUR, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_STDTEMP, translation_key="hz_vl_solltemp"), ModbusItem( address=31105, name="HZ_Vorlauftemperatur", mformat=FORMATS.TEMPERATUR, mtype=TYPES.SENSOR, device=DEVICES.HZ, params=PARAMS_STDTEMP, translation_key="hz_vl_temp"), ModbusItem( address=31106, name="Adr. 31106", mformat=FORMATS.UNKNOWN, mtype=TYPES.SENSOR, device=DEVICES.HZ, translation_key="adr31106"), ModbusItem( address=41101, name="HZ_Konfiguration", mformat=FORMATS.STATUS, mtype=TYPES.NUMBER_RO, device=DEVICES.HZ, resultlist=HZ_KONFIGURATION, translation_key="hz_konf"), diff --git a/custom_components/weishaupt_modbus/kennfeld.py b/custom_components/weishaupt_modbus/kennfeld.py index ac0b411..84a68f6 100644 --- a/custom_components/weishaupt_modbus/kennfeld.py +++ b/custom_components/weishaupt_modbus/kennfeld.py @@ -9,12 +9,26 @@ from .configentry import MyConfigEntry -# from scipy.interpolate import CubicSpline from .const import CONF, CONST logging.basicConfig() log = logging.getLogger(__name__) +SPLINE_AVAILABLE = True +try: + import scipy # noqa F401 pylint: disable=W0611 +except ModuleNotFoundError: + log.warning( + "Scipy not available, use less precise Chebyshef interpolation for heating power" + ) + SPLINE_AVAILABLE = False + +if SPLINE_AVAILABLE is True: + log.info( + "Scipy available, use precise cubic spline interpolation for heating power" + ) + from scipy.interpolate import CubicSpline # pylint: disable=E0401 + class PowerMap: """Power map class.""" @@ -148,16 +162,18 @@ async def initialize(self): t = np.linspace(-30, 40, 71) # cubic spline interpolation of power curves for idx in range(len(self._r_to_interpolate)): - # f = CubicSpline(self.known_x, self.interp_y[idx], bc_type='natural') - f = Chebyshev.fit(self.known_x, self._interp_y[idx], deg=8) + if SPLINE_AVAILABLE is True: + f = CubicSpline(self.known_x, self._interp_y[idx], bc_type="natural") + else: + f = Chebyshev.fit(self.known_x, self._interp_y[idx], deg=8) self._max_power.append(f(t)) def map(self, x, y): """Map.""" - x = x - self.known_x[0] + x = x / 10 - self.known_x[0] x = max(x, 0) x = min(x, 70) - y = y - self.known_t[0] + y = y / 10 - self.known_t[0] y = max(y, 0) y = min(y, self._steps - 1) diff --git a/custom_components/weishaupt_modbus/sensor.py b/custom_components/weishaupt_modbus/sensor.py index 16689ba..8ceffd1 100644 --- a/custom_components/weishaupt_modbus/sensor.py +++ b/custom_components/weishaupt_modbus/sensor.py @@ -69,8 +69,8 @@ async def async_setup_entry( idx=1, ) ) + entries = entries + webifentries - # entries = entries + webifentries async_add_entities( entries, update_before_add=True, diff --git a/custom_components/weishaupt_modbus/strings.json b/custom_components/weishaupt_modbus/strings.json index b1f5bae..eaa7d4c 100644 --- a/custom_components/weishaupt_modbus/strings.json +++ b/custom_components/weishaupt_modbus/strings.json @@ -22,7 +22,8 @@ "Name-Topic-Prefix": "Name Topic Prefix", "Port": "Port", "Prefix": "Prefix", - "enable-webif": "enable experimental webif?" + "enable-webif": "enable experimental webif?", + "Web-IF-Token": "4-Zeichen web-IF token, siehe readme" } } } @@ -996,6 +997,21 @@ "hz_vl_temp5": { "name": "{prefix}HZ_Vorlauftemperatur5" }, + "hz_vl_solltemp": { + "name": "{prefix}Vorlaufsolltemperatur" + }, + "hz_vl_solltemp2": { + "name": "{prefix}Vorlaufsolltemperatur2" + }, + "hz_vl_solltemp3": { + "name": "{prefix}Vorlaufsolltemperatur3" + }, + "hz_vl_solltemp4": { + "name": "{prefix}Vorlaufsolltemperatur4" + }, + "hz_vl_solltemp5": { + "name": "{prefix}Vorlaufsolltemperatur5" + }, "konf_ausg_h12": { "name": "{prefix}Konf. Ausgang H1.2", "state": { @@ -1324,19 +1340,7 @@ "name": "{prefix}Vorlauftemperatur präzise(Summenvorlauf(B7))" }, "vl_temp": { - "name": "{prefix}Vorlaufsolltemperatur" - }, - "vl_temp2": { - "name": "{prefix}Vorlaufsolltemperatur2" - }, - "vl_temp3": { - "name": "{prefix}Vorlaufsolltemperatur3" - }, - "vl_temp4": { - "name": "{prefix}Vorlaufsolltemperatur4" - }, - "vl_temp5": { - "name": "{prefix}Vorlaufsolltemperatur5" + "name": "{prefix}Vorlauftemperatur" }, "w2_konf": { "name": "{prefix}W2_Konfiguration", diff --git a/custom_components/weishaupt_modbus/translations/de.json b/custom_components/weishaupt_modbus/translations/de.json index 0c436dd..65f3855 100644 --- a/custom_components/weishaupt_modbus/translations/de.json +++ b/custom_components/weishaupt_modbus/translations/de.json @@ -22,7 +22,8 @@ "Name-Topic-Prefix": "Name Topic Prefix", "Port": "Port", "Prefix": "Prefix", - "enable-webif": "experimentelles WebIf aktivieren?" + "enable-webif": "experimentelles WebIf aktivieren?", + "Web-IF-Token": "4-Zeichen web-IF token, siehe readme" } } } @@ -996,6 +997,21 @@ "hz_vl_temp5": { "name": "{prefix}HZ_Vorlauftemperatur5" }, + "hz_vl_solltemp": { + "name": "{prefix}HZ_Vorlaufsolltemperatur" + }, + "hz_vl_solltemp2": { + "name": "{prefix}HZ_Vorlaufsolltemperatur2" + }, + "hz_vl_solltemp3": { + "name": "{prefix}HZ_Vorlaufsolltemperatur3" + }, + "hz_vl_solltemp4": { + "name": "{prefix}HZ_Vorlaufsolltemperatur4" + }, + "hz_vl_solltemp5": { + "name": "{prefix}HZ_Vorlaufsolltemperatur5" + }, "konf_ausg_h12": { "name": "{prefix}Konf. Ausgang H1.2", "state": { @@ -1324,19 +1340,7 @@ "name": "{prefix}Vorlauftemperatur präzise(Summenvorlauf(B7))" }, "vl_temp": { - "name": "{prefix}Vorlaufsolltemperatur" - }, - "vl_temp2": { - "name": "{prefix}Vorlaufsolltemperatur2" - }, - "vl_temp3": { - "name": "{prefix}Vorlaufsolltemperatur3" - }, - "vl_temp4": { - "name": "{prefix}Vorlaufsolltemperatur4" - }, - "vl_temp5": { - "name": "{prefix}Vorlaufsolltemperatur5" + "name": "{prefix}Vorlauftemperatur" }, "w2_konf": { "name": "{prefix}W2_Konfiguration", diff --git a/custom_components/weishaupt_modbus/translations/en.json b/custom_components/weishaupt_modbus/translations/en.json index 302825a..0b5d714 100644 --- a/custom_components/weishaupt_modbus/translations/en.json +++ b/custom_components/weishaupt_modbus/translations/en.json @@ -22,7 +22,8 @@ "Name-Topic-Prefix": "Name Topic Prefix", "Port": "Port", "Prefix": "Prefix", - "enable-webif": "enable experimental webif?" + "enable-webif": "enable experimental webif?", + "Web-IF-Token": "four letter web-IF token, see readme" } } } @@ -996,6 +997,21 @@ "hz_vl_temp5": { "name": "{prefix}Heat circuit feed temperature 5" }, + "hz_vl_solltemp": { + "name": "{prefix}Heat circuit feed setpoint temperature" + }, + "hz_vl_solltemp2": { + "name": "{prefix}Heat circuit feed setpoint temperature2" + }, + "hz_vl_solltemp3": { + "name": "{prefix}Heat circuit feed setpoint temperature3" + }, + "hz_vl_solltemp4": { + "name": "{prefix}Heat circuit feed setpoint temperature4" + }, + "hz_vl_solltemp5": { + "name": "{prefix}Heat circuit feed setpoint temperature5" + }, "konf_ausg_h12": { "name": "{prefix}Conf. Output H1.2", "state": { @@ -1324,19 +1340,7 @@ "name": "{prefix}Feed temperature präzise(Summenvorlauf(B7))" }, "vl_temp": { - "name": "{prefix}Feed setpoint temperature" - }, - "vl_temp2": { - "name": "{prefix}Feed setpoint temperature 2" - }, - "vl_temp3": { - "name": "{prefix}Feed setpoint temperature 3" - }, - "vl_temp4": { - "name": "{prefix}Feed setpoint temperature 4" - }, - "vl_temp5": { - "name": "{prefix}Feed setpoint temperature 5" + "name": "{prefix}Feed temperature" }, "w2_konf": { "name": "{prefix}W2_Configuration", diff --git a/custom_components/weishaupt_modbus/webif_object.py b/custom_components/weishaupt_modbus/webif_object.py index 8dfb79c..0343770 100644 --- a/custom_components/weishaupt_modbus/webif_object.py +++ b/custom_components/weishaupt_modbus/webif_object.py @@ -87,7 +87,13 @@ async def get_info(self) -> None: return None try: async with self._session.get( - url="/settings_export.html?stack=0C00000100000000008000F9AF010002000301,0C000C1900000000000000F9AF020003000401" + # token = F9AF + # token = 0F4C + url="/settings_export.html?stack=0C00000100000000008000" + + self._config_entry.data[CONF.WEBIF_TOKEN] + + "010002000301,0C000C1900000000000000" + + self._config_entry.data[CONF.WEBIF_TOKEN] + + "020003000401" ) as response: if response.status != 200: logging.debug(msg="Error: " & str(response.status))