solax-py-library 1.0.0.2501__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.
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)
@@ -8,8 +8,11 @@ from solax_py_library.utils.time_util import trans_str_time_to_index
8
8
 
9
9
 
10
10
  class CloudClient:
11
- def get_token(self, cloud_url, ems_sn, sn_secret):
12
- token_url = cloud_url + "/device/token/getByRegistrationSn"
11
+ def __init__(self, base_url):
12
+ self.base_url = base_url
13
+
14
+ def get_token(self, ems_sn, sn_secret):
15
+ token_url = self.base_url + "/device/token/getByRegistrationSn"
13
16
  try:
14
17
  response = requests.post(
15
18
  token_url,
@@ -28,13 +31,10 @@ class CloudClient:
28
31
  except Exception as e:
29
32
  print(f"访问token接口失败: {str(e)}")
30
33
 
31
- def get_weather_data_from_cloud(self, cloud_url, ems_sn, sn_secret):
34
+ def get_weather_data_from_cloud(self, ems_sn, token):
32
35
  """获取未来24小时天气数据"""
33
36
  try:
34
- token = self.get_token(cloud_url, ems_sn, sn_secret)
35
- if not token:
36
- return False
37
- weather_url = cloud_url + "/ess/web/v1/powerStation/station/solcast/get"
37
+ weather_url = self.base_url + "/ess/web/v1/powerStation/station/solcast/get"
38
38
  headers = {"token": token, "Content-Type": "application/json"}
39
39
  post_dict = {"registerNo": ems_sn, "day": 1}
40
40
  response = requests.post(
@@ -137,12 +137,9 @@ class CloudClient:
137
137
  print(f"获取天气数据失败 异常 {traceback.format_exc()}")
138
138
  return False
139
139
 
140
- def get_electrovalence_data_from_cloud(self, cloud_url, ems_sn, sn_secret):
140
+ def get_electrovalence_data_from_cloud(self, ems_sn, token):
141
141
  try:
142
- token = self.get_token(cloud_url, ems_sn, sn_secret)
143
- if not token:
144
- return False
145
- price_url = cloud_url + "/powerStation/station/getCurrentElectrovalence"
142
+ price_url = self.base_url + "/powerStation/station/getCurrentElectrovalence"
146
143
  response = requests.post(
147
144
  url=price_url,
148
145
  headers={"token": token, "Content-Type": "application/json"},
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: solax-py-library
3
- Version: 1.0.0.2501
3
+ Version: 1.0.0.2502
4
4
  Summary: some common tool
5
5
  Author: shenlvyu
6
6
  Author-email: 13296718439@163.com
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Requires-Dist: pydantic (>=1.10.0,<2.0.0)
16
+ Requires-Dist: requests (==2.32.3)
16
17
  Requires-Dist: typing-extensions (==4.7.1)
17
18
  Description-Content-Type: text/markdown
18
19
 
@@ -41,6 +41,9 @@ solax_py_library/snap_shot/exceptions/snap_shot.py,sha256=-oxxh_lUhfZwtggJ4zfNBP
41
41
  solax_py_library/snap_shot/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  solax_py_library/snap_shot/types/__init__.py,sha256=g9ybB88TntvAMGIhLgJ31Xxn26zluSfI496bg-apSTU,290
43
43
  solax_py_library/snap_shot/types/address.py,sha256=JhyB-t2OnKuE8akKk120sojCNXv4_OlLLuWsl5ChFZ8,1148
44
+ solax_py_library/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ solax_py_library/test/test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ solax_py_library/test/test_utils/test_cloud_client.py,sha256=ixgJxIxwQuthAPA-WtgTlFehor1kApuxv40XG55ohyA,394
44
47
  solax_py_library/upload/__init__.py,sha256=XhZar7BKaRN0XcdPl4QffWr488L3UWvuq5syT8nX2OU,93
45
48
  solax_py_library/upload/api/__init__.py,sha256=ASShe-YQxP0aA3B_I8EmpWKXIdXPWvaANifrzlYrFEk,84
46
49
  solax_py_library/upload/api/service.py,sha256=-APuz86t4loCkjzaxq02kuKrB6jxaPV-Tz1V__j6cY0,763
@@ -59,10 +62,10 @@ solax_py_library/upload/types/__init__.py,sha256=og9KBpYbcs36_S1izURj3vyHeuNOLJQ
59
62
  solax_py_library/upload/types/client.py,sha256=fG674_QEpOw3ibO171lcxJ0cz27yGR_sd3zgiyr4yuI,492
60
63
  solax_py_library/upload/types/ftp.py,sha256=9kCeLB0g5Je19v4ifz8YYEsGOhJL1lKBO2C6V2VBndc,679
61
64
  solax_py_library/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
- solax_py_library/utils/cloud_client.py,sha256=QbINoIMAxMm3UHr-lSL_MuZUbMR2SKvgy1TefRxmZdg,9809
65
+ solax_py_library/utils/cloud_client.py,sha256=_k6RCO0SulNrzo6lnX-iRhuYqj7Lc8dba1VrGG33bUg,9608
63
66
  solax_py_library/utils/common.py,sha256=bfnZcX9uM-PjJrYAFv1UMmZgt6bGR7MaOd7jRPNHGxw,1238
64
67
  solax_py_library/utils/struct_util.py,sha256=4SKx5IyAke88PGHPHDK3OEDtyGHdapGoQ1BnGR0F2ts,913
65
68
  solax_py_library/utils/time_util.py,sha256=oVnC-NrPrVggvrhnDnUAeZOJmfgUXuY_P9jKKsgFweI,252
66
- solax_py_library-1.0.0.2501.dist-info/METADATA,sha256=zlm5HzCMmKvfd90-1KoAIcAW05ntKT3qIB7csMkOyRQ,1792
67
- solax_py_library-1.0.0.2501.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
68
- solax_py_library-1.0.0.2501.dist-info/RECORD,,
69
+ solax_py_library-1.0.0.2502.dist-info/METADATA,sha256=n9UbweLWJmve4JYfmkayTgcbpNiydFI42TMb_OzG3eI,1827
70
+ solax_py_library-1.0.0.2502.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
71
+ solax_py_library-1.0.0.2502.dist-info/RECORD,,