Skip to content

Commit

Permalink
fix(x1_boost): totals are consecutive u16 ints (#129)
Browse files Browse the repository at this point in the history
* fix(x1_boost): totals are consecutive u16 ints

* modify test cases

from real world example

* old test cases

* formating

* utils format

* missing fixture
  • Loading branch information
kalosisz authored Feb 11, 2024
1 parent 4783bc9 commit ce0732f
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 4 deletions.
8 changes: 4 additions & 4 deletions solax/inverters/x1_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from solax import utils
from solax.inverter import Inverter, InverterHttpClient, Method, ResponseParser
from solax.units import Total, Units
from solax.utils import div10, div100, to_signed
from solax.utils import div10, div100, pack_u16, to_signed


class X1Boost(Inverter):
Expand Down Expand Up @@ -46,12 +46,12 @@ def response_decoder(cls):
"PV1 Power": (7, Units.W),
"PV2 Power": (8, Units.W),
"AC Frequency": (9, Units.HZ, div100),
"Total Generated Energy": (11, Total(Units.KWH), div10),
"Total Generated Energy": (pack_u16(11, 12), Total(Units.KWH), div10),
"Today's Generated Energy": (13, Total(Units.KWH), div10),
"Inverter Temperature": (39, Units.C),
"Exported Power": (48, Units.W, to_signed),
"Total Export Energy": (50, Total(Units.KWH), div100),
"Total Import Energy": (52, Total(Units.KWH), div100),
"Total Export Energy": (pack_u16(50, 51), Total(Units.KWH), div100),
"Total Import Energy": (pack_u16(52, 53), Total(Units.KWH), div100),
}

@classmethod
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tests.samples.expected_values import (
QVOLTHYBG33P_VALUES,
X1_BOOST_VALUES,
X1_BOOST_VALUES_OVERFLOWN,
X1_HYBRID_G4_VALUES,
X1_MINI_VALUES,
X1_MINI_VALUES_V34,
Expand All @@ -25,6 +26,7 @@
QVOLTHYBG33P_RESPONSE_V34,
X1_BOOST_AIR_MINI_RESPONSE,
X1_BOOST_RESPONSE,
X1_BOOST_RESPONSE_OVERFLOWN,
X1_HYBRID_G3_2X_MPPT_RESPONSE,
X1_HYBRID_G3_RESPONSE,
X1_HYBRID_G4_RESPONSE,
Expand Down Expand Up @@ -130,6 +132,16 @@ def simple_http_fixture(httpserver):
headers=X_FORWARDED_HEADER,
data=None,
),
InverterUnderTest(
uri="/",
method="POST",
query_string="optType=ReadRealTimeData",
response=X1_BOOST_RESPONSE_OVERFLOWN,
inverter=inverter.X1Boost,
values=X1_BOOST_VALUES_OVERFLOWN,
headers=X_FORWARDED_HEADER,
data=None,
),
InverterUnderTest(
uri="/",
method="POST",
Expand Down
19 changes: 19 additions & 0 deletions tests/samples/expected_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,25 @@
"Total Import Energy": 81.84,
}

X1_BOOST_VALUES_OVERFLOWN = {
"AC Voltage": 237.4,
"AC Output Current": 6.7,
"AC Output Power": 1581,
"PV1 Voltage": 397.3,
"PV2 Voltage": 233.8,
"PV1 Current": 4.1,
"PV2 Current": 5.7,
"PV1 Power": 1628,
"PV2 Power": 1336,
"AC Frequency": 49.96,
"Total Generated Energy": 14055.6,
"Today's Generated Energy": 1.3,
"Inverter Temperature": 36,
"Exported Power": 1444,
"Total Export Energy": 11348.18,
"Total Import Energy": 1850.05,
}

QVOLTHYBG33P_VALUES = {
"Network Voltage Phase 1": 221.4,
"Network Voltage Phase 2": 223.8,
Expand Down
209 changes: 209 additions & 0 deletions tests/samples/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,215 @@
"Information": [5.0, 4, "XXXXXXX", 1, 2.21, 0.00, 1.38, 0.00, 0.00, 1],
}

X1_BOOST_RESPONSE_OVERFLOWN = {
"sn": "XXXXXXX",
"ver": "2.034.06",
"type": 4,
"Data": [
2374,
67,
1581,
3973,
2338,
41,
57,
1628,
1336,
4996,
2,
9484,
2,
13,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
36,
0,
10636,
0,
0,
0,
0,
0,
0,
1444,
0,
20706,
17,
53933,
2,
0,
39,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
"Information": [3.680, 4, "XXXXXXX", 1, 2.06, 0, 1.27, 0, 0, 1],
}

X3_MIC_RESPONSE = {
"type": "X3-MIC",
"SN": "XXXXXXX",
Expand Down

0 comments on commit ce0732f

Please sign in to comment.