From b37a51a28ce4f579e3e1dd375fae06e8951df7b6 Mon Sep 17 00:00:00 2001 From: jontofront <37038426+jontofront@users.noreply.github.com> Date: Wed, 13 Dec 2023 07:16:53 +0000 Subject: [PATCH] testing translation --- custom_components/econet300/const.py | 18 ++++++++++++------ custom_components/econet300/sensor.py | 3 ++- custom_components/econet300/strings.json | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/custom_components/econet300/const.py b/custom_components/econet300/const.py index 8435884..165730e 100644 --- a/custom_components/econet300/const.py +++ b/custom_components/econet300/const.py @@ -106,7 +106,7 @@ "1031": "mixerTemp1", "1287": "mixerSetTemp1", "1792": "mode", - "1794": "boiler_power", + "1794": "boilerPower", "1795": "fanPower", "1280": "tempCOSet", } @@ -132,14 +132,13 @@ "mixerTemp1": UnitOfTemperature.CELSIUS, "tempBack": UnitOfTemperature.CELSIUS, "tempCWU": UnitOfTemperature.CELSIUS, - "boiler_power": PERCENTAGE, + "boilerPower": PERCENTAGE, "fuelLevel": PERCENTAGE, "tempUpperBuffer": UnitOfTemperature.CELSIUS, "tempLowerBuffer": UnitOfTemperature.CELSIUS, "signal": SIGNAL_STRENGTH_DECIBELS_MILLIWATT, "quality": PERCENTAGE, "valveMixer1": PERCENTAGE, - } REG_PARAM_STATE_CLASS = { @@ -168,7 +167,7 @@ "tempExternalSensor": SensorDeviceClass.TEMPERATURE, "tempCO": SensorDeviceClass.TEMPERATURE, "tempCOSet": SensorDeviceClass.TEMPERATURE, - "boiler_power": SensorDeviceClass.POWER_FACTOR, + "boilerPower": SensorDeviceClass.POWER_FACTOR, "fanPower": SensorDeviceClass.POWER_FACTOR, "tempFlueGas": SensorDeviceClass.TEMPERATURE, "mixerSetTemp1": SensorDeviceClass.TEMPERATURE, @@ -197,7 +196,7 @@ "tempExternalSensor": 1, "fuelLevel": 0, "lambdaLevel": 1, - "lambdaSet":1, + "lambdaSet": 1, "tempCO": 1, "tempCOSet": 0, "fanPower": 0, @@ -208,7 +207,7 @@ "tempLowerBuffer": 1, "tempCWU": 1, "tempFlueGas": 1, - } +} REG_PARAM_VALUE_PROCESSOR = { "mode": lambda x: OPERATION_MODE_NAMES.get(x, "Unknown"), @@ -239,3 +238,10 @@ "tempUpperBuffer": False, "tempLowerBuffer": False, } + +REG_PARAM_TRANSLATION_KEY = { + "boilerPower": "boiler_power", + "tempExternalSensor": "temp_external_sensor", + "tempFeeder": "temp_feeder", + "fuelLevel": "fuel_fevel", +} diff --git a/custom_components/econet300/sensor.py b/custom_components/econet300/sensor.py index d663955..427f898 100644 --- a/custom_components/econet300/sensor.py +++ b/custom_components/econet300/sensor.py @@ -18,6 +18,7 @@ DOMAIN, REG_PARAM_DEVICE_CLASS, REG_PARAM_STATE_CLASS, + REG_PARAM_TRANSLATION_KEY, SERVICE_COORDINATOR, SERVICE_API, REG_PARAM_MAP, @@ -79,7 +80,7 @@ def create_entity_description(key: str): return EconetSensorEntityDescription( key=key, name=map_key, - translation_key=camel_to_snake(map_key), + translation_key=REG_PARAM_TRANSLATION_KEY.get(map_key, None), native_unit_of_measurement=REG_PARAM_UNIT.get(map_key, None), state_class=REG_PARAM_STATE_CLASS.get(map_key, None), device_class=REG_PARAM_DEVICE_CLASS.get(map_key, None), diff --git a/custom_components/econet300/strings.json b/custom_components/econet300/strings.json index c16b396..44f654f 100644 --- a/custom_components/econet300/strings.json +++ b/custom_components/econet300/strings.json @@ -29,7 +29,7 @@ "lambda_set": { "name": "lambda Set" }, "lambda_level": { "name": "lambda Level" }, "signal": { "name": "signaliukas" }, - "temp_co": { "name": "tempCOukas" }, + "temp_c": { "name": "tempCOukas" }, "temp_cwu": { "name": "tempCWUiukas" }, "temp_upper_buffer": { "name": "tempUpper Buffer" }, "temp_lower_buffer": { "name": "tempLower Buffer" },