solax-py-library 1.0.0.2520__py3-none-any.whl → 1.0.0.2601__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.
- solax_py_library/device/types/device.py +16 -0
- solax_py_library/smart_scene/constant/message_entry.py +3 -0
- solax_py_library/smart_scene/core/condition/cabinet_condition.py +17 -14
- solax_py_library/smart_scene/types/condition.py +2 -2
- solax_py_library/smart_scene/types/condition_value.py +30 -0
- solax_py_library/test/test_smart_scene/test_condition.py +35 -1
- {solax_py_library-1.0.0.2520.dist-info → solax_py_library-1.0.0.2601.dist-info}/METADATA +1 -1
- {solax_py_library-1.0.0.2520.dist-info → solax_py_library-1.0.0.2601.dist-info}/RECORD +9 -7
- {solax_py_library-1.0.0.2520.dist-info → solax_py_library-1.0.0.2601.dist-info}/WHEEL +0 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
from enum import IntEnum
|
2
|
+
|
3
|
+
|
4
|
+
class DeviceType(IntEnum):
|
5
|
+
EMS_TYPE = 100
|
6
|
+
PCS_TYPE = 1
|
7
|
+
BMS_TYPE = 2 # 电池簇
|
8
|
+
ELM_TYPE = 3
|
9
|
+
EVC_TYPE = 4
|
10
|
+
IO_TYPE = 5
|
11
|
+
ESS_TYPE = 6 # 机柜
|
12
|
+
CELL_TYPE = 7 # 单体
|
13
|
+
AIRCONDITIONER_TYPE = 501
|
14
|
+
FIRE_SAFETY_TYPE = 502
|
15
|
+
COLD_TYPE = 503
|
16
|
+
DEHUMIDIFY_TYPE = 504
|
@@ -173,4 +173,7 @@ MESSAGE_ENTRY = {
|
|
173
173
|
"cabinetAlarm": {"zh_CN": "机柜发生{}", "en_US": "cabinet occurs {}"},
|
174
174
|
"OR": {"zh_CN": "满足任一条件", "en_US": "Meet any of the conditions"},
|
175
175
|
"AND": {"zh_CN": "满足所有条件", "en_US": "Meet all conditions"},
|
176
|
+
"tips_alarm": {"zh_CN": "状态提醒", "en_US": "Alarm tips"},
|
177
|
+
"normal_alarm": {"zh_CN": "普通告警", "en_US": "Normal alarm"},
|
178
|
+
"emergency_alarm": {"zh_CN": "紧急告警", "en_US": "Emergency alarm"},
|
176
179
|
}
|
@@ -7,6 +7,7 @@ from solax_py_library.smart_scene.types.condition import (
|
|
7
7
|
ConditionType,
|
8
8
|
)
|
9
9
|
from solax_py_library.device.types.alarm import AlarmLevel
|
10
|
+
from solax_py_library.smart_scene.types.condition_value import CabinetValue
|
10
11
|
|
11
12
|
|
12
13
|
class CabinetCondition(BaseCondition):
|
@@ -15,30 +16,32 @@ class CabinetCondition(BaseCondition):
|
|
15
16
|
def __init__(self, update_value_function, **kwargs):
|
16
17
|
super().__init__(update_value_function, **kwargs)
|
17
18
|
self.value = defaultdict(
|
18
|
-
lambda:
|
19
|
-
"soc": 0,
|
20
|
-
"alarm_level": {
|
21
|
-
AlarmLevel.EMERGENCY: False,
|
22
|
-
AlarmLevel.NORMAL: False,
|
23
|
-
AlarmLevel.TIPS: False,
|
24
|
-
},
|
25
|
-
}
|
19
|
+
lambda: CabinetValue
|
26
20
|
)
|
27
21
|
|
28
22
|
def meet_func(self, data: CabinetConditionItemData, ctx):
|
29
23
|
if not self.value:
|
30
24
|
return False
|
31
25
|
cabinet = ctx["cabinet"] or []
|
26
|
+
condition_data = data.childData.data
|
32
27
|
for cabinet_sn in cabinet:
|
28
|
+
cabinet_value = self.value[cabinet_sn]
|
29
|
+
if not cabinet_value:
|
30
|
+
continue
|
33
31
|
if data.childType == CabinetConditionType.cabinetSoc:
|
34
|
-
if self.value[cabinet_sn]
|
35
|
-
|
32
|
+
if self.value[cabinet_sn].soc is None:
|
33
|
+
continue
|
36
34
|
if data.childData.function.function()(
|
37
|
-
compare_value=self.value[cabinet_sn]
|
38
|
-
base_value=
|
35
|
+
compare_value=self.value[cabinet_sn].soc,
|
36
|
+
base_value=condition_data[0],
|
39
37
|
):
|
40
38
|
return True
|
41
39
|
elif data.childType == CabinetConditionType.cabinetAlarm:
|
42
|
-
|
43
|
-
|
40
|
+
alarm_type = condition_data[-1]
|
41
|
+
for device_type in condition_data[:-1]:
|
42
|
+
alarm_info = cabinet_value.alarm_info(device_type)
|
43
|
+
if not alarm_info:
|
44
|
+
continue
|
45
|
+
if alarm_info[alarm_type-1] is True:
|
46
|
+
return True
|
44
47
|
return False
|
@@ -163,7 +163,7 @@ class CabinetConditionItemData(BaseModel):
|
|
163
163
|
def _check_child_data(cls, value, values):
|
164
164
|
child_type = values.get("childType")
|
165
165
|
if child_type == CabinetConditionType.cabinetAlarm:
|
166
|
-
assert value.data[
|
166
|
+
assert value.data[-1] in {
|
167
167
|
AlarmLevel.TIPS,
|
168
168
|
AlarmLevel.NORMAL,
|
169
169
|
AlarmLevel.EMERGENCY,
|
@@ -181,7 +181,7 @@ class CabinetConditionItemData(BaseModel):
|
|
181
181
|
)
|
182
182
|
elif self.childType == CabinetConditionType.cabinetAlarm:
|
183
183
|
return MESSAGE_ENTRY[self.childType][lang].format(
|
184
|
-
MESSAGE_ENTRY[str(data[0])][lang], lang
|
184
|
+
MESSAGE_ENTRY[str(AlarmLevel(data[0]))][lang], lang
|
185
185
|
)
|
186
186
|
|
187
187
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from typing import List
|
2
|
+
|
3
|
+
from pydantic import BaseModel, Field
|
4
|
+
|
5
|
+
from solax_py_library.device.types.device import DeviceType
|
6
|
+
|
7
|
+
|
8
|
+
class CabinetValue(BaseModel):
|
9
|
+
soc: int = None
|
10
|
+
cabinet_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
11
|
+
pcs_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
12
|
+
io_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
13
|
+
bms_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
14
|
+
air_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
15
|
+
liquid_alarm: List[bool] = Field(default_factory=lambda :[False, False, False])
|
16
|
+
|
17
|
+
def alarm_info(self, device_type):
|
18
|
+
if device_type == DeviceType.EMS_TYPE:
|
19
|
+
return self.cabinet_alarm
|
20
|
+
elif device_type == DeviceType.PCS_TYPE:
|
21
|
+
return self.pcs_alarm
|
22
|
+
elif device_type == DeviceType.IO_TYPE:
|
23
|
+
return self.io_alarm
|
24
|
+
elif device_type == DeviceType.BMS_TYPE:
|
25
|
+
return self.bms_alarm
|
26
|
+
elif device_type == DeviceType.AIRCONDITIONER_TYPE:
|
27
|
+
return self.air_alarm
|
28
|
+
elif device_type == DeviceType.COLD_TYPE:
|
29
|
+
return self.liquid_alarm
|
30
|
+
return None
|
@@ -1,6 +1,10 @@
|
|
1
1
|
from unittest import TestCase
|
2
2
|
|
3
|
-
from solax_py_library.
|
3
|
+
from solax_py_library.device.types.device import DeviceType
|
4
|
+
from solax_py_library.smart_scene.core.condition import DateCondition, BaseCondition, CabinetCondition
|
5
|
+
from solax_py_library.smart_scene.types.condition import CabinetConditionItemData, CabinetConditionType, \
|
6
|
+
ConditionItemChildData
|
7
|
+
from solax_py_library.smart_scene.types.condition_value import CabinetValue
|
4
8
|
|
5
9
|
|
6
10
|
class TestCondition(TestCase):
|
@@ -9,3 +13,33 @@ class TestCondition(TestCase):
|
|
9
13
|
update_value_function=lambda: 1,
|
10
14
|
)
|
11
15
|
assert isinstance(date_condition, BaseCondition)
|
16
|
+
|
17
|
+
def test_cabinet_condition(self):
|
18
|
+
cabinet_condition = CabinetCondition(
|
19
|
+
update_value_function=lambda: {
|
20
|
+
"SN1": CabinetValue(
|
21
|
+
soc=0,
|
22
|
+
io_alarm=[False, True, False],
|
23
|
+
),
|
24
|
+
},
|
25
|
+
)
|
26
|
+
cabinet_condition.update_value()
|
27
|
+
assert cabinet_condition.meet_func(
|
28
|
+
data=CabinetConditionItemData(
|
29
|
+
childType=CabinetConditionType.cabinetAlarm,
|
30
|
+
childData=ConditionItemChildData(
|
31
|
+
data=[DeviceType.IO_TYPE, DeviceType.COLD_TYPE, 1]
|
32
|
+
)
|
33
|
+
),
|
34
|
+
ctx={"cabinet": ["SN1"]}
|
35
|
+
) is False
|
36
|
+
assert cabinet_condition.meet_func(
|
37
|
+
data=CabinetConditionItemData(
|
38
|
+
childType=CabinetConditionType.cabinetAlarm,
|
39
|
+
childData=ConditionItemChildData(
|
40
|
+
data=[DeviceType.IO_TYPE, DeviceType.COLD_TYPE, 2]
|
41
|
+
)
|
42
|
+
),
|
43
|
+
ctx={"cabinet": ["SN1"]}
|
44
|
+
) is True
|
45
|
+
|
@@ -8,12 +8,13 @@ solax_py_library/device/core/interver/__init__.py,sha256=RKye2D6NawSGdL4YUp_H-Lm
|
|
8
8
|
solax_py_library/device/core/interver/base.py,sha256=2TXHsjigMcIvGDLF3ZD4dw6UDrRRAk9Mq6sdBKRvydc,7191
|
9
9
|
solax_py_library/device/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
solax_py_library/device/types/alarm.py,sha256=kartXs_iRSV9Y3weFSsh9wMXU1_FxHZa6inHThyQCOk,358
|
11
|
+
solax_py_library/device/types/device.py,sha256=fksdxtCyG8Bvzs5lgUHjQm_Whj0NQwQP7PLZVPiwc24,328
|
11
12
|
solax_py_library/device/types/inverter_config.py,sha256=qCInNPbgsWf6yQjSw59kfQtJJWilMYUhvx_qo5qwRlU,912
|
12
13
|
solax_py_library/device/types/modbus_point.py,sha256=YmXe92gWXL_voVXDJE5zzNzr6dpPs7Ff3ciOAW-LgPs,580
|
13
14
|
solax_py_library/exception.py,sha256=ygAccdTqJctRrdt9bu6-vqZP5KadfKVS_1tjt4KcRn8,257
|
14
15
|
solax_py_library/smart_scene/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
16
|
solax_py_library/smart_scene/constant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
solax_py_library/smart_scene/constant/message_entry.py,sha256=
|
17
|
+
solax_py_library/smart_scene/constant/message_entry.py,sha256=r-hSUQItc0xEgodXtDct7AltFHQZxj5KH6ZP_ioZtAQ,9191
|
17
18
|
solax_py_library/smart_scene/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
19
|
solax_py_library/smart_scene/core/action/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
20
|
solax_py_library/smart_scene/core/action/base.py,sha256=CCYrlCZeb3CfGZgTWQN673VJmuYNsTbEtdZ4ERUV7RA,395
|
@@ -21,7 +22,7 @@ solax_py_library/smart_scene/core/action/ems_action.py,sha256=sML6qasFoqOktTvEcH
|
|
21
22
|
solax_py_library/smart_scene/core/action/system_action.py,sha256=oGXq3yXS9nKcGjJActjk0R2Wr3AoO9uoyRPyuiM053g,204
|
22
23
|
solax_py_library/smart_scene/core/condition/__init__.py,sha256=1nN-N52Oq7LKdn6ApKGtSZq5fB1qJzJq8BOKOumfQvY,475
|
23
24
|
solax_py_library/smart_scene/core/condition/base.py,sha256=saj7dc0Su2Wi_Lx04cesHFgIPDyQUwvHuDElcaDOIHU,596
|
24
|
-
solax_py_library/smart_scene/core/condition/cabinet_condition.py,sha256=
|
25
|
+
solax_py_library/smart_scene/core/condition/cabinet_condition.py,sha256=mLouKmO9VywSYlnha5lfAAOyPZUUWjEpvUEWEvx0HyQ,1803
|
25
26
|
solax_py_library/smart_scene/core/condition/date_condition.py,sha256=Xhca6VjoM8Bq-I-dFj1RPLTTzbBL81ORkBnR8D-YqUw,772
|
26
27
|
solax_py_library/smart_scene/core/condition/price_condition.py,sha256=IkgoB5YhpMxgFVkabilcBXtkjsqae01kkjF3tH10CK0,4006
|
27
28
|
solax_py_library/smart_scene/core/condition/system_condition.py,sha256=q5KDQdK6wjEvq0__WwBR4Sk-59yA2aIAgxTf1xjxJQk,1338
|
@@ -34,7 +35,8 @@ solax_py_library/smart_scene/exceptions/smart_scene.py,sha256=69khvoFm1Eki4NBT45
|
|
34
35
|
solax_py_library/smart_scene/exceptions/weather.py,sha256=bJl1VwiIXEpLQ9VjlVrDoTAIMFqVZdRCas7dtR7eAJc,133
|
35
36
|
solax_py_library/smart_scene/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
37
|
solax_py_library/smart_scene/types/action.py,sha256=cYICnxLfLRWFAlOGWpS2HBw-PyaB6TNlNuEmSsme26k,5723
|
37
|
-
solax_py_library/smart_scene/types/condition.py,sha256=
|
38
|
+
solax_py_library/smart_scene/types/condition.py,sha256=l6LFLvUCqKNX8qZqLsLUOkb5K_0nVAd0lc92wZcxWns,9565
|
39
|
+
solax_py_library/smart_scene/types/condition_value.py,sha256=H-45M4HEyBZXOToJZ2ftmV4d9hgDIWxqCaRMVGlQFXk,1247
|
38
40
|
solax_py_library/smart_scene/types/smart_scene_content.py,sha256=C8H17QEicmDBbxN-m550njwaZyUhAL2hUhlLg3Qj1zM,6061
|
39
41
|
solax_py_library/snap_shot/__init__.py,sha256=Ex12q6BCkdU-3OP-f-ehGCetJJWnoZ7KxhEDd_lXh6M,81
|
40
42
|
solax_py_library/snap_shot/constant/__init__.py,sha256=UNfjAlx1wovXc1oH74af9oIe2TljwCCiTzNXzWgtUms,65
|
@@ -50,7 +52,7 @@ solax_py_library/snap_shot/types/__init__.py,sha256=g9ybB88TntvAMGIhLgJ31Xxn26zl
|
|
50
52
|
solax_py_library/snap_shot/types/address.py,sha256=JhyB-t2OnKuE8akKk120sojCNXv4_OlLLuWsl5ChFZ8,1148
|
51
53
|
solax_py_library/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
52
54
|
solax_py_library/test/test_smart_scene/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
|
-
solax_py_library/test/test_smart_scene/test_condition.py,sha256=
|
55
|
+
solax_py_library/test/test_smart_scene/test_condition.py,sha256=gnNliXSLqDsEj-J2-xgBYagxNI5rJlBZSfbkOR7AJZE,1664
|
54
56
|
solax_py_library/test/test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
57
|
solax_py_library/test/test_utils/test_cloud_client.py,sha256=gOrHGXkFXpFV4kXTnjhmyJGem8VaGKw8OmXyW884oJ0,395
|
56
58
|
solax_py_library/upload/__init__.py,sha256=XhZar7BKaRN0XcdPl4QffWr488L3UWvuq5syT8nX2OU,93
|
@@ -75,6 +77,6 @@ solax_py_library/utils/cloud_client.py,sha256=5dZrc5fzrNFSXqTPZd7oHt-Y9Jj6RCigB7
|
|
75
77
|
solax_py_library/utils/common.py,sha256=bfnZcX9uM-PjJrYAFv1UMmZgt6bGR7MaOd7jRPNHGxw,1238
|
76
78
|
solax_py_library/utils/struct_util.py,sha256=pL6L80GXIHasy1ZDIj89-5BzXW1BWI3TPitH7thGGIE,1577
|
77
79
|
solax_py_library/utils/time_util.py,sha256=bY5kj9dmyOuLEQ6uYGQK7jU7y1RMiHZgevEKnkcQcSU,1461
|
78
|
-
solax_py_library-1.0.0.
|
79
|
-
solax_py_library-1.0.0.
|
80
|
-
solax_py_library-1.0.0.
|
80
|
+
solax_py_library-1.0.0.2601.dist-info/METADATA,sha256=dHRe01IzV0q4TZX6yERl6cdDEWIPWXqtLQKVh75qsOM,1827
|
81
|
+
solax_py_library-1.0.0.2601.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
82
|
+
solax_py_library-1.0.0.2601.dist-info/RECORD,,
|
File without changes
|