Skip to content

Commit

Permalink
X3 Hybrid G4: Attributes added (#136)
Browse files Browse the repository at this point in the history
* Update x3_hybrid_g4.py

add Battery mode

* Update x3_hybrid_g4.py

Battery Remaining Energy added

* Update x3_hybrid_g4.py

Feed-in und Consumed Energy total added

* Update x3_hybrid_g4.py

EPS Energy total / today added

* Update x3_hybrid_g4.py

PV Energy total added

* Update x3_hybrid_g4.py

Battery (Dis-)charge Energy total/today added

* Update x3_hybrid_g4.py

Load/Generator Power added

* Update x3_hybrid_g4.py

EPS Current and Voltage Units fixed

* Update x3_hybrid_g4.py

Battery Voltage and Current added

* Update x3_hybrid_g4.py

import twoway_div100

* Update x3_hybrid_g4.py

rename Feed-in -> Grid Power

* using black for formatting

* applied formatting with black v24.2.0 (debian testing)

* commented duplicate 'Battery Voltage' in field 39. This is twice in the data. Field 169, 170 probably better than 39.

* Update x3_hybrid_g4.py

refactor battery_modes to _decode_battery_mode

* Update x3_hybrid_g4.py

using the right comment method (hopefully)

* Update expected_values.py

added test values for X3_HYBRID_G4

* Update expected_values.py

added missing comma

* Update expected_values.py

removed duplicate value

* Update expected_values.py

added test value 'PV Energy total'

* Update expected_values.py

adjust expectred values with example response
  • Loading branch information
SebStaeubert authored Mar 7, 2024
1 parent 878bf5b commit 2e2cdd2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
53 changes: 45 additions & 8 deletions solax/inverters/x3_hybrid_g4.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

from solax.inverter import Inverter
from solax.units import Total, Units
from solax.utils import div10, div100, pack_u16, to_signed, to_signed32, twoway_div10
from solax.utils import (
div10,
div100,
pack_u16,
to_signed,
to_signed32,
twoway_div10,
twoway_div100,
)


class X3HybridG4(Inverter):
Expand Down Expand Up @@ -47,6 +55,15 @@ def _decode_run_mode(cls, run_mode):
10: "Standby",
}.get(run_mode)

@classmethod
def _decode_battery_mode(cls, battery_mode):
return {
0: "Self Use Mode",
1: "Force Time Use",
2: "Back Up Mode",
3: "Feed-in Priority",
}.get(battery_mode)

@classmethod
def response_decoder(cls):
return {
Expand All @@ -70,24 +87,44 @@ def response_decoder(cls):
"Grid 3 Frequency": (18, Units.HZ, div100),
"Run mode": (19, Units.NONE),
"Run mode text": (19, Units.NONE, X3HybridG4._decode_run_mode),
"EPS 1 Voltage": (23, Units.W, div10),
"EPS 2 Voltage": (24, Units.W, div10),
"EPS 3 Voltage": (25, Units.W, div10),
"EPS 1 Current": (26, Units.W, twoway_div10),
"EPS 2 Current": (27, Units.W, twoway_div10),
"EPS 3 Current": (28, Units.W, twoway_div10),
"EPS 1 Voltage": (23, Units.V, div10),
"EPS 2 Voltage": (24, Units.V, div10),
"EPS 3 Voltage": (25, Units.V, div10),
"EPS 1 Current": (26, Units.A, twoway_div10),
"EPS 2 Current": (27, Units.A, twoway_div10),
"EPS 3 Current": (28, Units.A, twoway_div10),
"EPS 1 Power": (29, Units.W, to_signed),
"EPS 2 Power": (30, Units.W, to_signed),
"EPS 3 Power": (31, Units.W, to_signed),
"Feed-in Power ": (pack_u16(34, 35), Units.W, to_signed32),
"Grid Power ": (pack_u16(34, 35), Units.W, to_signed32),
# 'Battery Voltage' is twice in the json response and covered with 169, 170 below.
# "Battery Voltage": (39, Units.V, div100),
"Battery Current": (40, Units.A, twoway_div100),
"Battery Power": (41, Units.W, to_signed),
"Load/Generator Power": (47, Units.W, to_signed),
"Radiator Temperature": (54, Units.C, to_signed),
"Yield total": (pack_u16(68, 69), Total(Units.KWH), div10),
"Yield today": (70, Units.KWH, div10),
"Battery Discharge Energy total": (
pack_u16(74, 75),
Total(Units.KWH),
div10,
),
"Battery Charge Energy total": (pack_u16(76, 77), Total(Units.KWH), div10),
"Battery Discharge Energy today": (78, Units.KWH, div10),
"Battery Charge Energy today": (79, Units.KWH, div10),
"PV Energy total": (pack_u16(80, 81), Total(Units.KWH), div10),
"EPS Energy total": (pack_u16(83, 84), Total(Units.KWH), div10),
"EPS Energy today": (85, Units.KWH, div10),
"Feed-in Energy": (pack_u16(86, 87), Total(Units.KWH), div100),
"Consumed Energy": (pack_u16(88, 89), Total(Units.KWH), div100),
"Feed-in Energy total": (pack_u16(90, 91), Total(Units.KWH), div100),
"Consumed Energy total": (pack_u16(92, 93), Total(Units.KWH), div100),
"Battery Remaining Capacity": (103, Units.PERCENT),
"Battery Temperature": (105, Units.C, to_signed),
"Battery Remaining Energy": (106, Units.KWH, div10),
"Battery mode": (168, Units.NONE),
"Battery mode text": (168, Units.NONE, X3HybridG4._decode_battery_mode),
"Battery Voltage": (pack_u16(169, 170), Units.V, div100),
}

Expand Down
16 changes: 15 additions & 1 deletion tests/samples/expected_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,29 @@
"EPS 1 Power": 0.0,
"EPS 2 Power": 0.0,
"EPS 3 Power": 0.0,
"Feed-in Power ": -152.0,
"Grid Power ": -152.0,
"Battery Current": 0.0,
"Battery Power": 0.0,
"Load/Generator Power": 342.0,
"Radiator Temperature": 23.0,
"Yield total": 4.4,
"Yield today": 0.1,
"Battery Discharge Energy total": 2.4,
"Battery Charge Energy total": 1.0,
"Battery Discharge Energy today": 0.0,
"Battery Charge Energy today": 0.0,
"PV Energy total": 3.4,
"EPS Energy total": 0.0,
"EPS Energy today": 0.0,
"Feed-in Energy": 0.0,
"Consumed Energy": 20.09,
"Feed-in Energy total": 0.0,
"Consumed Energy total": 2.09,
"Battery Remaining Capacity": 30.0,
"Battery Temperature": 22.0,
"Battery Remaining Energy": 3.3,
"Battery mode": 0.0,
"Battery mode text": "Self Use Mode",
"Battery Voltage": 234.6,
}

Expand Down

0 comments on commit 2e2cdd2

Please sign in to comment.