From f7d312ade3d632cdd4d3a7ea8e2ef9f0f5805930 Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Tue, 4 Jul 2023 23:09:40 +0200 Subject: [PATCH] change display language, car information, display light (auto dim, intensity) --- custom_components/alfen_wallbox/number.py | 14 ++++++ custom_components/alfen_wallbox/select.py | 20 +++++++++ custom_components/alfen_wallbox/sensor.py | 54 ++++++++++++++++++++++- custom_components/alfen_wallbox/switch.py | 5 +++ 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/custom_components/alfen_wallbox/number.py b/custom_components/alfen_wallbox/number.py index cf0227f..ceafa37 100644 --- a/custom_components/alfen_wallbox/number.py +++ b/custom_components/alfen_wallbox/number.py @@ -116,6 +116,20 @@ class AlfenNumberDescription(NumberEntityDescription, AlfenNumberDescriptionMixi unit_of_measurement=UnitOfPower.WATT, api_param="3280_3", ), + AlfenNumberDescription( + key="dp_light_intensity", + name="Display Light Intensity %", + state=None, + icon="mdi:lightbulb", + assumed_state=False, + device_class=NumberDeviceClass.POWER_FACTOR, + native_min_value=0, + native_max_value=100, + native_step=10, + mode=NumberMode.SLIDER, + unit_of_measurement=UnitOfPower.WATT, + api_param="2061_2", + ), ) diff --git a/custom_components/alfen_wallbox/select.py b/custom_components/alfen_wallbox/select.py index 0084bce..1f44854 100644 --- a/custom_components/alfen_wallbox/select.py +++ b/custom_components/alfen_wallbox/select.py @@ -83,6 +83,18 @@ class AlfenSelectDescription(SelectEntityDescription, AlfenSelectDescriptionMixi "Include Charging Ev": 1 } +DISPLAY_LANGUAGE_DICT: Final[dict[str, str]] = { + "English": "en_GB", + "Dutch": "nl_NL", + "German": "de_DE", + "French": "fr_FR", + "Italian": "it_IT", + "Norwegian": "no_NO", + "Finnish": "fi_FI", + "Portuguese": "pt_PT", + "Spanish": "es_ES", + "Swedish": "sv_SE", +} ALFEN_SELECT_TYPES: Final[tuple[AlfenSelectDescription, ...]] = ( AlfenSelectDescription( @@ -143,6 +155,14 @@ class AlfenSelectDescription(SelectEntityDescription, AlfenSelectDescriptionMixi options_dict=LOAD_BALANCE_RECEIVED_MEASUREMENTS_DICT, api_param="206F_0", ), + AlfenSelectDescription( + key="display_language", + name="Display Language", + icon="mdi:translate", + options=list(DISPLAY_LANGUAGE_DICT), + options_dict=DISPLAY_LANGUAGE_DICT, + api_param="205D_0", + ), ) diff --git a/custom_components/alfen_wallbox/sensor.py b/custom_components/alfen_wallbox/sensor.py index 324bd5c..91c0011 100644 --- a/custom_components/alfen_wallbox/sensor.py +++ b/custom_components/alfen_wallbox/sensor.py @@ -7,7 +7,7 @@ from .entity import AlfenEntity from homeassistant import const from homeassistant.config_entries import ConfigEntry -from homeassistant.const import UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, UnitOfTemperature +from homeassistant.const import PERCENTAGE, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfFrequency, UnitOfPower, UnitOfTemperature import datetime from homeassistant.core import HomeAssistant, callback @@ -484,6 +484,54 @@ class AlfenSensorDescription( unit=None, round_digits=None, ), + AlfenSensorDescription( + key="object_id", + name="Charger Number", + icon="mdi:information-outline", + api_param="2051_0", + unit=None, + round_digits=None, + ), + AlfenSensorDescription( + key="net_quality_hertz", + name="Net Quality Hz", + icon="mdi:information-outline", + api_param="2221_12", + unit=UnitOfFrequency.HERTZ, + round_digits=2, + ), + AlfenSensorDescription( + key="comm_car_cp_voltage_high", + name="Car CP Voltage High", + icon="mdi:lightning-bolt", + api_param="2511_0", + unit=UnitOfElectricPotential.VOLT, + round_digits=2, + ), + AlfenSensorDescription( + key="comm_car_cp_voltage_low", + name="Car CP Voltage Low", + icon="mdi:lightning-bolt", + api_param="2511_1", + unit=UnitOfElectricPotential.VOLT, + round_digits=2, + ), + AlfenSensorDescription( + key="comm_car_pp_resistance", + name="Car PP resistance", + icon="mdi:resistor", + api_param="2511_2", + unit="Ω", + round_digits=1, + ), + AlfenSensorDescription( + key="comm_car_pwm_duty_cycle", + name="Car PWM Duty Cycle", + icon="mdi:percent", + api_param="2511_3", + unit=PERCENTAGE, + round_digits=1, + ), ) @@ -724,6 +772,10 @@ def state(self): if self.entity_description.api_param == "2221_22": return round((prop["value"] / 1000), 2) + # Car PWM Duty cycle % + if self.entity_description.api_param == "2511_3": + return round((prop["value"] / 100), self.entity_description.round_digits) + # change milliseconds to HH:MM:SS if self.entity_description.api_param == "2060_0": return str(datetime.timedelta(milliseconds=prop['value'])).split('.', maxsplit=1)[0] diff --git a/custom_components/alfen_wallbox/switch.py b/custom_components/alfen_wallbox/switch.py index c66fdba..32033a2 100644 --- a/custom_components/alfen_wallbox/switch.py +++ b/custom_components/alfen_wallbox/switch.py @@ -33,6 +33,11 @@ class AlfenSwitchDescription(SwitchEntityDescription, AlfenSwitchDescriptionMixi name="Enable Phase Switching", api_param="2185_0", ), + AlfenSwitchDescription( + key="dp_light_auto_dim", + name="Display Light Auto Dim", + api_param="2061_1", + ), )