Skip to content

Commit a7dd105

Browse files
committed
Heat Pump integrated
1 parent 8d7e5d3 commit a7dd105

2 files changed

Lines changed: 145 additions & 0 deletions

File tree

custom_components/enpal_webparser/const.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"Site Data",
3232
"IoTEdgeDevice",
3333
"PowerSensor",
34+
"Heatpump",
3435
]
3536

3637
DEFAULT_USE_WALLBOX_ADDON = False
@@ -239,5 +240,12 @@
239240
"inverter_system_state_stop_due_to_power_rationing": "mdi:flash-off",
240241
"inverter_system_state_shutdown": "mdi:power",
241242
"inverter_system_state_spot_check": "mdi:magnify",
243+
244+
# Heatpump
245+
"heatpump_domestichotwater_temperature": "mdi:water-thermometer",
246+
"heatpump_energy_consumption_total_lifetime": "mdi:lightning-bolt",
247+
"heatpump_operation_mode_midea": "mdi:heat-pump-outline",
248+
"heatpump_outside_temperature": "mdi:thermometer",
249+
"heatpump_power_consumption_total": "mdi:heat-pump",
242250
}
243251

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
"""
2+
Test for Heatpump sensor group support.
3+
"""
4+
from custom_components.enpal_webparser.utils import parse_enpal_html_sensors
5+
from custom_components.enpal_webparser.const import DEFAULT_GROUPS
6+
7+
8+
def test_heatpump_group_in_default_groups():
9+
"""Test that Heatpump is included in DEFAULT_GROUPS."""
10+
assert "Heatpump" in DEFAULT_GROUPS, "Heatpump should be in DEFAULT_GROUPS"
11+
print("✓ Heatpump is included in DEFAULT_GROUPS")
12+
13+
14+
def test_parse_heatpump_sensors():
15+
"""Test parsing of Heatpump sensor group from HTML."""
16+
# Minimal HTML with Heatpump group
17+
html = """
18+
<!DOCTYPE html>
19+
<html>
20+
<body>
21+
<div class="card mb-4">
22+
<div class="card-header"><h2>Heatpump</h2></div>
23+
<div class="card-body">
24+
<table class="table table-bordered table-striped">
25+
<thead>
26+
<tr>
27+
<th class="col-3">Sensor Name</th>
28+
<th class="col-3">Value</th>
29+
<th class="col-3">Timestamp</th>
30+
</tr>
31+
</thead>
32+
<tbody>
33+
<tr>
34+
<td>Heatpump.DomesticHotWater.Temperature</td>
35+
<td>51°C</td>
36+
<td>11/07/2025 18:05:16</td>
37+
</tr>
38+
<tr>
39+
<td>Heatpump.Energy.Consumption.Total.Lifetime</td>
40+
<td>1031kWh</td>
41+
<td>11/07/2025 18:05:16</td>
42+
</tr>
43+
<tr>
44+
<td>Heatpump.Operation.Mode.Midea</td>
45+
<td>3</td>
46+
<td>11/07/2025 18:05:16</td>
47+
</tr>
48+
<tr>
49+
<td>Heatpump.Outside.Temperature</td>
50+
<td>10°C</td>
51+
<td>11/07/2025 18:05:16</td>
52+
</tr>
53+
<tr>
54+
<td>Heatpump.Power.Consumption.Total</td>
55+
<td>0.02kW</td>
56+
<td>11/07/2025 18:05:16</td>
57+
</tr>
58+
</tbody>
59+
</table>
60+
</div>
61+
</div>
62+
</body>
63+
</html>
64+
"""
65+
66+
# Parse with Heatpump group
67+
sensors = parse_enpal_html_sensors(html, groups=["Heatpump"])
68+
69+
# Verify sensors were found
70+
assert len(sensors) > 0, "Should find Heatpump sensors"
71+
72+
# Check sensor names
73+
sensor_names = [s['name'] for s in sensors]
74+
assert any("DomesticHotWater" in name for name in sensor_names), "Should find DomesticHotWater Temperature sensor"
75+
assert any("Energy" in name and "Consumption" in name for name in sensor_names), "Should find Energy Consumption sensor"
76+
assert any("Operation" in name and "Mode" in name for name in sensor_names), "Should find Operation Mode sensor"
77+
assert any("Outside" in name and "Temperature" in name for name in sensor_names), "Should find Outside Temperature sensor"
78+
assert any("Power" in name and "Consumption" in name for name in sensor_names), "Should find Power Consumption sensor"
79+
80+
# Verify group is correct
81+
for sensor in sensors:
82+
assert sensor['group'] == 'Heatpump', f"Sensor {sensor['name']} should be in Heatpump group"
83+
84+
print(f"✓ Successfully parsed {len(sensors)} Heatpump sensors:")
85+
for sensor in sensors:
86+
print(f" - {sensor['name']} = {sensor['value']}")
87+
88+
89+
def test_heatpump_sensors_not_parsed_when_group_not_selected():
90+
"""Test that Heatpump sensors are ignored when group is not selected."""
91+
html = """
92+
<!DOCTYPE html>
93+
<html>
94+
<body>
95+
<div class="card mb-4">
96+
<div class="card-header"><h2>Heatpump</h2></div>
97+
<div class="card-body">
98+
<table class="table table-bordered table-striped">
99+
<tbody>
100+
<tr>
101+
<td>Heatpump.Power.Consumption.Total</td>
102+
<td>0.02kW</td>
103+
<td>11/07/2025 18:05:16</td>
104+
</tr>
105+
</tbody>
106+
</table>
107+
</div>
108+
</div>
109+
</body>
110+
</html>
111+
"""
112+
113+
# Parse WITHOUT Heatpump group
114+
sensors = parse_enpal_html_sensors(html, groups=["Battery", "Inverter"])
115+
116+
# Should find no sensors
117+
assert len(sensors) == 0, "Should not find Heatpump sensors when group not selected"
118+
print("✓ Heatpump sensors correctly ignored when group not selected")
119+
120+
121+
if __name__ == "__main__":
122+
# Run tests directly
123+
print("=" * 80)
124+
print("Testing Heatpump sensor group support")
125+
print("=" * 80)
126+
127+
try:
128+
test_heatpump_group_in_default_groups()
129+
test_parse_heatpump_sensors()
130+
test_heatpump_sensors_not_parsed_when_group_not_selected()
131+
print("\n" + "=" * 80)
132+
print("All Heatpump tests PASSED ✓")
133+
print("=" * 80)
134+
except AssertionError as e:
135+
print(f"\n✗ Test FAILED: {e}")
136+
import sys
137+
sys.exit(1)

0 commit comments

Comments
 (0)