From d4248e972ab382fce8c7fac3c8f4576f0ed6f72d Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Thu, 6 Jul 2023 18:02:02 +0200 Subject: [PATCH] add ocpp category data, enable/disable socket1, enable/disable network (ethernet and gprs) --- custom_components/alfen_wallbox/alfen.py | 2 +- .../alfen_wallbox/binary_sensor.py | 6 ++ custom_components/alfen_wallbox/number.py | 14 +++++ custom_components/alfen_wallbox/select.py | 63 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/custom_components/alfen_wallbox/alfen.py b/custom_components/alfen_wallbox/alfen.py index aa532a8..8aa2ffd 100644 --- a/custom_components/alfen_wallbox/alfen.py +++ b/custom_components/alfen_wallbox/alfen.py @@ -107,7 +107,7 @@ async def _do_update(self): await self.login() properties = [] - for i in ("generic", "generic2", "meter1", "states", "temp"): + for i in ("generic", "generic2", "meter1", "states", "temp", "ocpp"): nextRequest = True offset = 0 while (nextRequest): diff --git a/custom_components/alfen_wallbox/binary_sensor.py b/custom_components/alfen_wallbox/binary_sensor.py index 6eb0d24..b2eaa85 100644 --- a/custom_components/alfen_wallbox/binary_sensor.py +++ b/custom_components/alfen_wallbox/binary_sensor.py @@ -34,6 +34,12 @@ class AlfenBinaryDescription(BinarySensorEntityDescription, AlfenBinaryDescripti device_class=None, api_param="205B_0", ), + AlfenBinaryDescription( + key="lb_enable_max_imbalance_current", + name="LB Enable Max Imbalance Current", + device_class=None, + api_param="2174_1", + ), ) diff --git a/custom_components/alfen_wallbox/number.py b/custom_components/alfen_wallbox/number.py index ceafa37..be89eef 100644 --- a/custom_components/alfen_wallbox/number.py +++ b/custom_components/alfen_wallbox/number.py @@ -130,6 +130,20 @@ class AlfenNumberDescription(NumberEntityDescription, AlfenNumberDescriptionMixi unit_of_measurement=UnitOfPower.WATT, api_param="2061_2", ), + AlfenNumberDescription( + key="lb_max_imbalance_current", + name="Max. Imbalance Current between phases", + state=None, + icon="mdi:current-ac", + assumed_state=False, + device_class=NumberDeviceClass.POWER_FACTOR, + native_min_value=0, + native_max_value=10, + native_step=1, + mode=NumberMode.SLIDER, + unit_of_measurement=UnitOfElectricCurrent.AMPERE, + api_param="2174_0", + ), ) diff --git a/custom_components/alfen_wallbox/select.py b/custom_components/alfen_wallbox/select.py index 1f44854..9e2b0a5 100644 --- a/custom_components/alfen_wallbox/select.py +++ b/custom_components/alfen_wallbox/select.py @@ -96,6 +96,24 @@ class AlfenSelectDescription(SelectEntityDescription, AlfenSelectDescriptionMixi "Swedish": "sv_SE", } +ALLOWED_PHASE_DICT: Final[dict[str, int]] = { + "1 Phase": 1, + "3 Phases": 3, +} + +PRIORITIES_DICT: Final[dict[str, int]] = { + "Disable": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4 +} + +OPERATIVE_MODE_DICT: Final[dict[str, int]] = { + "Operative": 0, + "In-operative": 2, +} + ALFEN_SELECT_TYPES: Final[tuple[AlfenSelectDescription, ...]] = ( AlfenSelectDescription( key="lb_solar_charging_mode", @@ -163,6 +181,51 @@ class AlfenSelectDescription(SelectEntityDescription, AlfenSelectDescriptionMixi options_dict=DISPLAY_LANGUAGE_DICT, api_param="205D_0", ), + AlfenSelectDescription( + key="lb_max_allowed_phase_socket_1", + name="Load Balancing Max Allowed of Phases Socket 1", + icon="mdi:scale-balance", + options=list(ALLOWED_PHASE_DICT), + options_dict=ALLOWED_PHASE_DICT, + api_param="312E_0", + ), + # 2 Socket devices + # AlfenSelectDescription( + # key="lb_max_allowed_phase_socket_2", + # name="Load Balancing Max Allowed of Phases Socket 2", + # icon="mdi:balance-scale", + # options=list(ALLOWED_PHASE_DICT), + # options_dict=ALLOWED_PHASE_DICT, + # api_param="312F_0", + # ), + AlfenSelectDescription( + key="bo_network_1_connection_priority", + name="Backoffice Network 1 Connection Priority (Ethernet)", + icon="mdi:ethernet-cable", + options=list(PRIORITIES_DICT), + options_dict=PRIORITIES_DICT, + api_param="20F0_E", + ), + AlfenSelectDescription( + key="bo_network_2_connection_priority", + name="Backoffice Network 2 Connection Priority (GPRS)", + icon="mdi:antenna", + options=list(PRIORITIES_DICT), + options_dict=PRIORITIES_DICT, + api_param="20F1_E", + ), + AlfenSelectDescription( + key="socket_1_operation_mode", + name="Socket 1 Operation Mode", + icon="mdi:power-socket-eu", + options=list(OPERATIVE_MODE_DICT), + options_dict=OPERATIVE_MODE_DICT, + api_param="205F_0", + ), + + + + )