solax-py-library 1.0.0.2513__py3-none-any.whl → 1.0.0.2514__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/smart_scene/core/condition/base.py +4 -2
- solax_py_library/smart_scene/core/condition/date_condition.py +3 -9
- solax_py_library/smart_scene/core/condition/system_condition.py +3 -5
- solax_py_library/test/test_smart_scene/__init__.py +0 -0
- solax_py_library/test/test_smart_scene/test_condition.py +11 -0
- {solax_py_library-1.0.0.2513.dist-info → solax_py_library-1.0.0.2514.dist-info}/METADATA +1 -1
- {solax_py_library-1.0.0.2513.dist-info → solax_py_library-1.0.0.2514.dist-info}/RECORD +8 -6
- {solax_py_library-1.0.0.2513.dist-info → solax_py_library-1.0.0.2514.dist-info}/WHEEL +0 -0
@@ -8,8 +8,10 @@ class BaseCondition(object):
|
|
8
8
|
self.update_value_function = update_value_function
|
9
9
|
|
10
10
|
def update_value(self):
|
11
|
-
self.update_value_function()
|
12
|
-
|
11
|
+
new_value = self.update_value_function()
|
12
|
+
if not isinstance(new_value, dict):
|
13
|
+
raise ValueError("update_value_function must return a dict")
|
14
|
+
self.value.update(new_value)
|
13
15
|
|
14
16
|
def meet_func(self, data, ctx):
|
15
17
|
...
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
|
3
1
|
from solax_py_library.smart_scene.core.condition.base import BaseCondition
|
4
2
|
from solax_py_library.smart_scene.types.condition import (
|
5
3
|
DateConditionItemData,
|
@@ -14,16 +12,12 @@ class DateCondition(BaseCondition):
|
|
14
12
|
def __init__(self, update_value_function, **kwargs):
|
15
13
|
super().__init__(update_value_function, **kwargs)
|
16
14
|
|
17
|
-
def _update_value(self):
|
18
|
-
"""获取time 类型需要的数据"""
|
19
|
-
now = datetime.now()
|
20
|
-
self.hour = now.hour
|
21
|
-
self.minute = now.minute
|
22
|
-
|
23
15
|
def meet_func(self, data: DateConditionItemData, ctx):
|
24
16
|
if data.childType == DateConditionType.time:
|
25
17
|
date = data.childData.data[0]
|
26
18
|
hour, minute = date.split(":")
|
27
|
-
if int(hour) == self.hour and int(minute) == self.
|
19
|
+
if int(hour) == self.value.get("hour") and int(minute) == self.value.get(
|
20
|
+
"minute"
|
21
|
+
):
|
28
22
|
return True
|
29
23
|
return False
|
@@ -11,8 +11,6 @@ class SystemCondition(BaseCondition):
|
|
11
11
|
|
12
12
|
def __init__(self, update_value_function, **kwargs):
|
13
13
|
super().__init__(update_value_function, **kwargs)
|
14
|
-
self.grid_active_power = None
|
15
|
-
self.system_soc = None
|
16
14
|
|
17
15
|
def meet_system_condition(self, data: SystemConditionItemData, ctx):
|
18
16
|
if not self.value:
|
@@ -21,15 +19,15 @@ class SystemCondition(BaseCondition):
|
|
21
19
|
function_value = child_data.function
|
22
20
|
compare_value = None
|
23
21
|
if data.childType == SystemConditionType.systemExportPower:
|
24
|
-
compare_value = self.grid_active_power
|
22
|
+
compare_value = self.value.get("grid_active_power")
|
25
23
|
if compare_value < 0:
|
26
24
|
return False
|
27
25
|
elif data.childType == SystemConditionType.systemImportPower:
|
28
|
-
compare_value = self.grid_active_power
|
26
|
+
compare_value = self.value.get("grid_active_power")
|
29
27
|
if compare_value > 0:
|
30
28
|
return False
|
31
29
|
elif data.childType == SystemConditionType.systemSoc:
|
32
|
-
compare_value = self.system_soc
|
30
|
+
compare_value = self.value.get("system_soc")
|
33
31
|
if compare_value is None:
|
34
32
|
return False
|
35
33
|
return function_value.function()(
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from unittest import TestCase
|
2
|
+
|
3
|
+
from solax_py_library.smart_scene.core.condition import DateCondition, BaseCondition
|
4
|
+
|
5
|
+
|
6
|
+
class TestCondition(TestCase):
|
7
|
+
def test_condition(self):
|
8
|
+
date_condition = DateCondition(
|
9
|
+
update_value_function=lambda: 1,
|
10
|
+
)
|
11
|
+
assert isinstance(date_condition, BaseCondition)
|
@@ -20,11 +20,11 @@ solax_py_library/smart_scene/core/action/base.py,sha256=vSC3rL9qfPy41Nlds_0QcTLM
|
|
20
20
|
solax_py_library/smart_scene/core/action/ems_action.py,sha256=tasL7pUJbnmrEEokAa9Mug5eUFvHuFKGYZKNvNMdrBs,610
|
21
21
|
solax_py_library/smart_scene/core/action/system_action.py,sha256=mVLTg9pZ7tDayLbr3I92a33snA2AGT3meUdm_XYDQEc,10839
|
22
22
|
solax_py_library/smart_scene/core/condition/__init__.py,sha256=1nN-N52Oq7LKdn6ApKGtSZq5fB1qJzJq8BOKOumfQvY,475
|
23
|
-
solax_py_library/smart_scene/core/condition/base.py,sha256=
|
23
|
+
solax_py_library/smart_scene/core/condition/base.py,sha256=saj7dc0Su2Wi_Lx04cesHFgIPDyQUwvHuDElcaDOIHU,596
|
24
24
|
solax_py_library/smart_scene/core/condition/cabinet_condition.py,sha256=HEVifO3rHk2ElfSCEB0MzVdfrFWlkwqjt6tFhtJ8CLY,1581
|
25
|
-
solax_py_library/smart_scene/core/condition/date_condition.py,sha256
|
25
|
+
solax_py_library/smart_scene/core/condition/date_condition.py,sha256=Xhca6VjoM8Bq-I-dFj1RPLTTzbBL81ORkBnR8D-YqUw,772
|
26
26
|
solax_py_library/smart_scene/core/condition/price_condition.py,sha256=mzUnrMuG0DHCxaQQe7-rmE_vra9U6vd-1AYDKkbPPUw,3884
|
27
|
-
solax_py_library/smart_scene/core/condition/system_condition.py,sha256=
|
27
|
+
solax_py_library/smart_scene/core/condition/system_condition.py,sha256=oLz0MM47bj6K1saAap3YBteK9UeejSqu5CQVdLvGE1Q,1350
|
28
28
|
solax_py_library/smart_scene/core/condition/weather_condition.py,sha256=OiKye007PZnocnmcrNQD6ObOEF7VyaYkdqz6D_2lNok,2236
|
29
29
|
solax_py_library/smart_scene/core/service/__init__.py,sha256=wWzHSN2XaHnI-TNtCJWWRHnNC7s3-2GNQo9y0K_PC4Q,69
|
30
30
|
solax_py_library/smart_scene/core/service/runner.py,sha256=SwQ6jb5yFPcyHyfU-THyGDjPEMcNFUOHkvVYA9wB1EE,6201
|
@@ -49,6 +49,8 @@ solax_py_library/snap_shot/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
|
|
49
49
|
solax_py_library/snap_shot/types/__init__.py,sha256=g9ybB88TntvAMGIhLgJ31Xxn26zluSfI496bg-apSTU,290
|
50
50
|
solax_py_library/snap_shot/types/address.py,sha256=JhyB-t2OnKuE8akKk120sojCNXv4_OlLLuWsl5ChFZ8,1148
|
51
51
|
solax_py_library/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
52
|
+
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=w-REUzkaDrq9acye2qZeAbTQb8bpgAykLfylsLvNrx8,331
|
52
54
|
solax_py_library/test/test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
55
|
solax_py_library/test/test_utils/test_cloud_client.py,sha256=gOrHGXkFXpFV4kXTnjhmyJGem8VaGKw8OmXyW884oJ0,395
|
54
56
|
solax_py_library/upload/__init__.py,sha256=XhZar7BKaRN0XcdPl4QffWr488L3UWvuq5syT8nX2OU,93
|
@@ -73,6 +75,6 @@ solax_py_library/utils/cloud_client.py,sha256=5dZrc5fzrNFSXqTPZd7oHt-Y9Jj6RCigB7
|
|
73
75
|
solax_py_library/utils/common.py,sha256=bfnZcX9uM-PjJrYAFv1UMmZgt6bGR7MaOd7jRPNHGxw,1238
|
74
76
|
solax_py_library/utils/struct_util.py,sha256=4SKx5IyAke88PGHPHDK3OEDtyGHdapGoQ1BnGR0F2ts,913
|
75
77
|
solax_py_library/utils/time_util.py,sha256=bY5kj9dmyOuLEQ6uYGQK7jU7y1RMiHZgevEKnkcQcSU,1461
|
76
|
-
solax_py_library-1.0.0.
|
77
|
-
solax_py_library-1.0.0.
|
78
|
-
solax_py_library-1.0.0.
|
78
|
+
solax_py_library-1.0.0.2514.dist-info/METADATA,sha256=2aiCh__xWlAwyUZxGCK5qlIlz3kRyGTEO8CHz__cLG8,1827
|
79
|
+
solax_py_library-1.0.0.2514.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
80
|
+
solax_py_library-1.0.0.2514.dist-info/RECORD,,
|
File without changes
|