Skip to content

Commit 1d92421

Browse files
authored
Add second DC port to Delta 3 Ultra Plus (#317)
The Delta 3 Ultra Plus exposes a second DC input plug that was not yet wired up. This change adds the corresponding DC port 2 input power and port state sensors, the derived solar input power, and a current limit control for second dc port.
1 parent 4af325e commit 1d92421

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

custom_components/ef_ble/eflib/devices/delta3_ultra_plus.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from collections.abc import Sequence
22

3-
from ..entity import controls
3+
from ..entity import controls, dynamic
44
from ..pb import pd335_sys_pb2
5-
from ..props import pb_field, repeated_pb_field_type
6-
from ..props.transforms import flow_is_on, out_power
5+
from ..props import computed_field, pb_field, repeated_pb_field_type
6+
from ..props.transforms import flow_is_on, out_power, pround
77
from . import delta3, delta3_ultra
8+
from ._delta3_base import DCPortState, _DcAmpSettingField, _DcChargingMaxField
89

910
pb = delta3.pb
1011

@@ -31,7 +32,29 @@ class Device(delta3_ultra.Device):
3132
ac_power_2_3 = _ACPortPower(4)
3233

3334
usbc3_output_power = pb_field(pb.pow_get_typec3, out_power)
34-
max_ac_charging_power = pb_field(pb.plug_in_info_ac_in_chg_hal_pow_max)
35+
36+
dc_charging_max_amps_2 = _DcAmpSettingField(
37+
pd335_sys_pb2.PV_CHG_VOL_SPEC_12V, pd335_sys_pb2.PV_PLUG_INDEX_2
38+
)
39+
dc_charging_current_max_2 = _DcChargingMaxField(pd335_sys_pb2.PV_CHG_VOL_SPEC_12V)
40+
41+
dc_port_2_input_power = pb_field(pb.pow_get_pv2, pround(2))
42+
dc_port_2_state = pb_field(pb.plug_in_info_pv2_type, DCPortState.from_value)
43+
44+
@computed_field
45+
def solar_input_power_2(self) -> float:
46+
if (
47+
self.dc_port_2_state is DCPortState.SOLAR
48+
and self.dc_port_2_input_power is not None
49+
):
50+
return round(self.dc_port_2_input_power, 2)
51+
return 0
52+
53+
@controls.current(dc_charging_max_amps_2, max=dynamic(dc_charging_current_max_2))
54+
async def set_dc_charging_amps_max_2(self, value: float) -> bool:
55+
return await self.set_dc_charging_amps_max(
56+
value, plug_index=pd335_sys_pb2.PV_PLUG_INDEX_2
57+
)
3558

3659
@controls.outlet(ac_ports_2)
3760
async def enable_ac_ports_2(self, enabled: bool):

0 commit comments

Comments
 (0)