Homevolt 0.4.4__tar.gz → 0.6.0__tar.gz
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.
- {homevolt-0.4.4 → homevolt-0.6.0}/Homevolt.egg-info/PKG-INFO +49 -52
- {homevolt-0.4.4 → homevolt-0.6.0}/Homevolt.egg-info/SOURCES.txt +4 -1
- {homevolt-0.4.4 → homevolt-0.6.0}/PKG-INFO +49 -52
- {homevolt-0.4.4 → homevolt-0.6.0}/README.md +46 -51
- {homevolt-0.4.4 → homevolt-0.6.0}/homevolt/const.py +12 -0
- homevolt-0.6.0/homevolt/homevolt.py +988 -0
- homevolt-0.6.0/homevolt/py.typed +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/pyproject.toml +32 -2
- homevolt-0.6.0/tests/test_control.py +824 -0
- homevolt-0.6.0/tests/test_ems.py +8 -0
- homevolt-0.4.4/homevolt/homevolt.py +0 -408
- {homevolt-0.4.4 → homevolt-0.6.0}/Homevolt.egg-info/dependency_links.txt +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/Homevolt.egg-info/requires.txt +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/Homevolt.egg-info/top_level.txt +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/LICENSE +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/homevolt/__init__.py +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/homevolt/exceptions.py +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/homevolt/models.py +0 -0
- {homevolt-0.4.4 → homevolt-0.6.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Homevolt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Python library for Homevolt EMS devices
|
|
5
5
|
Author-email: Daniel Høyer <github@dahoiv.net>
|
|
6
6
|
License: GPL-3.0
|
|
@@ -10,6 +10,8 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Typing :: Typed
|
|
13
15
|
Requires-Python: >=3.12
|
|
14
16
|
Description-Content-Type: text/markdown
|
|
15
17
|
License-File: LICENSE
|
|
@@ -21,12 +23,14 @@ Dynamic: license-file
|
|
|
21
23
|
Python library for Homevolt EMS devices.
|
|
22
24
|
|
|
23
25
|
Get real-time data from your Homevolt Energy Management System, including:
|
|
26
|
+
|
|
24
27
|
- Voltage, current, and power measurements
|
|
25
28
|
- Battery state of charge and temperature
|
|
26
29
|
- Grid, solar, and load sensor data
|
|
27
30
|
- Schedule information
|
|
28
31
|
|
|
29
32
|
Control your battery with:
|
|
33
|
+
|
|
30
34
|
- Immediate battery control (charge, discharge, idle)
|
|
31
35
|
- Scheduled battery operations
|
|
32
36
|
- Local mode management
|
|
@@ -38,6 +42,25 @@ Control your battery with:
|
|
|
38
42
|
pip install homevolt
|
|
39
43
|
```
|
|
40
44
|
|
|
45
|
+
## Development
|
|
46
|
+
|
|
47
|
+
This repository supports a standard `uv` development workflow.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv sync --dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
That creates a local environment with the package and development tools installed.
|
|
54
|
+
|
|
55
|
+
Common commands:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv run pre-commit run --all-files
|
|
59
|
+
uv run ruff check .
|
|
60
|
+
uv run mypy homevolt
|
|
61
|
+
uv run pytest
|
|
62
|
+
```
|
|
63
|
+
|
|
41
64
|
## Example
|
|
42
65
|
|
|
43
66
|
```python
|
|
@@ -119,35 +142,17 @@ async def main():
|
|
|
119
142
|
# Enable local mode to prevent remote schedule overrides
|
|
120
143
|
await homevolt_connection.enable_local_mode()
|
|
121
144
|
|
|
122
|
-
#
|
|
123
|
-
await homevolt_connection.
|
|
145
|
+
# Replace the current schedule with immediate inverter-charge control.
|
|
146
|
+
await homevolt_connection.set_battery_mode("inverter_charge")
|
|
124
147
|
|
|
125
|
-
#
|
|
126
|
-
await homevolt_connection.
|
|
127
|
-
|
|
148
|
+
# Refresh once so the new Manual Schedule entry can be updated safely.
|
|
149
|
+
await homevolt_connection.fetch_schedule_data()
|
|
150
|
+
await homevolt_connection.set_battery_parameters(
|
|
128
151
|
max_charge=3000,
|
|
152
|
+
min_soc=20,
|
|
129
153
|
max_soc=90,
|
|
130
154
|
)
|
|
131
155
|
|
|
132
|
-
# Schedule night charging (11 PM - 7 AM)
|
|
133
|
-
from datetime import datetime, timedelta
|
|
134
|
-
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
135
|
-
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
136
|
-
|
|
137
|
-
await homevolt_connection.add_schedule(
|
|
138
|
-
mode=1, # Inverter Charge
|
|
139
|
-
from_time=tonight.isoformat(),
|
|
140
|
-
to_time=tomorrow.isoformat(),
|
|
141
|
-
max_charge=3000,
|
|
142
|
-
max_soc=80,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
# Set battery to idle
|
|
146
|
-
await homevolt_connection.set_battery_idle()
|
|
147
|
-
|
|
148
|
-
# Discharge during peak hours
|
|
149
|
-
await homevolt_connection.discharge_battery(max_power=2500, min_soc=30)
|
|
150
|
-
|
|
151
156
|
|
|
152
157
|
if __name__ == "__main__":
|
|
153
158
|
asyncio.run(main())
|
|
@@ -155,18 +160,21 @@ if __name__ == "__main__":
|
|
|
155
160
|
|
|
156
161
|
## Battery Control Modes
|
|
157
162
|
|
|
158
|
-
The following
|
|
163
|
+
The following mode strings are available for battery control:
|
|
159
164
|
|
|
160
|
-
- `
|
|
161
|
-
- `
|
|
162
|
-
- `
|
|
163
|
-
- `
|
|
164
|
-
- `
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
- `idle`: Battery standby (mode 0)
|
|
166
|
+
- `inverter_charge`: Charge via the inverter from grid/solar (mode 1)
|
|
167
|
+
- `inverter_discharge`: Discharge via the inverter to home/grid (mode 2)
|
|
168
|
+
- `frequency_reserve`: Frequency regulation service mode (mode 6)
|
|
169
|
+
- `solar_charge`: Charge from solar production only (mode 7)
|
|
170
|
+
|
|
171
|
+
Other firmware schedule types are intentionally rejected because current firmware
|
|
172
|
+
does not create a matching manual schedule for them.
|
|
173
|
+
|
|
174
|
+
Battery writes require local mode to be enabled first. `set_battery_mode()` uses the
|
|
175
|
+
device's `sched_set` command, so it replaces the complete current schedule with one
|
|
176
|
+
immediate `Manual Schedule` entry. `set_battery_parameters()` only accepts that
|
|
177
|
+
single manual entry and refuses writes that would discard unsupported parameters.
|
|
170
178
|
|
|
171
179
|
## API Reference
|
|
172
180
|
|
|
@@ -188,6 +196,7 @@ Initialize a Homevolt connection.
|
|
|
188
196
|
- `sensors` (dict[str, Sensor]): Dictionary of sensor readings
|
|
189
197
|
- `device_metadata` (dict[str, DeviceMetadata]): Dictionary of device metadata
|
|
190
198
|
- `current_schedule` (dict | None): Current schedule information
|
|
199
|
+
- `battery_parameters_writable` (bool): Whether the current manual entry supports partial writes
|
|
191
200
|
|
|
192
201
|
#### Methods
|
|
193
202
|
|
|
@@ -198,25 +207,13 @@ Initialize a Homevolt connection.
|
|
|
198
207
|
|
|
199
208
|
#### Battery Control Methods
|
|
200
209
|
|
|
201
|
-
|
|
202
|
-
- `async
|
|
203
|
-
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
204
|
-
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
205
|
-
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
206
|
-
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
207
|
-
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
208
|
-
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
209
|
-
|
|
210
|
-
**Scheduled Control:**
|
|
211
|
-
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
212
|
-
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
213
|
-
- `async clear_all_schedules()`: Clear all schedules
|
|
210
|
+
- `async set_battery_mode(mode)`: Replace the schedule with an immediate control mode
|
|
211
|
+
- `async set_battery_parameters(**kwargs)`: Update supported values on one manual entry
|
|
214
212
|
|
|
215
213
|
**Configuration:**
|
|
214
|
+
|
|
216
215
|
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
217
216
|
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
218
|
-
- `async set_parameter(key, value)`: Set a device parameter
|
|
219
|
-
- `async get_parameter(key)`: Get a device parameter value
|
|
220
217
|
|
|
221
218
|
### Data Models
|
|
222
219
|
|
|
@@ -234,6 +231,7 @@ Initialize a Homevolt connection.
|
|
|
234
231
|
#### SensorType
|
|
235
232
|
|
|
236
233
|
Enumeration of sensor types:
|
|
234
|
+
|
|
237
235
|
- `VOLTAGE`
|
|
238
236
|
- `CURRENT`
|
|
239
237
|
- `POWER`
|
|
@@ -257,4 +255,3 @@ Enumeration of sensor types:
|
|
|
257
255
|
## License
|
|
258
256
|
|
|
259
257
|
GPL-3.0
|
|
260
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Homevolt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Python library for Homevolt EMS devices
|
|
5
5
|
Author-email: Daniel Høyer <github@dahoiv.net>
|
|
6
6
|
License: GPL-3.0
|
|
@@ -10,6 +10,8 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Typing :: Typed
|
|
13
15
|
Requires-Python: >=3.12
|
|
14
16
|
Description-Content-Type: text/markdown
|
|
15
17
|
License-File: LICENSE
|
|
@@ -21,12 +23,14 @@ Dynamic: license-file
|
|
|
21
23
|
Python library for Homevolt EMS devices.
|
|
22
24
|
|
|
23
25
|
Get real-time data from your Homevolt Energy Management System, including:
|
|
26
|
+
|
|
24
27
|
- Voltage, current, and power measurements
|
|
25
28
|
- Battery state of charge and temperature
|
|
26
29
|
- Grid, solar, and load sensor data
|
|
27
30
|
- Schedule information
|
|
28
31
|
|
|
29
32
|
Control your battery with:
|
|
33
|
+
|
|
30
34
|
- Immediate battery control (charge, discharge, idle)
|
|
31
35
|
- Scheduled battery operations
|
|
32
36
|
- Local mode management
|
|
@@ -38,6 +42,25 @@ Control your battery with:
|
|
|
38
42
|
pip install homevolt
|
|
39
43
|
```
|
|
40
44
|
|
|
45
|
+
## Development
|
|
46
|
+
|
|
47
|
+
This repository supports a standard `uv` development workflow.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv sync --dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
That creates a local environment with the package and development tools installed.
|
|
54
|
+
|
|
55
|
+
Common commands:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv run pre-commit run --all-files
|
|
59
|
+
uv run ruff check .
|
|
60
|
+
uv run mypy homevolt
|
|
61
|
+
uv run pytest
|
|
62
|
+
```
|
|
63
|
+
|
|
41
64
|
## Example
|
|
42
65
|
|
|
43
66
|
```python
|
|
@@ -119,35 +142,17 @@ async def main():
|
|
|
119
142
|
# Enable local mode to prevent remote schedule overrides
|
|
120
143
|
await homevolt_connection.enable_local_mode()
|
|
121
144
|
|
|
122
|
-
#
|
|
123
|
-
await homevolt_connection.
|
|
145
|
+
# Replace the current schedule with immediate inverter-charge control.
|
|
146
|
+
await homevolt_connection.set_battery_mode("inverter_charge")
|
|
124
147
|
|
|
125
|
-
#
|
|
126
|
-
await homevolt_connection.
|
|
127
|
-
|
|
148
|
+
# Refresh once so the new Manual Schedule entry can be updated safely.
|
|
149
|
+
await homevolt_connection.fetch_schedule_data()
|
|
150
|
+
await homevolt_connection.set_battery_parameters(
|
|
128
151
|
max_charge=3000,
|
|
152
|
+
min_soc=20,
|
|
129
153
|
max_soc=90,
|
|
130
154
|
)
|
|
131
155
|
|
|
132
|
-
# Schedule night charging (11 PM - 7 AM)
|
|
133
|
-
from datetime import datetime, timedelta
|
|
134
|
-
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
135
|
-
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
136
|
-
|
|
137
|
-
await homevolt_connection.add_schedule(
|
|
138
|
-
mode=1, # Inverter Charge
|
|
139
|
-
from_time=tonight.isoformat(),
|
|
140
|
-
to_time=tomorrow.isoformat(),
|
|
141
|
-
max_charge=3000,
|
|
142
|
-
max_soc=80,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
# Set battery to idle
|
|
146
|
-
await homevolt_connection.set_battery_idle()
|
|
147
|
-
|
|
148
|
-
# Discharge during peak hours
|
|
149
|
-
await homevolt_connection.discharge_battery(max_power=2500, min_soc=30)
|
|
150
|
-
|
|
151
156
|
|
|
152
157
|
if __name__ == "__main__":
|
|
153
158
|
asyncio.run(main())
|
|
@@ -155,18 +160,21 @@ if __name__ == "__main__":
|
|
|
155
160
|
|
|
156
161
|
## Battery Control Modes
|
|
157
162
|
|
|
158
|
-
The following
|
|
163
|
+
The following mode strings are available for battery control:
|
|
159
164
|
|
|
160
|
-
- `
|
|
161
|
-
- `
|
|
162
|
-
- `
|
|
163
|
-
- `
|
|
164
|
-
- `
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
- `idle`: Battery standby (mode 0)
|
|
166
|
+
- `inverter_charge`: Charge via the inverter from grid/solar (mode 1)
|
|
167
|
+
- `inverter_discharge`: Discharge via the inverter to home/grid (mode 2)
|
|
168
|
+
- `frequency_reserve`: Frequency regulation service mode (mode 6)
|
|
169
|
+
- `solar_charge`: Charge from solar production only (mode 7)
|
|
170
|
+
|
|
171
|
+
Other firmware schedule types are intentionally rejected because current firmware
|
|
172
|
+
does not create a matching manual schedule for them.
|
|
173
|
+
|
|
174
|
+
Battery writes require local mode to be enabled first. `set_battery_mode()` uses the
|
|
175
|
+
device's `sched_set` command, so it replaces the complete current schedule with one
|
|
176
|
+
immediate `Manual Schedule` entry. `set_battery_parameters()` only accepts that
|
|
177
|
+
single manual entry and refuses writes that would discard unsupported parameters.
|
|
170
178
|
|
|
171
179
|
## API Reference
|
|
172
180
|
|
|
@@ -188,6 +196,7 @@ Initialize a Homevolt connection.
|
|
|
188
196
|
- `sensors` (dict[str, Sensor]): Dictionary of sensor readings
|
|
189
197
|
- `device_metadata` (dict[str, DeviceMetadata]): Dictionary of device metadata
|
|
190
198
|
- `current_schedule` (dict | None): Current schedule information
|
|
199
|
+
- `battery_parameters_writable` (bool): Whether the current manual entry supports partial writes
|
|
191
200
|
|
|
192
201
|
#### Methods
|
|
193
202
|
|
|
@@ -198,25 +207,13 @@ Initialize a Homevolt connection.
|
|
|
198
207
|
|
|
199
208
|
#### Battery Control Methods
|
|
200
209
|
|
|
201
|
-
|
|
202
|
-
- `async
|
|
203
|
-
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
204
|
-
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
205
|
-
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
206
|
-
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
207
|
-
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
208
|
-
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
209
|
-
|
|
210
|
-
**Scheduled Control:**
|
|
211
|
-
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
212
|
-
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
213
|
-
- `async clear_all_schedules()`: Clear all schedules
|
|
210
|
+
- `async set_battery_mode(mode)`: Replace the schedule with an immediate control mode
|
|
211
|
+
- `async set_battery_parameters(**kwargs)`: Update supported values on one manual entry
|
|
214
212
|
|
|
215
213
|
**Configuration:**
|
|
214
|
+
|
|
216
215
|
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
217
216
|
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
218
|
-
- `async set_parameter(key, value)`: Set a device parameter
|
|
219
|
-
- `async get_parameter(key)`: Get a device parameter value
|
|
220
217
|
|
|
221
218
|
### Data Models
|
|
222
219
|
|
|
@@ -234,6 +231,7 @@ Initialize a Homevolt connection.
|
|
|
234
231
|
#### SensorType
|
|
235
232
|
|
|
236
233
|
Enumeration of sensor types:
|
|
234
|
+
|
|
237
235
|
- `VOLTAGE`
|
|
238
236
|
- `CURRENT`
|
|
239
237
|
- `POWER`
|
|
@@ -257,4 +255,3 @@ Enumeration of sensor types:
|
|
|
257
255
|
## License
|
|
258
256
|
|
|
259
257
|
GPL-3.0
|
|
260
|
-
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Python library for Homevolt EMS devices.
|
|
4
4
|
|
|
5
5
|
Get real-time data from your Homevolt Energy Management System, including:
|
|
6
|
+
|
|
6
7
|
- Voltage, current, and power measurements
|
|
7
8
|
- Battery state of charge and temperature
|
|
8
9
|
- Grid, solar, and load sensor data
|
|
9
10
|
- Schedule information
|
|
10
11
|
|
|
11
12
|
Control your battery with:
|
|
13
|
+
|
|
12
14
|
- Immediate battery control (charge, discharge, idle)
|
|
13
15
|
- Scheduled battery operations
|
|
14
16
|
- Local mode management
|
|
@@ -20,6 +22,25 @@ Control your battery with:
|
|
|
20
22
|
pip install homevolt
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
This repository supports a standard `uv` development workflow.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv sync --dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
That creates a local environment with the package and development tools installed.
|
|
34
|
+
|
|
35
|
+
Common commands:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv run pre-commit run --all-files
|
|
39
|
+
uv run ruff check .
|
|
40
|
+
uv run mypy homevolt
|
|
41
|
+
uv run pytest
|
|
42
|
+
```
|
|
43
|
+
|
|
23
44
|
## Example
|
|
24
45
|
|
|
25
46
|
```python
|
|
@@ -101,35 +122,17 @@ async def main():
|
|
|
101
122
|
# Enable local mode to prevent remote schedule overrides
|
|
102
123
|
await homevolt_connection.enable_local_mode()
|
|
103
124
|
|
|
104
|
-
#
|
|
105
|
-
await homevolt_connection.
|
|
125
|
+
# Replace the current schedule with immediate inverter-charge control.
|
|
126
|
+
await homevolt_connection.set_battery_mode("inverter_charge")
|
|
106
127
|
|
|
107
|
-
#
|
|
108
|
-
await homevolt_connection.
|
|
109
|
-
|
|
128
|
+
# Refresh once so the new Manual Schedule entry can be updated safely.
|
|
129
|
+
await homevolt_connection.fetch_schedule_data()
|
|
130
|
+
await homevolt_connection.set_battery_parameters(
|
|
110
131
|
max_charge=3000,
|
|
132
|
+
min_soc=20,
|
|
111
133
|
max_soc=90,
|
|
112
134
|
)
|
|
113
135
|
|
|
114
|
-
# Schedule night charging (11 PM - 7 AM)
|
|
115
|
-
from datetime import datetime, timedelta
|
|
116
|
-
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
117
|
-
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
118
|
-
|
|
119
|
-
await homevolt_connection.add_schedule(
|
|
120
|
-
mode=1, # Inverter Charge
|
|
121
|
-
from_time=tonight.isoformat(),
|
|
122
|
-
to_time=tomorrow.isoformat(),
|
|
123
|
-
max_charge=3000,
|
|
124
|
-
max_soc=80,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
# Set battery to idle
|
|
128
|
-
await homevolt_connection.set_battery_idle()
|
|
129
|
-
|
|
130
|
-
# Discharge during peak hours
|
|
131
|
-
await homevolt_connection.discharge_battery(max_power=2500, min_soc=30)
|
|
132
|
-
|
|
133
136
|
|
|
134
137
|
if __name__ == "__main__":
|
|
135
138
|
asyncio.run(main())
|
|
@@ -137,18 +140,21 @@ if __name__ == "__main__":
|
|
|
137
140
|
|
|
138
141
|
## Battery Control Modes
|
|
139
142
|
|
|
140
|
-
The following
|
|
143
|
+
The following mode strings are available for battery control:
|
|
141
144
|
|
|
142
|
-
- `
|
|
143
|
-
- `
|
|
144
|
-
- `
|
|
145
|
-
- `
|
|
146
|
-
- `
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
- `idle`: Battery standby (mode 0)
|
|
146
|
+
- `inverter_charge`: Charge via the inverter from grid/solar (mode 1)
|
|
147
|
+
- `inverter_discharge`: Discharge via the inverter to home/grid (mode 2)
|
|
148
|
+
- `frequency_reserve`: Frequency regulation service mode (mode 6)
|
|
149
|
+
- `solar_charge`: Charge from solar production only (mode 7)
|
|
150
|
+
|
|
151
|
+
Other firmware schedule types are intentionally rejected because current firmware
|
|
152
|
+
does not create a matching manual schedule for them.
|
|
153
|
+
|
|
154
|
+
Battery writes require local mode to be enabled first. `set_battery_mode()` uses the
|
|
155
|
+
device's `sched_set` command, so it replaces the complete current schedule with one
|
|
156
|
+
immediate `Manual Schedule` entry. `set_battery_parameters()` only accepts that
|
|
157
|
+
single manual entry and refuses writes that would discard unsupported parameters.
|
|
152
158
|
|
|
153
159
|
## API Reference
|
|
154
160
|
|
|
@@ -170,6 +176,7 @@ Initialize a Homevolt connection.
|
|
|
170
176
|
- `sensors` (dict[str, Sensor]): Dictionary of sensor readings
|
|
171
177
|
- `device_metadata` (dict[str, DeviceMetadata]): Dictionary of device metadata
|
|
172
178
|
- `current_schedule` (dict | None): Current schedule information
|
|
179
|
+
- `battery_parameters_writable` (bool): Whether the current manual entry supports partial writes
|
|
173
180
|
|
|
174
181
|
#### Methods
|
|
175
182
|
|
|
@@ -180,25 +187,13 @@ Initialize a Homevolt connection.
|
|
|
180
187
|
|
|
181
188
|
#### Battery Control Methods
|
|
182
189
|
|
|
183
|
-
|
|
184
|
-
- `async
|
|
185
|
-
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
186
|
-
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
187
|
-
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
188
|
-
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
189
|
-
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
190
|
-
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
191
|
-
|
|
192
|
-
**Scheduled Control:**
|
|
193
|
-
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
194
|
-
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
195
|
-
- `async clear_all_schedules()`: Clear all schedules
|
|
190
|
+
- `async set_battery_mode(mode)`: Replace the schedule with an immediate control mode
|
|
191
|
+
- `async set_battery_parameters(**kwargs)`: Update supported values on one manual entry
|
|
196
192
|
|
|
197
193
|
**Configuration:**
|
|
194
|
+
|
|
198
195
|
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
199
196
|
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
200
|
-
- `async set_parameter(key, value)`: Set a device parameter
|
|
201
|
-
- `async get_parameter(key)`: Get a device parameter value
|
|
202
197
|
|
|
203
198
|
### Data Models
|
|
204
199
|
|
|
@@ -216,6 +211,7 @@ Initialize a Homevolt connection.
|
|
|
216
211
|
#### SensorType
|
|
217
212
|
|
|
218
213
|
Enumeration of sensor types:
|
|
214
|
+
|
|
219
215
|
- `VOLTAGE`
|
|
220
216
|
- `CURRENT`
|
|
221
217
|
- `POWER`
|
|
@@ -239,4 +235,3 @@ Enumeration of sensor types:
|
|
|
239
235
|
## License
|
|
240
236
|
|
|
241
237
|
GPL-3.0
|
|
242
|
-
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
"""Constants for the Homevolt library."""
|
|
2
2
|
|
|
3
|
+
# Connection settings
|
|
4
|
+
DEFAULT_CONNECT_TIMEOUT = 10
|
|
5
|
+
DEFAULT_READ_TIMEOUT = 30
|
|
6
|
+
RETRY_COUNT = 3
|
|
7
|
+
RETRY_BACKOFF_FACTOR = 2.0
|
|
8
|
+
RETRY_STATUS_CODES = {502, 503, 504}
|
|
9
|
+
|
|
3
10
|
# API endpoints
|
|
4
11
|
ENDPOINT_EMS = "/ems.json"
|
|
5
12
|
ENDPOINT_SCHEDULE = "/schedule.json"
|
|
@@ -20,6 +27,11 @@ SCHEDULE_TYPE = {
|
|
|
20
27
|
9: "full_solar_export",
|
|
21
28
|
}
|
|
22
29
|
|
|
30
|
+
# Modes confirmed to produce a matching manual schedule on current firmware.
|
|
31
|
+
CONTROLLABLE_SCHEDULE_TYPE = {
|
|
32
|
+
mode: option for mode, option in SCHEDULE_TYPE.items() if mode in {0, 1, 2, 6, 7}
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
# Device type mappings for sensors
|
|
24
36
|
DEVICE_MAP = {
|
|
25
37
|
"grid": "grid",
|