Skip to content

Commit 74981b8

Browse files
authored
Merge pull request #90 from RustyDust/sru_work
Add operating_mode 11
2 parents 9a682b3 + 7e45171 commit 74981b8

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ that should work with current versions of Sonnenbatterie.
1717
## Installation
1818

1919
### 1) via HACS
20+
> [!IMPORTANT]
21+
> This is a **HACS _integration_**, not a **HASS-IO _AddOn_**, so you <ins>need to have [HACS](https://hacs.xyz) installed</ins>,
22+
> and you need to add this repository as a custom **integration repository** to HACS.
23+
2024
1. Add a custom **integration** repository to HACS using this link:
21-
[https://github.com/weltmeyer/hasonnenbatterie](https://github.com/weltmeyer/hasonnenbatterie)
22-
> [!IMPORTANT]
23-
> This is a **HACS _integration_**, not a **HASS-IO _AddOn_**, so you <ins>need to have [HACS](https://hacs.xyz) installed</ins>,
24-
> and you need to add this repository as a custom **integration repository** to HACS.
25+
[https://github.com/weltmeyer/hasonnenbatterie](https://github.com/weltmeyer/hasonnenbatterie)
2526
2. Once the repository is added, use the search bar and type `sonnenbatterie`
2627
3. Use the 3-dot menu to the right of the list entry (not the one at the top bar!) to download/install the integration.
2728
The latest release is automatically selected. Only select a different version if you've been told to do so
@@ -90,6 +91,7 @@ Currently supported actions are:
9091
- `"manual"`
9192
- `"automatic"`
9293
- `"timeofuse"`
94+
- `"optimizing"`
9395

9496
##### Code snippet
9597
``` yaml
@@ -104,13 +106,15 @@ The name of the mode that has been set:
104106
- `manual`
105107
- `automatic`
106108
- `timeofuse`
109+
- `optimizing`
107110

108111
### <a name="set_operatingmode_num"></a>`set_operating_mode_num(mode=<mode>)`
109112
- Sets the operating mode of your SonnenBatterie.
110113
- Supported values for `<mode>` are:
111114
- `1`
112115
- `2`
113116
- `10`
117+
- `11`
114118

115119
##### Code snippet
116120
``` yaml
@@ -125,6 +129,7 @@ An `int` representing the mode that has been set:
125129
- 1: `manual`
126130
- 2: `automatic`
127131
- 10: `timeofuse`
132+
- 11: `optimizing`
128133

129134
### `charge_battery(power=<power>)`
130135
> [!IMPORTANT]
@@ -210,6 +215,7 @@ An integer representing the current value of "battery reserve"
210215
- `manual`
211216
- `automatic`
212217
- `timeofuse`
218+
- `optimizing`
213219
- _prefer [`set_operating_mode`](.#set_operatingmode)) over this_
214220
- "EM_ToU_Schedule"
215221
- set a scheulde for charging in ToU mode
@@ -312,6 +318,7 @@ The name of the mode that has been set:
312318
- `manual`
313319
- `automatic`
314320
- `timeofuse`
321+
- `optimizing`
315322

316323
### <a name="get_operatingmode_num"></a>`get_operating_mode_num()`
317324
- Retrieves the current operating mode of your SonnenBatterie in numeric form
@@ -328,6 +335,7 @@ An `int` representing the mode that has been set:
328335
- 1: `manual`
329336
- 2: `automatic`
330337
- 10: `timeofuse`
338+
- 11: `optimizing`
331339

332340
## Problems and/or unused/unavailable sensors
333341
Depending on the software on and the operating mode of your Sonnenbatterie some

custom_components/sonnenbatterie/const.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
CONF_OPERATING_MODES = [
2626
"manual",
2727
"automatic",
28-
"timeofuse"
28+
"timeofuse",
29+
"optimizing"
2930
]
3031

3132
CONF_OPERATING_MODES_NUM = [
3233
"1",
3334
"2",
34-
"10"
35+
"10",
36+
"11"
3537
]
3638

3739
CONF_CHARGE_WATT = "power"
@@ -49,14 +51,19 @@
4951
SB_OPERATING_MODES: Final = {
5052
"manual": 1,
5153
"automatic": 2,
54+
"testing": 4,
5255
"expansion": 6,
53-
"timeofuse": 10
56+
"timeofuse": 10,
57+
"optimizing": 11
5458
}
5559

5660
SB_OPERATING_MODES_NUM: Final = {
5761
'1': "manual",
5862
'2': "automatic",
59-
'10': "timeofuse"
63+
'4': "testing",
64+
'6': "expansion",
65+
'10': "timeofuse",
66+
'11': "optimizing"
6067
}
6168

6269
# rustydust_241227: doesn't seem to be used anywhere

custom_components/sonnenbatterie/service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ async def set_tou_schedule(self, call: ServiceCall) -> ServiceResponse:
114114
except ValueError as e:
115115
raise HomeAssistantError(f"Schedule is not a valid JSON string: '{schedule}'") from e
116116

117-
if json_schedule['threshold_p_max'] > self._tou_max:
118-
LOGGER.warning(f"Specified 'threshold_p_max' exceeds configured limit of {self._tou_max}, value capped to {json_schedule['threshold_p_max']}")
119-
json_schedule['threshold_p_max'] = self._tou_max
117+
for lp in range(len(json_schedule)):
118+
if json_schedule[lp]['threshold_p_max'] > self._tou_max:
119+
LOGGER.warning(f"Specified 'threshold_p_max' exceeds configured limit of {self._tou_max}, value capped to {json_schedule[lp]['threshold_p_max']}")
120+
json_schedule[lp]['threshold_p_max'] = self._tou_max
120121

121122
tou = TimeofUseSchedule()
122123
try:

custom_components/sonnenbatterie/translations/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@
117117
"state": {
118118
"1": "Manuell",
119119
"2": "Automatisch",
120+
"4": "Testbetrieb",
120121
"6": "Erweiterungsmodul",
121-
"10": "Zeitgesteuert"
122+
"10": "Zeitgesteuert",
123+
"11": "Auto-Optimierung"
122124
}
123125
},
124126
"battery_system_cycles": {

custom_components/sonnenbatterie/translations/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@
118118
"state": {
119119
"1": "Manual",
120120
"2": "Automatic",
121+
"4": "Testing",
121122
"6": "Extension module",
122-
"10": "Time of Use"
123+
"10": "Time of Use",
124+
"11": "Optimization"
123125
}
124126
},
125127
"battery_system_cycles": {

0 commit comments

Comments
 (0)