Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/predbat/solis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,40 @@ async def publish_entities(self):
app="solis"
)

# PV Voltage (from detail)
entity_id = f"sensor.{prefix}_solis_{inverter_sn_lower}_pv1_voltage"
pv_voltage = detail.get("uPv1")
pv_voltage_unit = detail.get("pvVoltageStr", "V")
self.dashboard_item(
entity_id,
state=pv_voltage,
attributes={
"friendly_name": f"Solis {inverter_name} PV1 Voltage",
"unit_of_measurement": pv_voltage_unit,
"device_class": "voltage",
"state_class": "measurement",
"icon": "mdi:lightning-bolt",
},
app="solis"
)

# PV Voltage (from detail)
entity_id = f"sensor.{prefix}_solis_{inverter_sn_lower}_pv2_voltage"
pv_voltage = detail.get("uPv2")
pv_voltage_unit = detail.get("pvVoltageStr", "V")
self.dashboard_item(
entity_id,
state=pv_voltage,
attributes={
"friendly_name": f"Solis {inverter_name} PV2 Voltage",
"unit_of_measurement": pv_voltage_unit,
"device_class": "voltage",
"state_class": "measurement",
"icon": "mdi:lightning-bolt",
},
app="solis"
)

# Product Model
entity_id = f"sensor.{prefix}_solis_{inverter_sn_lower}_product_model"
product_model = detail.get("productModel")
Expand Down
14 changes: 14 additions & 0 deletions apps/predbat/tests/test_solis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,9 @@ async def test_publish_entities():
"familyLoadPowerStr": "kW",
"psum": -1.2,
"psumStr": "kW",
"uPv1": 285.3,
"uPv2": 272.1,
"pvVoltageStr": "V",
}

# Setup cached CID values
Expand Down Expand Up @@ -1815,6 +1818,17 @@ async def test_publish_entities():
discharged_today = api.dashboard_items[f"sensor.{prefix}_solis_{inverter_sn_lower}_battery_energy_discharged_today"]
assert discharged_today["state"] == 3.8, f"Battery energy discharged today should be 3.8, got {discharged_today['state']}"

# Check PV voltage sensors
assert f"sensor.{prefix}_solis_{inverter_sn_lower}_pv1_voltage" in api.dashboard_items, "PV1 voltage should be published"
pv1_voltage = api.dashboard_items[f"sensor.{prefix}_solis_{inverter_sn_lower}_pv1_voltage"]
assert pv1_voltage["state"] == 285.3, f"PV1 voltage should be 285.3, got {pv1_voltage['state']}"
assert pv1_voltage["attributes"]["unit_of_measurement"] == "V", "PV1 voltage should have V unit"

assert f"sensor.{prefix}_solis_{inverter_sn_lower}_pv2_voltage" in api.dashboard_items, "PV2 voltage should be published"
pv2_voltage = api.dashboard_items[f"sensor.{prefix}_solis_{inverter_sn_lower}_pv2_voltage"]
assert pv2_voltage["state"] == 272.1, f"PV2 voltage should be 272.1, got {pv2_voltage['state']}"
assert pv2_voltage["attributes"]["unit_of_measurement"] == "V", "PV2 voltage should have V unit"

print(f"PASSED: publish_entities created {len(api.dashboard_items)} entities correctly")
return False

Expand Down