Skip to content

Commit

Permalink
Merge pull request egnerfl#11 from leeyuentuen/more_info
Browse files Browse the repository at this point in the history
change display language, car information, display light (auto dim, intensity)
  • Loading branch information
leeyuentuen authored Jul 5, 2023
2 parents 9a86f08 + f7d312a commit 88f63e0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
14 changes: 14 additions & 0 deletions custom_components/alfen_wallbox/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
)


Expand Down
20 changes: 20 additions & 0 deletions custom_components/alfen_wallbox/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
),

)

Expand Down
54 changes: 53 additions & 1 deletion custom_components/alfen_wallbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
),
)


Expand Down Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions custom_components/alfen_wallbox/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
)


Expand Down

0 comments on commit 88f63e0

Please sign in to comment.