Skip to content

Commit 16a4c06

Browse files
committed
Add total PV Power sensor (sum of PV1-PV4)
1 parent 7be3c89 commit 16a4c06

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎custom_components/deye_modbus/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
_REGISTER_FIELDS = {
2929
"name", "unique_id", "register_type", "address", "count", "scale", "offset",
3030
"unit_of_measurement", "device_class", "state_class", "signed", "word_order",
31-
"options", "mask", "icon", "enabled_default", "precision",
31+
"options", "mask", "icon", "enabled_default", "precision", "compute", "sources",
3232
}
3333

3434

@@ -41,6 +41,9 @@ def _auto_inject_readbacks(sensors: list[dict], controls: list[dict]) -> tuple[l
4141
"""Give every writable control a hidden holding sensor to read its state back."""
4242
for s in sensors:
4343
s["unique_id"] = _ensure_uid(s.get("unique_id"), "s", int(s.get("address", 0)))
44+
if s.get("sources"):
45+
s.setdefault("compute", "sum")
46+
s["register_type"] = "computed"
4447
sensor_uids = {s["unique_id"] for s in sensors}
4548
for c in controls:
4649
addr = c.get("address", c.get("base_address", 0))

‎custom_components/deye_modbus/maps/sun_3ph_hybrid.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ sensors:
158158
state_class: measurement
159159
enabled_default: false
160160

161+
# Total PV power: the 3-phase protocol has no single register for this, so it
162+
# is the sum of the four MPPT power registers (computed, not read).
163+
- name: PV Power
164+
unique_id: pv_power
165+
compute: sum
166+
sources: [pv1_power, pv2_power, pv3_power, pv4_power]
167+
unit_of_measurement: W
168+
device_class: power
169+
state_class: measurement
170+
icon: mdi:solar-power
171+
161172
# ---------------------------------------------------------------- battery
162173
- name: Battery SOC
163174
unique_id: battery_soc

0 commit comments

Comments
 (0)