openems-client 0.1.0__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.
- openems_client/__init__.py +1 -0
- openems_client/config/combined_sensors.json +17 -0
- openems_client/config/component_update_groups.json +16 -0
- openems_client/config/default_channels.json +139 -0
- openems_client/config/enum_options.json +154 -0
- openems_client/config/number_properties.json +134 -0
- openems_client/config/time_options.json +20 -0
- openems_client/config.py +111 -0
- openems_client/const.py +83 -0
- openems_client/entry_data.py +297 -0
- openems_client/helpers.py +39 -0
- openems_client/helpers_openems.py +138 -0
- openems_client/openems.py +1111 -0
- openems_client/py.typed +0 -0
- openems_client-0.1.0.dist-info/METADATA +106 -0
- openems_client-0.1.0.dist-info/RECORD +18 -0
- openems_client-0.1.0.dist-info/WHEEL +4 -0
- openems_client-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Async client for OpenEMS / FENECON FEMS energy management systems."""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"combined_sensors": [
|
|
4
|
+
{
|
|
5
|
+
"id": "VoltageDifference",
|
|
6
|
+
"template": "{{MaxCellVoltage}} - {{MinCellVoltage}}",
|
|
7
|
+
"unit_of_measurement": "mV"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "Tower{tId}Module{mId}CellVoltageDifference",
|
|
11
|
+
"template": "[{{Tower{tId}Module{mId}Cell{cId}Voltage}}] | max - [{{Tower{tId}Module{mId}Cell{cId}Voltage}}] | min",
|
|
12
|
+
"unit_of_measurement": "mV"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"component_regexp": "battery\\d+"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"component_regexp": "ctrlEvcs\\d+",
|
|
4
|
+
"rules": [
|
|
5
|
+
{
|
|
6
|
+
"channel": "_PropertyEnabledCharging",
|
|
7
|
+
"requires": ["_PropertyChargeMode"],
|
|
8
|
+
"when": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"channel": "_PropertyChargeMode",
|
|
12
|
+
"requires": ["_PropertyEnabledCharging"]
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"channels": ["_PropertyIsEssChargeFromGridAllowed"],
|
|
4
|
+
"component_regexp": "_meta"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"channels": [
|
|
8
|
+
"ConsumptionActivePower",
|
|
9
|
+
"ConsumptionMaxActivePower",
|
|
10
|
+
"EssActivePower",
|
|
11
|
+
"EssDcChargeEnergy",
|
|
12
|
+
"EssDcDischargeEnergy",
|
|
13
|
+
"EssDischargePower",
|
|
14
|
+
"EssMaxDischargePower",
|
|
15
|
+
"EssMinDischargePower",
|
|
16
|
+
"EssSoc",
|
|
17
|
+
"GridActivePower",
|
|
18
|
+
"GridBuyActiveEnergy",
|
|
19
|
+
"GridMaxActivePower",
|
|
20
|
+
"GridMinActivePower",
|
|
21
|
+
"GridMode",
|
|
22
|
+
"GridSellActiveEnergy",
|
|
23
|
+
"ProductionAcActivePower",
|
|
24
|
+
"ProductionActiveEnergy",
|
|
25
|
+
"ProductionActivePower",
|
|
26
|
+
"ProductionDcActualPower",
|
|
27
|
+
"ProductionMaxActivePower",
|
|
28
|
+
"State"
|
|
29
|
+
],
|
|
30
|
+
"component_regexp": "_sum"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"channels": ["ActualEnergy", "ActualPower"],
|
|
34
|
+
"component_regexp": "charger\\d+"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"channels": ["_PropertyIsReserveSocEnabled", "_PropertyReserveSoc"],
|
|
38
|
+
"component_regexp": "ctrlEmergencyCapacityReserve\\d+"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"channels": [
|
|
42
|
+
"_PropertyMode",
|
|
43
|
+
"_PropertyManualEnergySessionLimit",
|
|
44
|
+
"_PropertyPhaseSwitching",
|
|
45
|
+
"ActualMode",
|
|
46
|
+
"StateMachine",
|
|
47
|
+
"SessionEnergy"
|
|
48
|
+
],
|
|
49
|
+
"component_regexp": "ctrlEvseCluster\\d+|ctrlEvseSingle\\d+"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"channels": [
|
|
53
|
+
"_PropertyChargeMode",
|
|
54
|
+
"_PropertyDefaultChargeMinPower",
|
|
55
|
+
"_PropertyEnabledCharging",
|
|
56
|
+
"_PropertyEnergySessionLimit",
|
|
57
|
+
"_PropertyForceChargeMinPower",
|
|
58
|
+
"_PropertyPriority"
|
|
59
|
+
],
|
|
60
|
+
"component_regexp": "ctrlEvcs\\d+"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"channels": ["RestrictionMode"],
|
|
64
|
+
"component_regexp": "ctrlEssLimiter14a\\d+"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"channels": [
|
|
68
|
+
"_PropertyMode",
|
|
69
|
+
"_PropertyDelayChargeRiskLevel",
|
|
70
|
+
"_PropertyManualTargetTime",
|
|
71
|
+
"DelayChargeMaximumChargeLimit",
|
|
72
|
+
"DelayChargeState",
|
|
73
|
+
"SellToGridLimitMinimumChargeLimit",
|
|
74
|
+
"SellToGridLimitState",
|
|
75
|
+
"TargetMinute"
|
|
76
|
+
],
|
|
77
|
+
"component_regexp": "ctrlGridOptimizedCharge\\d+"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"channels": [
|
|
81
|
+
"Status",
|
|
82
|
+
"_PropertyAutomaticForceOnCtrlEnabled",
|
|
83
|
+
"_PropertyAutomaticForceOnSoc",
|
|
84
|
+
"_PropertyAutomaticForceOnSurplusPower",
|
|
85
|
+
"_PropertyAutomaticLockCtrlEnabled",
|
|
86
|
+
"_PropertyAutomaticLockGridBuyPower",
|
|
87
|
+
"_PropertyAutomaticLockSoc",
|
|
88
|
+
"_PropertyAutomaticRecommendationCtrlEnabled",
|
|
89
|
+
"_PropertyAutomaticRecommendationSurplusPower",
|
|
90
|
+
"_PropertyManualState",
|
|
91
|
+
"_PropertyMinimumSwitchingTime",
|
|
92
|
+
"_PropertyMode"
|
|
93
|
+
],
|
|
94
|
+
"component_regexp": "ctrlIoHeatPump\\d+"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"channels": [
|
|
98
|
+
"_PropertyIsRunning",
|
|
99
|
+
"_PropertyTargetTime",
|
|
100
|
+
"_PropertyTargetTimeSpecified",
|
|
101
|
+
"CtrlIsBlockingEss",
|
|
102
|
+
"CtrlIsChargingEss",
|
|
103
|
+
"CtrlIsDischargingEss"
|
|
104
|
+
],
|
|
105
|
+
"component_regexp": "ctrlPrepareBatteryExtension\\d+"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"channels": [
|
|
109
|
+
"Capacity",
|
|
110
|
+
"DcChargeEnergy",
|
|
111
|
+
"DcDischargeEnergy",
|
|
112
|
+
"DcDischargePower",
|
|
113
|
+
"Soc"
|
|
114
|
+
],
|
|
115
|
+
"component_regexp": "ess\\d+"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"channels": [
|
|
119
|
+
"ActivePower",
|
|
120
|
+
"ChargePower",
|
|
121
|
+
"EnergySession",
|
|
122
|
+
"MaximumHardwarePower",
|
|
123
|
+
"MinimumHardwarePower",
|
|
124
|
+
"Phases",
|
|
125
|
+
"SetChargePowerLimit",
|
|
126
|
+
"State",
|
|
127
|
+
"Status"
|
|
128
|
+
],
|
|
129
|
+
"component_regexp": "evcs\\d+"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"channels": ["ActivePower"],
|
|
133
|
+
"component_regexp": "meter\\d+"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"channels": ["ActivePower", "ActiveProductionEnergy"],
|
|
137
|
+
"component_regexp": "pvInverter\\d+"
|
|
138
|
+
}
|
|
139
|
+
]
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"channels": [
|
|
4
|
+
{
|
|
5
|
+
"id": "_PropertyCurrency",
|
|
6
|
+
"options": ["EUR", "SEK", "CHF"]
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "_PropertyFormat",
|
|
10
|
+
"options": ["GERMAN_EXCEL", "ENGLISH"]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "_PropertyPhase",
|
|
14
|
+
"options": ["L1", "L2", "L3"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "_PropertyPhaseRotation",
|
|
18
|
+
"options": ["L1_L2_L3", "L2_L3_L1", "L3_L1_L2"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"component_regexp": ".*"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"channels": [
|
|
25
|
+
{
|
|
26
|
+
"id": "_PropertyMode",
|
|
27
|
+
"options": ["ZERO", "MINIMUM", "SURPLUS", "FORCE"]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "_PropertyPhaseSwitching",
|
|
31
|
+
"options": [
|
|
32
|
+
"DISABLE",
|
|
33
|
+
"FORCE_SINGLE_PHASE",
|
|
34
|
+
"FORCE_THREE_PHASE",
|
|
35
|
+
"AUTOMATIC"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"component_regexp": "ctrlEvseCluster\\d+|ctrlEvseSingle\\d+"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"channels": [
|
|
43
|
+
{
|
|
44
|
+
"id": "_PropertyChargeMode",
|
|
45
|
+
"options": ["FORCE_CHARGE", "EXCESS_POWER"]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "_PropertyPriority",
|
|
49
|
+
"options": ["CAR", "STORAGE"]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"component_regexp": "ctrlEvcs\\d+"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"channels": [
|
|
56
|
+
{
|
|
57
|
+
"id": "_PropertyLogVerbosity",
|
|
58
|
+
"options": ["NONE", "DEBUG_LOG", "TRACE"]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "_PropertyRiskLevel",
|
|
62
|
+
"options": ["LOW", "MEDIUM", "HIGH"]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "_PropertyVersion",
|
|
66
|
+
"options": ["V1_ESS_ONLY", "V2_ENERGY_SCHEDULABLE"]
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"component_regexp": "_energy"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"channels": [
|
|
73
|
+
{
|
|
74
|
+
"id": "_PropertyGridMode",
|
|
75
|
+
"options": ["UNDEFINED", "ON_GRID", "OFF_GRID"]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "_PropertyLogVerbosity",
|
|
79
|
+
"options": ["NONE", "REQUESTED_PREDICTIONS"]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "_PropertySource",
|
|
83
|
+
"options": [
|
|
84
|
+
"ZERO",
|
|
85
|
+
"H0_HOUSEHOLD_SUMMER_WEEKDAY_STANDARD_LOAD_PROFILE",
|
|
86
|
+
"H0_HOUSEHOLD_SUMMER_WEEKDAY_PV_PRODUCTION",
|
|
87
|
+
"H0_HOUSEHOLD_SUMMER_WEEKDAY_NON_REGULATED_CONSUMPTION",
|
|
88
|
+
"H0_HOUSEHOLD_SUMMER_WEEKDAY_PV_PRODUCTION2"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"component_regexp": "(datasource\\d+|ess\\d+|meter\\d+)"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"channels": [
|
|
96
|
+
{
|
|
97
|
+
"id": "_PropertyStrategy",
|
|
98
|
+
"options": [
|
|
99
|
+
"UNDEFINED",
|
|
100
|
+
"NONE",
|
|
101
|
+
"ALL_CONSTRAINTS",
|
|
102
|
+
"OPTIMIZE_BY_MOVING_TOWARDS_TARGET",
|
|
103
|
+
"OPTIMIZE_BY_KEEPING_TARGET_DIRECTION_AND_MAXIMIZING_IN_ORDER",
|
|
104
|
+
"OPTIMIZE_BY_KEEPING_ALL_EQUAL",
|
|
105
|
+
"OPTIMIZE_BY_KEEPING_ALL_NEAR_EQUAL"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"component_regexp": "_power"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"channels": [
|
|
113
|
+
{
|
|
114
|
+
"id": "_PropertyMode",
|
|
115
|
+
"options": ["OFF", "MANUAL", "AUTOMATIC"]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "_PropertyDelayChargeRiskLevel",
|
|
119
|
+
"options": ["LOW", "MEDIUM", "HIGH"]
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"component_regexp": "ctrlGridOptimizedCharge\\d+"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"channels": [
|
|
126
|
+
{
|
|
127
|
+
"id": "_PropertyDefaultLevel",
|
|
128
|
+
"options": ["LEVEL_1", "LEVEL_2", "LEVEL_3"]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "_PropertyMode",
|
|
132
|
+
"options": ["AUTOMATIC", "MANUAL_ON", "MANUAL_OFF"]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "_PropertyWorkMode",
|
|
136
|
+
"options": ["TIME", "NONE"]
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"component_regexp": "ctrlIoHeatingElement\\d+"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"channels": [
|
|
143
|
+
{
|
|
144
|
+
"id": "_PropertyMode",
|
|
145
|
+
"options": ["MANUAL", "AUTOMATIC"]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "_PropertyManualState",
|
|
149
|
+
"options": ["LOCK", "REGULAR", "RECOMMENDATION", "FORCE_ON"]
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"component_regexp": "ctrlIoHeatPump\\d+"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"channels": [
|
|
4
|
+
{
|
|
5
|
+
"id": "_PropertyTargetGridSetpoint",
|
|
6
|
+
"limit": {
|
|
7
|
+
"lower": "0-{{$ess.id/MaxApparentPower}}",
|
|
8
|
+
"upper": "{{$ess.id/MaxApparentPower}}"
|
|
9
|
+
},
|
|
10
|
+
"mode": "box",
|
|
11
|
+
"step": 100
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"component_regexp": "ctrlBalancing\\d+"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"channels": [
|
|
18
|
+
{
|
|
19
|
+
"id": "_PropertyManualEnergySessionLimit",
|
|
20
|
+
"limit": {
|
|
21
|
+
"lower": "0",
|
|
22
|
+
"upper": "100000"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"component_regexp": "ctrlEvseCluster\\d+|ctrlEvseSingle\\d+"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"channels": [
|
|
30
|
+
{
|
|
31
|
+
"id": "_PropertyEnergySessionLimit",
|
|
32
|
+
"limit": {
|
|
33
|
+
"lower": "0",
|
|
34
|
+
"upper": "100000"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "_PropertyForceChargeMinPower",
|
|
39
|
+
"limit": {
|
|
40
|
+
"lower": "{{$evcs.id/MinimumHardwarePower}} / {{$evcs.id/Phases}}",
|
|
41
|
+
"upper": "{{$evcs.id/MaximumHardwarePower}} / {{$evcs.id/Phases}}"
|
|
42
|
+
},
|
|
43
|
+
"multiplier": "{{$evcs.id/Phases}}"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "_PropertyDefaultChargeMinPower",
|
|
47
|
+
"limit": {
|
|
48
|
+
"lower": "{{$evcs.id/MinimumHardwarePower}}",
|
|
49
|
+
"upper": "{{$evcs.id/MaximumHardwarePower}}"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"component_regexp": "ctrlEvcs\\d+"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"channels": [
|
|
57
|
+
{
|
|
58
|
+
"id": "_PropertyReserveSoc",
|
|
59
|
+
"limit": {
|
|
60
|
+
"lower": "5",
|
|
61
|
+
"upper": "100"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"component_regexp": "ctrlEmergencyCapacityReserve\\d+"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"channels": [
|
|
69
|
+
{
|
|
70
|
+
"id": "_PropertyMinTime",
|
|
71
|
+
"limit": {
|
|
72
|
+
"lower": "1",
|
|
73
|
+
"upper": "10"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"component_regexp": "ctrlIoHeatingElement\\d+"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"channels": [
|
|
81
|
+
{
|
|
82
|
+
"id": "_PropertyAutomaticForceOnSoc",
|
|
83
|
+
"limit": {
|
|
84
|
+
"lower": "0",
|
|
85
|
+
"upper": "100"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "_PropertyAutomaticLockSoc",
|
|
90
|
+
"limit": {
|
|
91
|
+
"lower": "0",
|
|
92
|
+
"upper": "100"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "_PropertyAutomaticRecommendationSurplusPower",
|
|
97
|
+
"limit": {
|
|
98
|
+
"lower": "0",
|
|
99
|
+
"upper": "100000"
|
|
100
|
+
},
|
|
101
|
+
"mode": "box",
|
|
102
|
+
"step": 1
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "_PropertyAutomaticForceOnSurplusPower",
|
|
106
|
+
"limit": {
|
|
107
|
+
"lower": "0",
|
|
108
|
+
"upper": "100000"
|
|
109
|
+
},
|
|
110
|
+
"mode": "box",
|
|
111
|
+
"step": 1
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "_PropertyAutomaticLockGridBuyPower",
|
|
115
|
+
"limit": {
|
|
116
|
+
"lower": "0",
|
|
117
|
+
"upper": "100000"
|
|
118
|
+
},
|
|
119
|
+
"mode": "box",
|
|
120
|
+
"step": 1
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "_PropertyMinimumSwitchingTime",
|
|
124
|
+
"limit": {
|
|
125
|
+
"lower": "0",
|
|
126
|
+
"upper": "3600"
|
|
127
|
+
},
|
|
128
|
+
"mode": "box",
|
|
129
|
+
"step": 1
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"component_regexp": "ctrlIoHeatPump\\d+"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"channels": [
|
|
4
|
+
{
|
|
5
|
+
"id": "_PropertyManualTargetTime",
|
|
6
|
+
"is_time": true
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"component_regexp": "ctrlGridOptimizedCharge\\d+"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"channels": [
|
|
13
|
+
{
|
|
14
|
+
"id": "_PropertyEndTime",
|
|
15
|
+
"is_time": true
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"component_regexp": "ctrlIoHeatingElement\\d+"
|
|
19
|
+
}
|
|
20
|
+
]
|
openems_client/config.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Load additional config options from json files."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import re
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
ENCODING = "utf-8"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OpenEMSConfig:
|
|
12
|
+
"""Load additional config options from json files."""
|
|
13
|
+
|
|
14
|
+
def __init__(self) -> None:
|
|
15
|
+
"""Initialize and read json files."""
|
|
16
|
+
path = Path(__file__).parent / "config"
|
|
17
|
+
with (path / "default_channels.json").open(encoding=ENCODING) as channel_file:
|
|
18
|
+
self.default_channels = json.load(channel_file)
|
|
19
|
+
with (path / "enum_options.json").open(encoding=ENCODING) as enum_file:
|
|
20
|
+
self.enum_options = json.load(enum_file)
|
|
21
|
+
with (path / "time_options.json").open(encoding=ENCODING) as time_file:
|
|
22
|
+
self.time_options = json.load(time_file)
|
|
23
|
+
with (path / "number_properties.json").open(encoding=ENCODING) as number_file:
|
|
24
|
+
self.number_properties = json.load(number_file)
|
|
25
|
+
with (path / "component_update_groups.json").open(
|
|
26
|
+
encoding=ENCODING
|
|
27
|
+
) as groups_file:
|
|
28
|
+
self.update_groups = json.load(groups_file)
|
|
29
|
+
with (path / "combined_sensors.json").open(encoding=ENCODING) as combined_file:
|
|
30
|
+
self.combined_sensors = json.load(combined_file)
|
|
31
|
+
|
|
32
|
+
def _get_config_property(self, dict, property, component_name, channel_name):
|
|
33
|
+
"""Return dict property for a given component/channel."""
|
|
34
|
+
for component_conf in dict:
|
|
35
|
+
comp_regex = component_conf["component_regexp"]
|
|
36
|
+
if re.fullmatch(comp_regex, component_name):
|
|
37
|
+
for channel in component_conf["channels"]:
|
|
38
|
+
if channel["id"] == channel_name:
|
|
39
|
+
return channel.get(property)
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
def get_enum_options(self, component_name, channel_name) -> list[str] | None:
|
|
43
|
+
"""Return option string list for a given component/channel."""
|
|
44
|
+
return self._get_config_property(
|
|
45
|
+
self.enum_options, "options", component_name, channel_name
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def is_time_property(self, component_name, channel_name) -> list[str] | None:
|
|
49
|
+
"""Return True if given component/channel is marked as time."""
|
|
50
|
+
return self._get_config_property(
|
|
51
|
+
self.time_options, "is_time", component_name, channel_name
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def get_number_limit(self, component_name, channel_name) -> dict | None:
|
|
55
|
+
"""Return limit definition for a given component/channel."""
|
|
56
|
+
return self._get_config_property(
|
|
57
|
+
self.number_properties, "limit", component_name, channel_name
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def get_number_multiplier(self, component_name, channel_name) -> dict | None:
|
|
61
|
+
"""Return multiplier for a given component/channel."""
|
|
62
|
+
return self._get_config_property(
|
|
63
|
+
self.number_properties, "multiplier", component_name, channel_name
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def get_number_step(self, component_name, channel_name) -> float | None:
|
|
67
|
+
"""Return the fixed step size for a given component/channel."""
|
|
68
|
+
return self._get_config_property(
|
|
69
|
+
self.number_properties, "step", component_name, channel_name
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def get_number_mode(self, component_name, channel_name) -> str | None:
|
|
73
|
+
"""Return the display mode ("box" or "slider") for a given component/channel."""
|
|
74
|
+
return self._get_config_property(
|
|
75
|
+
self.number_properties, "mode", component_name, channel_name
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
def is_component_enabled(self, comp_name: str) -> bool:
|
|
79
|
+
"""Return if there is at least one channel enabled by default."""
|
|
80
|
+
for entry in self.default_channels:
|
|
81
|
+
if re.fullmatch(entry["component_regexp"], comp_name):
|
|
82
|
+
return True
|
|
83
|
+
|
|
84
|
+
return False
|
|
85
|
+
|
|
86
|
+
def is_channel_enabled(self, comp_name, chan_name) -> bool:
|
|
87
|
+
"""Return True if the channel is enabled by default."""
|
|
88
|
+
for entry in self.default_channels:
|
|
89
|
+
if re.fullmatch(entry["component_regexp"], comp_name):
|
|
90
|
+
if chan_name in entry["channels"]:
|
|
91
|
+
return True
|
|
92
|
+
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
def update_group_members(self, comp_name, chan_name) -> tuple[list[str], Any]:
|
|
96
|
+
"""Return list of all update group members and the condition value."""
|
|
97
|
+
for entry in self.update_groups:
|
|
98
|
+
if re.fullmatch(entry["component_regexp"], comp_name):
|
|
99
|
+
for rule in entry["rules"]:
|
|
100
|
+
if rule["channel"] == chan_name:
|
|
101
|
+
return rule["requires"], rule.get("when")
|
|
102
|
+
|
|
103
|
+
return [], None
|
|
104
|
+
|
|
105
|
+
def get_combined_sensors(self, comp_name) -> list[dict]:
|
|
106
|
+
"""Return list of combined sensors for given component."""
|
|
107
|
+
for entry in self.combined_sensors:
|
|
108
|
+
if re.fullmatch(entry["component_regexp"], comp_name):
|
|
109
|
+
return entry["combined_sensors"]
|
|
110
|
+
|
|
111
|
+
return []
|
openems_client/const.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Constants for the OpenEMS client."""
|
|
2
|
+
|
|
3
|
+
from typing import TypedDict
|
|
4
|
+
|
|
5
|
+
SLASH_ESC = "_s_l_a_s_h_"
|
|
6
|
+
|
|
7
|
+
CONF_COMPONENTS: str = "components"
|
|
8
|
+
CONF_ADVANCED_OPTIONS: str = "advanced_options"
|
|
9
|
+
CONF_IGNORE_DECREASING_IF_TOTAL_INCREASING: str = (
|
|
10
|
+
"ignore_decreasing_if_total_increasing"
|
|
11
|
+
)
|
|
12
|
+
CONF_FORWARD_INTERVAL: str = "forward_interval"
|
|
13
|
+
|
|
14
|
+
CONN_TYPE_DIRECT_EDGE: str = "direct_edge"
|
|
15
|
+
CONN_TYPE_LOCAL_FEMS: str = "local_fems"
|
|
16
|
+
CONN_TYPE_LOCAL_OPENEMS: str = "local_openems"
|
|
17
|
+
CONN_TYPE_WEB_FENECON: str = "web_fenecon"
|
|
18
|
+
CONN_TYPE_CUSTOM_URL: str = "custom_url"
|
|
19
|
+
CONN_TYPE_REST: str = "rest"
|
|
20
|
+
|
|
21
|
+
CURRENT_DATA_TIMEOUT_SECONDS = 60
|
|
22
|
+
WEBSOCKET_HEARTBEAT_SECONDS = 60
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AdvancedOptions(TypedDict):
|
|
26
|
+
"""Type containing the advanced options."""
|
|
27
|
+
|
|
28
|
+
# Right after a restart, for some systems, the FEMS backend reports zero or unexplainably
|
|
29
|
+
# small values for total amount channels. This settles typically after only a few seconds.
|
|
30
|
+
# This parameter allows to ignore such values.
|
|
31
|
+
ignore_decreasing_if_total_increasing: bool
|
|
32
|
+
# 0 = forward currentData updates immediately; >0 = forward at most every N seconds.
|
|
33
|
+
forward_interval: int
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ConfigOptions(TypedDict):
|
|
37
|
+
"""Type containing the config entry options."""
|
|
38
|
+
|
|
39
|
+
components: dict[str, bool]
|
|
40
|
+
advanced_options: AdvancedOptions
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ConnectionType(TypedDict):
|
|
44
|
+
"Type containing the websocket connection parameters."
|
|
45
|
+
|
|
46
|
+
scheme: str
|
|
47
|
+
host: str | None
|
|
48
|
+
port: int
|
|
49
|
+
path: str
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
CONN_TYPES: dict[str, ConnectionType] = {
|
|
53
|
+
CONN_TYPE_DIRECT_EDGE: {
|
|
54
|
+
"scheme": "ws",
|
|
55
|
+
"host": None,
|
|
56
|
+
"port": 8085,
|
|
57
|
+
"path": "/",
|
|
58
|
+
},
|
|
59
|
+
CONN_TYPE_LOCAL_FEMS: {
|
|
60
|
+
"scheme": "ws",
|
|
61
|
+
"host": None,
|
|
62
|
+
"port": 80,
|
|
63
|
+
"path": "/websocket",
|
|
64
|
+
},
|
|
65
|
+
CONN_TYPE_LOCAL_OPENEMS: {
|
|
66
|
+
"scheme": "ws",
|
|
67
|
+
"host": None,
|
|
68
|
+
"port": 8082,
|
|
69
|
+
"path": "/",
|
|
70
|
+
},
|
|
71
|
+
CONN_TYPE_WEB_FENECON: {
|
|
72
|
+
"scheme": "wss",
|
|
73
|
+
"host": "portal.fenecon.de",
|
|
74
|
+
"port": 443,
|
|
75
|
+
"path": "/openems-backend-ui2",
|
|
76
|
+
},
|
|
77
|
+
CONN_TYPE_REST: {
|
|
78
|
+
"scheme": "http",
|
|
79
|
+
"host": None,
|
|
80
|
+
"port": 8084,
|
|
81
|
+
"path": "/rest/",
|
|
82
|
+
},
|
|
83
|
+
}
|