solax-py-library 1.0.0.24__py3-none-any.whl → 1.0.0.2502__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. solax_py_library/__init__.py +1 -1
  2. solax_py_library/device/constant/inverter_model_info.py +312 -312
  3. solax_py_library/device/core/interver/__init__.py +36 -36
  4. solax_py_library/device/core/interver/base.py +215 -215
  5. solax_py_library/device/types/inverter_config.py +41 -41
  6. solax_py_library/device/types/modbus_point.py +30 -30
  7. solax_py_library/exception.py +10 -10
  8. solax_py_library/smart_scene/__init__.py +0 -0
  9. solax_py_library/smart_scene/constant/__init__.py +0 -0
  10. solax_py_library/smart_scene/constant/message_entry.py +338 -0
  11. solax_py_library/smart_scene/core/__init__.py +0 -0
  12. solax_py_library/smart_scene/core/action/__init__.py +0 -0
  13. solax_py_library/smart_scene/core/condition/__init__.py +0 -0
  14. solax_py_library/smart_scene/core/condition/base.py +12 -0
  15. solax_py_library/smart_scene/core/condition/cabinet_condition.py +104 -0
  16. solax_py_library/smart_scene/core/condition/date_condition.py +26 -0
  17. solax_py_library/smart_scene/core/condition/price_condition.py +105 -0
  18. solax_py_library/smart_scene/core/condition/system_condition.py +41 -0
  19. solax_py_library/smart_scene/core/condition/weather_condition.py +67 -0
  20. solax_py_library/smart_scene/exceptions/__init__.py +0 -0
  21. solax_py_library/smart_scene/exceptions/price.py +5 -0
  22. solax_py_library/smart_scene/exceptions/smart_scene.py +81 -0
  23. solax_py_library/smart_scene/exceptions/weather.py +5 -0
  24. solax_py_library/smart_scene/types/__init__.py +0 -0
  25. solax_py_library/smart_scene/types/action.py +156 -0
  26. solax_py_library/smart_scene/types/condition.py +293 -0
  27. solax_py_library/smart_scene/types/smart_scene_content.py +173 -0
  28. solax_py_library/snap_shot/__init__.py +3 -3
  29. solax_py_library/snap_shot/constant/__init__.py +5 -5
  30. solax_py_library/snap_shot/constant/crc_table.py +258 -258
  31. solax_py_library/snap_shot/core/__init__.py +9 -9
  32. solax_py_library/snap_shot/core/base_modbus.py +14 -14
  33. solax_py_library/snap_shot/exceptions/__init__.py +3 -3
  34. solax_py_library/snap_shot/exceptions/snap_shot.py +9 -9
  35. solax_py_library/snap_shot/types/__init__.py +15 -15
  36. solax_py_library/snap_shot/types/address.py +39 -39
  37. solax_py_library/test/__init__.py +0 -0
  38. solax_py_library/test/test_utils/__init__.py +0 -0
  39. solax_py_library/test/test_utils/test_cloud_client.py +14 -0
  40. solax_py_library/upload/__init__.py +3 -3
  41. solax_py_library/upload/api/__init__.py +3 -3
  42. solax_py_library/upload/api/service.py +24 -24
  43. solax_py_library/upload/core/__init__.py +3 -3
  44. solax_py_library/upload/core/data_adapter/__init__.py +5 -5
  45. solax_py_library/upload/core/data_adapter/base.py +9 -9
  46. solax_py_library/upload/core/data_adapter/csv.py +26 -26
  47. solax_py_library/upload/core/upload_service/__init__.py +15 -15
  48. solax_py_library/upload/core/upload_service/base.py +43 -43
  49. solax_py_library/upload/exceptions/__init__.py +8 -8
  50. solax_py_library/upload/exceptions/upload_error.py +21 -21
  51. solax_py_library/upload/test/test_ftp.py +113 -113
  52. solax_py_library/upload/types/__init__.py +11 -11
  53. solax_py_library/upload/types/client.py +19 -19
  54. solax_py_library/upload/types/ftp.py +37 -37
  55. solax_py_library/utils/cloud_client.py +210 -0
  56. solax_py_library/utils/common.py +38 -38
  57. solax_py_library/utils/struct_util.py +30 -30
  58. solax_py_library/utils/time_util.py +5 -0
  59. {solax_py_library-1.0.0.24.dist-info → solax_py_library-1.0.0.2502.dist-info}/METADATA +2 -1
  60. solax_py_library-1.0.0.2502.dist-info/RECORD +71 -0
  61. solax_py_library-1.0.0.24.dist-info/RECORD +0 -46
  62. {solax_py_library-1.0.0.24.dist-info → solax_py_library-1.0.0.2502.dist-info}/WHEEL +0 -0
@@ -1,9 +1,9 @@
1
- from .base_modbus import ModbusClientBase
2
- from .snap_shot import SnapshotCore
3
- from .parser import Parser
4
-
5
- __all__ = [
6
- "ModbusClientBase",
7
- "SnapshotCore",
8
- "Parser",
9
- ]
1
+ from .base_modbus import ModbusClientBase
2
+ from .snap_shot import SnapshotCore
3
+ from .parser import Parser
4
+
5
+ __all__ = [
6
+ "ModbusClientBase",
7
+ "SnapshotCore",
8
+ "Parser",
9
+ ]
@@ -1,14 +1,14 @@
1
- from abc import ABC, abstractmethod
2
- from typing import List
3
-
4
-
5
- class ModbusClientBase(ABC):
6
- @abstractmethod
7
- async def read_registers(self, address: int, quantity_of_x: int) -> List[int]:
8
- """抽象读取寄存器方法"""
9
- pass
10
-
11
- @abstractmethod
12
- async def write_registers(self, address: int, values: List[int]) -> bool:
13
- """抽象写入寄存器方法"""
14
- pass
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+
5
+ class ModbusClientBase(ABC):
6
+ @abstractmethod
7
+ async def read_registers(self, address: int, quantity_of_x: int) -> List[int]:
8
+ """抽象读取寄存器方法"""
9
+ pass
10
+
11
+ @abstractmethod
12
+ async def write_registers(self, address: int, values: List[int]) -> bool:
13
+ """抽象写入寄存器方法"""
14
+ pass
@@ -1,3 +1,3 @@
1
- from .snap_shot import SnapshotError, SnapshotTimeoutError
2
-
3
- __all__ = ["SnapshotError", "SnapshotTimeoutError"]
1
+ from .snap_shot import SnapshotError, SnapshotTimeoutError
2
+
3
+ __all__ = ["SnapshotError", "SnapshotTimeoutError"]
@@ -1,9 +1,9 @@
1
- from solax_py_library.exception import SolaxBaseError
2
-
3
-
4
- class SnapshotError(SolaxBaseError):
5
- ...
6
-
7
-
8
- class SnapshotTimeoutError(SnapshotError):
9
- ...
1
+ from solax_py_library.exception import SolaxBaseError
2
+
3
+
4
+ class SnapshotError(SolaxBaseError):
5
+ ...
6
+
7
+
8
+ class SnapshotTimeoutError(SnapshotError):
9
+ ...
@@ -1,15 +1,15 @@
1
- from .address import (
2
- SnapshotMCUSource,
3
- SnapshotRegisterAddress,
4
- SnapshotStartResult,
5
- SnapshotExportDevice,
6
- CommandType,
7
- )
8
-
9
- __all__ = [
10
- "SnapshotMCUSource",
11
- "SnapshotRegisterAddress",
12
- "SnapshotStartResult",
13
- "SnapshotExportDevice",
14
- "CommandType",
15
- ]
1
+ from .address import (
2
+ SnapshotMCUSource,
3
+ SnapshotRegisterAddress,
4
+ SnapshotStartResult,
5
+ SnapshotExportDevice,
6
+ CommandType,
7
+ )
8
+
9
+ __all__ = [
10
+ "SnapshotMCUSource",
11
+ "SnapshotRegisterAddress",
12
+ "SnapshotStartResult",
13
+ "SnapshotExportDevice",
14
+ "CommandType",
15
+ ]
@@ -1,39 +1,39 @@
1
- from enum import IntEnum
2
-
3
-
4
- class SnapshotMCUSource(IntEnum):
5
- MCU_SOURCE_MDSP = 0
6
- MCU_SOURCE_SDSP = 1
7
-
8
-
9
- class SnapshotExportDevice(IntEnum):
10
- EXPORT_DEVICE_UART = 0
11
- EXPORT_DEVICE_USB = 1
12
-
13
-
14
- class SnapshotStartResult(IntEnum):
15
- SNAPSHOT_START_START = 0xAAAA
16
- SNAPSHOT_START_SUCCESS = 0xA5A5
17
- SNAPSHOT_START_FAILED = 0x5A5A
18
- SNAPSHOT_START_STOP = 0xBBBB
19
-
20
-
21
- class SnapshotRegisterAddress(IntEnum):
22
- SNAPSHOT_REGISTERADDRESS_MCUSOURCE = 0x4011
23
- SNAPSHOT_REGISTERADDRESS_EXPORTDEVICE = 0x4012
24
- SNAPSHOT_REGISTERADDRESS_START = 0x4013
25
- SNAPSHOT_REGISTERADDRESS_TOTALNUMBER = 0x4070
26
- SNAPSHOT_REGISTERADDRESS_SNAPSHOTINDEX = 0x4071
27
- SNAPSHOT_REGISTERADDRESS_PACKDATASTATUS = 0x4072
28
- SNAPSHOT_REGISTERADDRESS_DATASIZE = 0x4073
29
- SNAPSHOT_REGISTERADDRESS_CHANNELNUMBER = 0x4074
30
- SNAPSHOT_REGISTERADDRESS_CHANNELDATASIZE = 0x4075
31
- SNAPSHOT_REGISTERADDRESS_PACKINDEX = 0x407F
32
- SNAPSHOT_REGISTERADDRESS_PACKDATA = 0x4080
33
-
34
-
35
- class CommandType(IntEnum):
36
- ACK = 0x80 # 接收应答
37
- TOTAL_PACKETS = 0x81 # 上报总包数
38
- DATA_PACKET = 0x82 # 具体分包数据
39
- ERROR = 0x83 # 报错应答
1
+ from enum import IntEnum
2
+
3
+
4
+ class SnapshotMCUSource(IntEnum):
5
+ MCU_SOURCE_MDSP = 0
6
+ MCU_SOURCE_SDSP = 1
7
+
8
+
9
+ class SnapshotExportDevice(IntEnum):
10
+ EXPORT_DEVICE_UART = 0
11
+ EXPORT_DEVICE_USB = 1
12
+
13
+
14
+ class SnapshotStartResult(IntEnum):
15
+ SNAPSHOT_START_START = 0xAAAA
16
+ SNAPSHOT_START_SUCCESS = 0xA5A5
17
+ SNAPSHOT_START_FAILED = 0x5A5A
18
+ SNAPSHOT_START_STOP = 0xBBBB
19
+
20
+
21
+ class SnapshotRegisterAddress(IntEnum):
22
+ SNAPSHOT_REGISTERADDRESS_MCUSOURCE = 0x4011
23
+ SNAPSHOT_REGISTERADDRESS_EXPORTDEVICE = 0x4012
24
+ SNAPSHOT_REGISTERADDRESS_START = 0x4013
25
+ SNAPSHOT_REGISTERADDRESS_TOTALNUMBER = 0x4070
26
+ SNAPSHOT_REGISTERADDRESS_SNAPSHOTINDEX = 0x4071
27
+ SNAPSHOT_REGISTERADDRESS_PACKDATASTATUS = 0x4072
28
+ SNAPSHOT_REGISTERADDRESS_DATASIZE = 0x4073
29
+ SNAPSHOT_REGISTERADDRESS_CHANNELNUMBER = 0x4074
30
+ SNAPSHOT_REGISTERADDRESS_CHANNELDATASIZE = 0x4075
31
+ SNAPSHOT_REGISTERADDRESS_PACKINDEX = 0x407F
32
+ SNAPSHOT_REGISTERADDRESS_PACKDATA = 0x4080
33
+
34
+
35
+ class CommandType(IntEnum):
36
+ ACK = 0x80 # 接收应答
37
+ TOTAL_PACKETS = 0x81 # 上报总包数
38
+ DATA_PACKET = 0x82 # 具体分包数据
39
+ ERROR = 0x83 # 报错应答
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ from unittest import TestCase
2
+
3
+ from solax_py_library.utils.cloud_client import CloudClient
4
+
5
+
6
+ class TestCloudClient(TestCase):
7
+ def test_get_weather(self):
8
+ client = CloudClient()
9
+ ret = client.get_weather_data_from_cloud(
10
+ "https://aliyun-sit.solaxtech.net:5050",
11
+ "XMG11A011L",
12
+ "b080a22827484db6bd509d496f9df90b"
13
+ )
14
+ print(ret)
@@ -1,3 +1,3 @@
1
- from . import api, types, core, exceptions
2
-
3
- __all__ = ["api", "core", "exceptions", "types"]
1
+ from . import api, types, core, exceptions
2
+
3
+ __all__ = ["api", "core", "exceptions", "types"]
@@ -1,3 +1,3 @@
1
- from .service import upload, upload_service
2
-
3
- __all__ = ["upload", "upload_service"]
1
+ from .service import upload, upload_service
2
+
3
+ __all__ = ["upload", "upload_service"]
@@ -1,24 +1,24 @@
1
- from typing import Dict, Any
2
-
3
- from solax_py_library.upload.core.upload_service import upload_service_map
4
- from solax_py_library.exception import SolaxBaseError
5
- from solax_py_library.upload.types.client import UploadType, UploadData
6
-
7
-
8
- def upload_service(upload_type: UploadType, configuration: Dict[str, Any]):
9
- """
10
- upload_type: 上传类型。
11
- configuration: 配置信息
12
- """
13
- upload_class = upload_service_map.get(upload_type)
14
- if not upload_class:
15
- raise SolaxBaseError
16
- return upload_class(**configuration)
17
-
18
-
19
- async def upload(
20
- upload_type: UploadType, configuration: Dict[str, Any], upload_data: UploadData
21
- ):
22
- service = upload_service(upload_type, configuration)
23
- with service as s:
24
- await s.upload(upload_data)
1
+ from typing import Dict, Any
2
+
3
+ from solax_py_library.upload.core.upload_service import upload_service_map
4
+ from solax_py_library.exception import SolaxBaseError
5
+ from solax_py_library.upload.types.client import UploadType, UploadData
6
+
7
+
8
+ def upload_service(upload_type: UploadType, configuration: Dict[str, Any]):
9
+ """
10
+ upload_type: 上传类型。
11
+ configuration: 配置信息
12
+ """
13
+ upload_class = upload_service_map.get(upload_type)
14
+ if not upload_class:
15
+ raise SolaxBaseError
16
+ return upload_class(**configuration)
17
+
18
+
19
+ async def upload(
20
+ upload_type: UploadType, configuration: Dict[str, Any], upload_data: UploadData
21
+ ):
22
+ service = upload_service(upload_type, configuration)
23
+ with service as s:
24
+ await s.upload(upload_data)
@@ -1,3 +1,3 @@
1
- from . import upload_service, data_adapter
2
-
3
- __all__ = ["upload_service", "data_adapter"]
1
+ from . import upload_service, data_adapter
2
+
3
+ __all__ = ["upload_service", "data_adapter"]
@@ -1,5 +1,5 @@
1
- from .base import BaseDataAdapter
2
- from .csv import CSVDataAdapter
3
-
4
-
5
- __all__ = ["BaseDataAdapter", "CSVDataAdapter"]
1
+ from .base import BaseDataAdapter
2
+ from .csv import CSVDataAdapter
3
+
4
+
5
+ __all__ = ["BaseDataAdapter", "CSVDataAdapter"]
@@ -1,9 +1,9 @@
1
- from abc import ABCMeta, abstractmethod
2
-
3
-
4
- class BaseDataAdapter(metaclass=ABCMeta):
5
- data_type = None
6
-
7
- @abstractmethod
8
- def parse_data(self, data):
9
- ...
1
+ from abc import ABCMeta, abstractmethod
2
+
3
+
4
+ class BaseDataAdapter(metaclass=ABCMeta):
5
+ data_type = None
6
+
7
+ @abstractmethod
8
+ def parse_data(self, data):
9
+ ...
@@ -1,26 +1,26 @@
1
- import csv
2
- import tempfile
3
- from typing import Any, Union, List, Dict
4
-
5
- from solax_py_library.upload.core.data_adapter.base import BaseDataAdapter
6
-
7
-
8
- class CSVDataAdapter(BaseDataAdapter):
9
- @classmethod
10
- def parse_data(cls, data: Union[List[List[Any]], List[Dict[str, Any]]]):
11
- with tempfile.NamedTemporaryFile(
12
- delete=False, mode="w", newline="", encoding="utf-8-sig"
13
- ) as temp_file:
14
- if isinstance(data[0], list):
15
- writer = csv.writer(temp_file)
16
- writer.writerows(data)
17
- else:
18
- headers = list(data[0].keys())
19
- writer = csv.DictWriter(temp_file, fieldnames=headers)
20
- writer.writeheader()
21
- writer.writerows(data)
22
-
23
- temp_file_path = temp_file.name
24
- temp_file.seek(0)
25
-
26
- return temp_file_path
1
+ import csv
2
+ import tempfile
3
+ from typing import Any, Union, List, Dict
4
+
5
+ from solax_py_library.upload.core.data_adapter.base import BaseDataAdapter
6
+
7
+
8
+ class CSVDataAdapter(BaseDataAdapter):
9
+ @classmethod
10
+ def parse_data(cls, data: Union[List[List[Any]], List[Dict[str, Any]]]):
11
+ with tempfile.NamedTemporaryFile(
12
+ delete=False, mode="w", newline="", encoding="utf-8-sig"
13
+ ) as temp_file:
14
+ if isinstance(data[0], list):
15
+ writer = csv.writer(temp_file)
16
+ writer.writerows(data)
17
+ else:
18
+ headers = list(data[0].keys())
19
+ writer = csv.DictWriter(temp_file, fieldnames=headers)
20
+ writer.writeheader()
21
+ writer.writerows(data)
22
+
23
+ temp_file_path = temp_file.name
24
+ temp_file.seek(0)
25
+
26
+ return temp_file_path
@@ -1,15 +1,15 @@
1
- from .base import BaseUploadService
2
- from .ftp import FTPUploadService
3
-
4
-
5
- upload_service_map = {}
6
-
7
-
8
- def _register(upload_obj):
9
- upload_service_map[upload_obj.upload_type] = upload_obj
10
-
11
-
12
- _register(FTPUploadService)
13
-
14
-
15
- __all__ = ["BaseUploadService", "FTPUploadService"]
1
+ from .base import BaseUploadService
2
+ from .ftp import FTPUploadService
3
+
4
+
5
+ upload_service_map = {}
6
+
7
+
8
+ def _register(upload_obj):
9
+ upload_service_map[upload_obj.upload_type] = upload_obj
10
+
11
+
12
+ _register(FTPUploadService)
13
+
14
+
15
+ __all__ = ["BaseUploadService", "FTPUploadService"]
@@ -1,43 +1,43 @@
1
- from abc import ABCMeta, abstractmethod
2
-
3
- from solax_py_library.upload.types.client import UploadData
4
-
5
-
6
- class BaseUploadService(metaclass=ABCMeta):
7
- upload_type = None
8
-
9
- def __init__(self, **kwargs) -> None:
10
- self._client = None
11
- self._is_connect = False
12
- self.timeout = 5
13
-
14
- @abstractmethod
15
- def connect(self):
16
- ...
17
-
18
- async def upload(self, data: UploadData):
19
- upload_data = self._parse(data.build_data())
20
- return self._upload(upload_data)
21
-
22
- @abstractmethod
23
- def close(self):
24
- ...
25
-
26
- @property
27
- def is_connect(self):
28
- return self._is_connect
29
-
30
- def __enter__(self):
31
- self.connect()
32
- return self
33
-
34
- def __exit__(self, exc_type, exc_value, traceback):
35
- self.close()
36
-
37
- @abstractmethod
38
- def _upload(self, data):
39
- ...
40
-
41
- @abstractmethod
42
- def _parse(self, upload_data: UploadData):
43
- ...
1
+ from abc import ABCMeta, abstractmethod
2
+
3
+ from solax_py_library.upload.types.client import UploadData
4
+
5
+
6
+ class BaseUploadService(metaclass=ABCMeta):
7
+ upload_type = None
8
+
9
+ def __init__(self, **kwargs) -> None:
10
+ self._client = None
11
+ self._is_connect = False
12
+ self.timeout = 5
13
+
14
+ @abstractmethod
15
+ def connect(self):
16
+ ...
17
+
18
+ async def upload(self, data: UploadData):
19
+ upload_data = self._parse(data.build_data())
20
+ return self._upload(upload_data)
21
+
22
+ @abstractmethod
23
+ def close(self):
24
+ ...
25
+
26
+ @property
27
+ def is_connect(self):
28
+ return self._is_connect
29
+
30
+ def __enter__(self):
31
+ self.connect()
32
+ return self
33
+
34
+ def __exit__(self, exc_type, exc_value, traceback):
35
+ self.close()
36
+
37
+ @abstractmethod
38
+ def _upload(self, data):
39
+ ...
40
+
41
+ @abstractmethod
42
+ def _parse(self, upload_data: UploadData):
43
+ ...
@@ -1,8 +1,8 @@
1
- from .upload_error import ConfigurationError, ConnectError, LoginError, SendDataError
2
-
3
- __all__ = [
4
- "ConnectError",
5
- "LoginError",
6
- "SendDataError",
7
- "ConfigurationError",
8
- ]
1
+ from .upload_error import ConfigurationError, ConnectError, LoginError, SendDataError
2
+
3
+ __all__ = [
4
+ "ConnectError",
5
+ "LoginError",
6
+ "SendDataError",
7
+ "ConfigurationError",
8
+ ]
@@ -1,21 +1,21 @@
1
- from solax_py_library.exception import SolaxBaseError
2
-
3
-
4
- class ConnectError(SolaxBaseError):
5
- code = 0x1001
6
- message = "connect error"
7
-
8
-
9
- class LoginError(SolaxBaseError):
10
- code = 0x1002
11
- message = "authentication error"
12
-
13
-
14
- class SendDataError(SolaxBaseError):
15
- code = 0x1003
16
- message = "send data error"
17
-
18
-
19
- class ConfigurationError(SolaxBaseError):
20
- code = 0x1004
21
- message = "server configuration error"
1
+ from solax_py_library.exception import SolaxBaseError
2
+
3
+
4
+ class ConnectError(SolaxBaseError):
5
+ code = 0x1001
6
+ message = "connect error"
7
+
8
+
9
+ class LoginError(SolaxBaseError):
10
+ code = 0x1002
11
+ message = "authentication error"
12
+
13
+
14
+ class SendDataError(SolaxBaseError):
15
+ code = 0x1003
16
+ message = "send data error"
17
+
18
+
19
+ class ConfigurationError(SolaxBaseError):
20
+ code = 0x1004
21
+ message = "server configuration error"