Skip to content

Commit

Permalink
Merge branch 'master' into fix/x1boost
Browse files Browse the repository at this point in the history
  • Loading branch information
kalosisz committed Feb 10, 2024
2 parents 6c22456 + 4783bc9 commit 93a57bb
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
isort --check-only --profile black .
- name: Lint with flake8
run: |
flake8 --ignore=E501 solax tests
flake8 --ignore=E501,E704 solax tests
- name: Lint with pylint
run: |
pylint -d 'C0111' solax tests
Expand Down
1 change: 1 addition & 0 deletions solax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for Solax inverter via local API."""

import asyncio
import logging

Expand Down
2 changes: 1 addition & 1 deletion solax/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ def schema(cls) -> vol.Schema:
return cls._schema

def __str__(self) -> str:
return f"{self.__class__.__name__} :: {self.http_client}"
return f"{self.__class__.__name__}::{self.http_client}"
1 change: 1 addition & 0 deletions solax/inverters/x1_mini_v34.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class X1MiniV34(Inverter):
[vol.Coerce(float)],
vol.Any(
vol.Length(min=69, max=69),
vol.Length(min=100, max=100),
vol.Length(min=200, max=200),
),
)
Expand Down
1 change: 1 addition & 0 deletions solax/units.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Units and different measurement types"""

from enum import Enum
from typing import NamedTuple, Union

Expand Down
6 changes: 2 additions & 4 deletions solax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class Packer(Protocol): # pragma: no cover
data into one raw value
"""

def __call__(self, *vals: float) -> float:
...
def __call__(self, *vals: float) -> float: ...


PackerBuilderResult = Tuple[Tuple[int, ...], Packer]
Expand All @@ -24,8 +23,7 @@ class PackerBuilder(Protocol): # pragma: no cover
raw values to be fed to the packer
"""

def __call__(self, *indexes: int) -> PackerBuilderResult:
...
def __call__(self, *indexes: int) -> PackerBuilderResult: ...


def __u16_packer(*values: float) -> float:
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
X1_HYBRID_G4_VALUES,
X1_MINI_VALUES,
X1_MINI_VALUES_V34,
X1_MINI_VALUES_V34_VER3,
X1_SMART_VALUES,
X1_VALUES,
X3_HYBRID_G4_VALUES,
Expand All @@ -28,6 +29,7 @@
X1_HYBRID_G3_RESPONSE,
X1_HYBRID_G4_RESPONSE,
X1_MINI_RESPONSE_V34,
X1_MINI_RESPONSE_V34_VER3,
X1_SMART_RESPONSE,
X3_HYBRID_G3_2X_MPPT_RESPONSE,
X3_HYBRID_G3_2X_MPPT_RESPONSE_V34,
Expand Down Expand Up @@ -238,6 +240,16 @@ def simple_http_fixture(httpserver):
headers=None,
data=None,
),
InverterUnderTest(
uri="/",
method="POST",
query_string=None,
response=X1_MINI_RESPONSE_V34_VER3,
inverter=inverter.X1MiniV34,
values=X1_MINI_VALUES_V34_VER3,
headers=None,
data="optType=ReadRealTimeData",
),
]


Expand Down
20 changes: 20 additions & 0 deletions tests/samples/expected_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,26 @@
"Inverter Temperature": 41,
}


X1_MINI_VALUES_V34_VER3 = {
"Network Voltage": 234.8,
"Output Current": 0.7,
"AC Power": 144.0,
"PV1 Voltage": 96.6,
"PV2 Voltage": 0.0,
"PV1 Current": 1.6,
"PV2 Current": 0.0,
"PV1 Power": 154.0,
"PV2 Power": 0.0,
"Grid Frequency": 49.94,
"Total Energy": 6.7,
"Today's Energy": 3.1,
"Total Feed-in Energy": 2.5,
"Total Consumption": 0.0,
"Power Now": 0.0,
"Inverter Temperature": 39.0,
}

X1_SMART_VALUES = {
"Network Voltage": 239.6,
"Output Current": 12.6,
Expand Down
109 changes: 109 additions & 0 deletions tests/samples/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,115 @@
"Information": [0.700, 4, "XXXXXXXXXXXXXX", 1, 1.19, 0.00, 1.32, 0.00, 0.00, 1],
}

X1_MINI_RESPONSE_V34_VER3 = {
"sn": "XXXXXXXXXX",
"ver": "3.006.04",
"type": 4,
"Data": [
2348,
7,
144,
966,
0,
16,
0,
154,
0,
4994,
2,
67,
0,
31,
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,
34,
0,
25,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
],
"Information": [1.500, 4, "XXXXXXXXXXXXXX", 8, 2.27, 0.00, 1.43, 0.00, 0.00, 1],
}

X1_SMART_RESPONSE = {
"sn": "XXXXXXX",
"ver": "2.033.20",
Expand Down
2 changes: 1 addition & 1 deletion verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo "Running mypy..."
mypy --exclude venv .

echo "Running flake8..."
flake8 --ignore=E501 solax tests
flake8 --ignore=E501,E704 solax tests

echo "Running pylint..."
pylint -d 'C0111' solax tests
Expand Down

0 comments on commit 93a57bb

Please sign in to comment.