Homevolt 0.1.0__tar.gz → 0.2.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.1.0 → homevolt-0.2.0}/Homevolt.egg-info/PKG-INFO +106 -8
- {homevolt-0.1.0 → homevolt-0.2.0}/PKG-INFO +106 -8
- {homevolt-0.1.0 → homevolt-0.2.0}/README.md +105 -7
- {homevolt-0.1.0 → homevolt-0.2.0}/homevolt/__init__.py +2 -3
- homevolt-0.2.0/homevolt/const.py +28 -0
- homevolt-0.2.0/homevolt/device.py +760 -0
- {homevolt-0.1.0 → homevolt-0.2.0}/homevolt/exceptions.py +4 -5
- {homevolt-0.1.0 → homevolt-0.2.0}/homevolt/homevolt.py +1 -1
- {homevolt-0.1.0 → homevolt-0.2.0}/homevolt/models.py +0 -1
- {homevolt-0.1.0 → homevolt-0.2.0}/pyproject.toml +1 -1
- homevolt-0.1.0/homevolt/const.py +0 -23
- homevolt-0.1.0/homevolt/device.py +0 -329
- {homevolt-0.1.0 → homevolt-0.2.0}/Homevolt.egg-info/SOURCES.txt +0 -0
- {homevolt-0.1.0 → homevolt-0.2.0}/Homevolt.egg-info/dependency_links.txt +0 -0
- {homevolt-0.1.0 → homevolt-0.2.0}/Homevolt.egg-info/requires.txt +0 -0
- {homevolt-0.1.0 → homevolt-0.2.0}/Homevolt.egg-info/top_level.txt +0 -0
- {homevolt-0.1.0 → homevolt-0.2.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.2.0
|
|
4
4
|
Summary: Python library for Homevolt EMS devices
|
|
5
5
|
Author-email: Your Name <your.email@example.com>
|
|
6
6
|
License: GPL-3.0
|
|
@@ -24,6 +24,12 @@ Get real-time data from your Homevolt Energy Management System, including:
|
|
|
24
24
|
- Grid, solar, and load sensor data
|
|
25
25
|
- Schedule information
|
|
26
26
|
|
|
27
|
+
Control your battery with:
|
|
28
|
+
- Immediate battery control (charge, discharge, idle)
|
|
29
|
+
- Scheduled battery operations
|
|
30
|
+
- Local mode management
|
|
31
|
+
- Parameter configuration
|
|
32
|
+
|
|
27
33
|
## Install
|
|
28
34
|
|
|
29
35
|
```bash
|
|
@@ -46,20 +52,20 @@ async def main():
|
|
|
46
52
|
websession=session,
|
|
47
53
|
)
|
|
48
54
|
await homevolt_connection.update_info()
|
|
49
|
-
|
|
55
|
+
|
|
50
56
|
device = homevolt_connection.get_device()
|
|
51
57
|
print(f"Device ID: {device.device_id}")
|
|
52
58
|
print(f"Current Power: {device.sensors['Power'].value} W")
|
|
53
59
|
print(f"Battery SOC: {device.sensors['Battery State of Charge'].value * 100}%")
|
|
54
|
-
|
|
60
|
+
|
|
55
61
|
# Access all sensors
|
|
56
62
|
for sensor_name, sensor in device.sensors.items():
|
|
57
63
|
print(f"{sensor_name}: {sensor.value} ({sensor.type.value})")
|
|
58
|
-
|
|
64
|
+
|
|
59
65
|
# Access device metadata
|
|
60
66
|
for device_id, metadata in device.device_metadata.items():
|
|
61
67
|
print(f"{device_id}: {metadata.name} ({metadata.model})")
|
|
62
|
-
|
|
68
|
+
|
|
63
69
|
await homevolt_connection.close_connection()
|
|
64
70
|
|
|
65
71
|
|
|
@@ -83,10 +89,10 @@ async def main():
|
|
|
83
89
|
websession=session,
|
|
84
90
|
) as homevolt_connection:
|
|
85
91
|
await homevolt_connection.update_info()
|
|
86
|
-
|
|
92
|
+
|
|
87
93
|
device = homevolt_connection.get_device()
|
|
88
94
|
await device.update_info() # Refresh data
|
|
89
|
-
|
|
95
|
+
|
|
90
96
|
print(f"Device ID: {device.device_id}")
|
|
91
97
|
print(f"Available sensors: {list(device.sensors.keys())}")
|
|
92
98
|
|
|
@@ -95,6 +101,76 @@ if __name__ == "__main__":
|
|
|
95
101
|
asyncio.run(main())
|
|
96
102
|
```
|
|
97
103
|
|
|
104
|
+
## Battery Control Example
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import asyncio
|
|
108
|
+
import aiohttp
|
|
109
|
+
import homevolt
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def main():
|
|
113
|
+
async with aiohttp.ClientSession() as session:
|
|
114
|
+
async with homevolt.Homevolt(
|
|
115
|
+
ip_address="192.168.1.100",
|
|
116
|
+
password="optional_password",
|
|
117
|
+
websession=session,
|
|
118
|
+
) as homevolt_connection:
|
|
119
|
+
await homevolt_connection.update_info()
|
|
120
|
+
device = homevolt_connection.get_device()
|
|
121
|
+
|
|
122
|
+
# Enable local mode to prevent remote schedule overrides
|
|
123
|
+
await device.enable_local_mode()
|
|
124
|
+
|
|
125
|
+
# Charge battery immediately (up to 3000W, stop at 90% SOC)
|
|
126
|
+
await device.charge_battery(max_power=3000, max_soc=90)
|
|
127
|
+
|
|
128
|
+
# Or use the full control method
|
|
129
|
+
await device.set_battery_mode(
|
|
130
|
+
mode=1, # Inverter Charge
|
|
131
|
+
max_charge=3000,
|
|
132
|
+
max_soc=90,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Schedule night charging (11 PM - 7 AM)
|
|
136
|
+
from datetime import datetime, timedelta
|
|
137
|
+
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
138
|
+
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
139
|
+
|
|
140
|
+
await device.add_schedule(
|
|
141
|
+
mode=1, # Inverter Charge
|
|
142
|
+
from_time=tonight.isoformat(),
|
|
143
|
+
to_time=tomorrow.isoformat(),
|
|
144
|
+
max_charge=3000,
|
|
145
|
+
max_soc=80,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Set battery to idle
|
|
149
|
+
await device.set_battery_idle()
|
|
150
|
+
|
|
151
|
+
# Discharge during peak hours
|
|
152
|
+
await device.discharge_battery(max_power=2500, min_soc=30)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
asyncio.run(main())
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Battery Control Modes
|
|
160
|
+
|
|
161
|
+
The following modes are available for battery control:
|
|
162
|
+
|
|
163
|
+
- `0`: Idle - Battery standby (no charge/discharge)
|
|
164
|
+
- `1`: Inverter Charge - Charge battery via inverter from grid/solar
|
|
165
|
+
- `2`: Inverter Discharge - Discharge battery via inverter to home/grid
|
|
166
|
+
- `3`: Grid Charge - Charge from grid with power setpoint
|
|
167
|
+
- `4`: Grid Discharge - Discharge to grid with power setpoint
|
|
168
|
+
- `5`: Grid Charge/Discharge - Bidirectional grid control
|
|
169
|
+
- `6`: Frequency Reserve - Frequency regulation service mode
|
|
170
|
+
- `7`: Solar Charge - Charge from solar production only
|
|
171
|
+
- `8`: Solar Charge/Discharge - Solar-based grid management
|
|
172
|
+
- `9`: Full Solar Export - Export all solar production
|
|
173
|
+
|
|
98
174
|
## API Reference
|
|
99
175
|
|
|
100
176
|
### Homevolt
|
|
@@ -132,6 +208,28 @@ Represents a Homevolt EMS device.
|
|
|
132
208
|
- `async fetch_ems_data()`: Fetch EMS data specifically
|
|
133
209
|
- `async fetch_schedule_data()`: Fetch schedule data specifically
|
|
134
210
|
|
|
211
|
+
#### Battery Control Methods
|
|
212
|
+
|
|
213
|
+
**Immediate Control:**
|
|
214
|
+
- `async set_battery_mode(mode, **kwargs)`: Set immediate battery control mode
|
|
215
|
+
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
216
|
+
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
217
|
+
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
218
|
+
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
219
|
+
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
220
|
+
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
221
|
+
|
|
222
|
+
**Scheduled Control:**
|
|
223
|
+
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
224
|
+
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
225
|
+
- `async clear_all_schedules()`: Clear all schedules
|
|
226
|
+
|
|
227
|
+
**Configuration:**
|
|
228
|
+
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
229
|
+
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
230
|
+
- `async set_parameter(key, value)`: Set a device parameter
|
|
231
|
+
- `async get_parameter(key)`: Get a device parameter value
|
|
232
|
+
|
|
135
233
|
### Data Models
|
|
136
234
|
|
|
137
235
|
#### Sensor
|
|
@@ -163,7 +261,7 @@ Enumeration of sensor types:
|
|
|
163
261
|
|
|
164
262
|
### Exceptions
|
|
165
263
|
|
|
166
|
-
- `
|
|
264
|
+
- `HomevoltError`: Base exception for all Homevolt errors
|
|
167
265
|
- `HomevoltConnectionError`: Connection or network errors
|
|
168
266
|
- `HomevoltAuthenticationError`: Authentication failures
|
|
169
267
|
- `HomevoltDataError`: Data parsing errors
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Homevolt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Python library for Homevolt EMS devices
|
|
5
5
|
Author-email: Your Name <your.email@example.com>
|
|
6
6
|
License: GPL-3.0
|
|
@@ -24,6 +24,12 @@ Get real-time data from your Homevolt Energy Management System, including:
|
|
|
24
24
|
- Grid, solar, and load sensor data
|
|
25
25
|
- Schedule information
|
|
26
26
|
|
|
27
|
+
Control your battery with:
|
|
28
|
+
- Immediate battery control (charge, discharge, idle)
|
|
29
|
+
- Scheduled battery operations
|
|
30
|
+
- Local mode management
|
|
31
|
+
- Parameter configuration
|
|
32
|
+
|
|
27
33
|
## Install
|
|
28
34
|
|
|
29
35
|
```bash
|
|
@@ -46,20 +52,20 @@ async def main():
|
|
|
46
52
|
websession=session,
|
|
47
53
|
)
|
|
48
54
|
await homevolt_connection.update_info()
|
|
49
|
-
|
|
55
|
+
|
|
50
56
|
device = homevolt_connection.get_device()
|
|
51
57
|
print(f"Device ID: {device.device_id}")
|
|
52
58
|
print(f"Current Power: {device.sensors['Power'].value} W")
|
|
53
59
|
print(f"Battery SOC: {device.sensors['Battery State of Charge'].value * 100}%")
|
|
54
|
-
|
|
60
|
+
|
|
55
61
|
# Access all sensors
|
|
56
62
|
for sensor_name, sensor in device.sensors.items():
|
|
57
63
|
print(f"{sensor_name}: {sensor.value} ({sensor.type.value})")
|
|
58
|
-
|
|
64
|
+
|
|
59
65
|
# Access device metadata
|
|
60
66
|
for device_id, metadata in device.device_metadata.items():
|
|
61
67
|
print(f"{device_id}: {metadata.name} ({metadata.model})")
|
|
62
|
-
|
|
68
|
+
|
|
63
69
|
await homevolt_connection.close_connection()
|
|
64
70
|
|
|
65
71
|
|
|
@@ -83,10 +89,10 @@ async def main():
|
|
|
83
89
|
websession=session,
|
|
84
90
|
) as homevolt_connection:
|
|
85
91
|
await homevolt_connection.update_info()
|
|
86
|
-
|
|
92
|
+
|
|
87
93
|
device = homevolt_connection.get_device()
|
|
88
94
|
await device.update_info() # Refresh data
|
|
89
|
-
|
|
95
|
+
|
|
90
96
|
print(f"Device ID: {device.device_id}")
|
|
91
97
|
print(f"Available sensors: {list(device.sensors.keys())}")
|
|
92
98
|
|
|
@@ -95,6 +101,76 @@ if __name__ == "__main__":
|
|
|
95
101
|
asyncio.run(main())
|
|
96
102
|
```
|
|
97
103
|
|
|
104
|
+
## Battery Control Example
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import asyncio
|
|
108
|
+
import aiohttp
|
|
109
|
+
import homevolt
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def main():
|
|
113
|
+
async with aiohttp.ClientSession() as session:
|
|
114
|
+
async with homevolt.Homevolt(
|
|
115
|
+
ip_address="192.168.1.100",
|
|
116
|
+
password="optional_password",
|
|
117
|
+
websession=session,
|
|
118
|
+
) as homevolt_connection:
|
|
119
|
+
await homevolt_connection.update_info()
|
|
120
|
+
device = homevolt_connection.get_device()
|
|
121
|
+
|
|
122
|
+
# Enable local mode to prevent remote schedule overrides
|
|
123
|
+
await device.enable_local_mode()
|
|
124
|
+
|
|
125
|
+
# Charge battery immediately (up to 3000W, stop at 90% SOC)
|
|
126
|
+
await device.charge_battery(max_power=3000, max_soc=90)
|
|
127
|
+
|
|
128
|
+
# Or use the full control method
|
|
129
|
+
await device.set_battery_mode(
|
|
130
|
+
mode=1, # Inverter Charge
|
|
131
|
+
max_charge=3000,
|
|
132
|
+
max_soc=90,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Schedule night charging (11 PM - 7 AM)
|
|
136
|
+
from datetime import datetime, timedelta
|
|
137
|
+
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
138
|
+
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
139
|
+
|
|
140
|
+
await device.add_schedule(
|
|
141
|
+
mode=1, # Inverter Charge
|
|
142
|
+
from_time=tonight.isoformat(),
|
|
143
|
+
to_time=tomorrow.isoformat(),
|
|
144
|
+
max_charge=3000,
|
|
145
|
+
max_soc=80,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Set battery to idle
|
|
149
|
+
await device.set_battery_idle()
|
|
150
|
+
|
|
151
|
+
# Discharge during peak hours
|
|
152
|
+
await device.discharge_battery(max_power=2500, min_soc=30)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
asyncio.run(main())
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Battery Control Modes
|
|
160
|
+
|
|
161
|
+
The following modes are available for battery control:
|
|
162
|
+
|
|
163
|
+
- `0`: Idle - Battery standby (no charge/discharge)
|
|
164
|
+
- `1`: Inverter Charge - Charge battery via inverter from grid/solar
|
|
165
|
+
- `2`: Inverter Discharge - Discharge battery via inverter to home/grid
|
|
166
|
+
- `3`: Grid Charge - Charge from grid with power setpoint
|
|
167
|
+
- `4`: Grid Discharge - Discharge to grid with power setpoint
|
|
168
|
+
- `5`: Grid Charge/Discharge - Bidirectional grid control
|
|
169
|
+
- `6`: Frequency Reserve - Frequency regulation service mode
|
|
170
|
+
- `7`: Solar Charge - Charge from solar production only
|
|
171
|
+
- `8`: Solar Charge/Discharge - Solar-based grid management
|
|
172
|
+
- `9`: Full Solar Export - Export all solar production
|
|
173
|
+
|
|
98
174
|
## API Reference
|
|
99
175
|
|
|
100
176
|
### Homevolt
|
|
@@ -132,6 +208,28 @@ Represents a Homevolt EMS device.
|
|
|
132
208
|
- `async fetch_ems_data()`: Fetch EMS data specifically
|
|
133
209
|
- `async fetch_schedule_data()`: Fetch schedule data specifically
|
|
134
210
|
|
|
211
|
+
#### Battery Control Methods
|
|
212
|
+
|
|
213
|
+
**Immediate Control:**
|
|
214
|
+
- `async set_battery_mode(mode, **kwargs)`: Set immediate battery control mode
|
|
215
|
+
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
216
|
+
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
217
|
+
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
218
|
+
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
219
|
+
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
220
|
+
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
221
|
+
|
|
222
|
+
**Scheduled Control:**
|
|
223
|
+
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
224
|
+
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
225
|
+
- `async clear_all_schedules()`: Clear all schedules
|
|
226
|
+
|
|
227
|
+
**Configuration:**
|
|
228
|
+
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
229
|
+
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
230
|
+
- `async set_parameter(key, value)`: Set a device parameter
|
|
231
|
+
- `async get_parameter(key)`: Get a device parameter value
|
|
232
|
+
|
|
135
233
|
### Data Models
|
|
136
234
|
|
|
137
235
|
#### Sensor
|
|
@@ -163,7 +261,7 @@ Enumeration of sensor types:
|
|
|
163
261
|
|
|
164
262
|
### Exceptions
|
|
165
263
|
|
|
166
|
-
- `
|
|
264
|
+
- `HomevoltError`: Base exception for all Homevolt errors
|
|
167
265
|
- `HomevoltConnectionError`: Connection or network errors
|
|
168
266
|
- `HomevoltAuthenticationError`: Authentication failures
|
|
169
267
|
- `HomevoltDataError`: Data parsing errors
|
|
@@ -8,6 +8,12 @@ Get real-time data from your Homevolt Energy Management System, including:
|
|
|
8
8
|
- Grid, solar, and load sensor data
|
|
9
9
|
- Schedule information
|
|
10
10
|
|
|
11
|
+
Control your battery with:
|
|
12
|
+
- Immediate battery control (charge, discharge, idle)
|
|
13
|
+
- Scheduled battery operations
|
|
14
|
+
- Local mode management
|
|
15
|
+
- Parameter configuration
|
|
16
|
+
|
|
11
17
|
## Install
|
|
12
18
|
|
|
13
19
|
```bash
|
|
@@ -30,20 +36,20 @@ async def main():
|
|
|
30
36
|
websession=session,
|
|
31
37
|
)
|
|
32
38
|
await homevolt_connection.update_info()
|
|
33
|
-
|
|
39
|
+
|
|
34
40
|
device = homevolt_connection.get_device()
|
|
35
41
|
print(f"Device ID: {device.device_id}")
|
|
36
42
|
print(f"Current Power: {device.sensors['Power'].value} W")
|
|
37
43
|
print(f"Battery SOC: {device.sensors['Battery State of Charge'].value * 100}%")
|
|
38
|
-
|
|
44
|
+
|
|
39
45
|
# Access all sensors
|
|
40
46
|
for sensor_name, sensor in device.sensors.items():
|
|
41
47
|
print(f"{sensor_name}: {sensor.value} ({sensor.type.value})")
|
|
42
|
-
|
|
48
|
+
|
|
43
49
|
# Access device metadata
|
|
44
50
|
for device_id, metadata in device.device_metadata.items():
|
|
45
51
|
print(f"{device_id}: {metadata.name} ({metadata.model})")
|
|
46
|
-
|
|
52
|
+
|
|
47
53
|
await homevolt_connection.close_connection()
|
|
48
54
|
|
|
49
55
|
|
|
@@ -67,10 +73,10 @@ async def main():
|
|
|
67
73
|
websession=session,
|
|
68
74
|
) as homevolt_connection:
|
|
69
75
|
await homevolt_connection.update_info()
|
|
70
|
-
|
|
76
|
+
|
|
71
77
|
device = homevolt_connection.get_device()
|
|
72
78
|
await device.update_info() # Refresh data
|
|
73
|
-
|
|
79
|
+
|
|
74
80
|
print(f"Device ID: {device.device_id}")
|
|
75
81
|
print(f"Available sensors: {list(device.sensors.keys())}")
|
|
76
82
|
|
|
@@ -79,6 +85,76 @@ if __name__ == "__main__":
|
|
|
79
85
|
asyncio.run(main())
|
|
80
86
|
```
|
|
81
87
|
|
|
88
|
+
## Battery Control Example
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import asyncio
|
|
92
|
+
import aiohttp
|
|
93
|
+
import homevolt
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
async def main():
|
|
97
|
+
async with aiohttp.ClientSession() as session:
|
|
98
|
+
async with homevolt.Homevolt(
|
|
99
|
+
ip_address="192.168.1.100",
|
|
100
|
+
password="optional_password",
|
|
101
|
+
websession=session,
|
|
102
|
+
) as homevolt_connection:
|
|
103
|
+
await homevolt_connection.update_info()
|
|
104
|
+
device = homevolt_connection.get_device()
|
|
105
|
+
|
|
106
|
+
# Enable local mode to prevent remote schedule overrides
|
|
107
|
+
await device.enable_local_mode()
|
|
108
|
+
|
|
109
|
+
# Charge battery immediately (up to 3000W, stop at 90% SOC)
|
|
110
|
+
await device.charge_battery(max_power=3000, max_soc=90)
|
|
111
|
+
|
|
112
|
+
# Or use the full control method
|
|
113
|
+
await device.set_battery_mode(
|
|
114
|
+
mode=1, # Inverter Charge
|
|
115
|
+
max_charge=3000,
|
|
116
|
+
max_soc=90,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Schedule night charging (11 PM - 7 AM)
|
|
120
|
+
from datetime import datetime, timedelta
|
|
121
|
+
tonight = datetime.now().replace(hour=23, minute=0, second=0)
|
|
122
|
+
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
|
|
123
|
+
|
|
124
|
+
await device.add_schedule(
|
|
125
|
+
mode=1, # Inverter Charge
|
|
126
|
+
from_time=tonight.isoformat(),
|
|
127
|
+
to_time=tomorrow.isoformat(),
|
|
128
|
+
max_charge=3000,
|
|
129
|
+
max_soc=80,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Set battery to idle
|
|
133
|
+
await device.set_battery_idle()
|
|
134
|
+
|
|
135
|
+
# Discharge during peak hours
|
|
136
|
+
await device.discharge_battery(max_power=2500, min_soc=30)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if __name__ == "__main__":
|
|
140
|
+
asyncio.run(main())
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Battery Control Modes
|
|
144
|
+
|
|
145
|
+
The following modes are available for battery control:
|
|
146
|
+
|
|
147
|
+
- `0`: Idle - Battery standby (no charge/discharge)
|
|
148
|
+
- `1`: Inverter Charge - Charge battery via inverter from grid/solar
|
|
149
|
+
- `2`: Inverter Discharge - Discharge battery via inverter to home/grid
|
|
150
|
+
- `3`: Grid Charge - Charge from grid with power setpoint
|
|
151
|
+
- `4`: Grid Discharge - Discharge to grid with power setpoint
|
|
152
|
+
- `5`: Grid Charge/Discharge - Bidirectional grid control
|
|
153
|
+
- `6`: Frequency Reserve - Frequency regulation service mode
|
|
154
|
+
- `7`: Solar Charge - Charge from solar production only
|
|
155
|
+
- `8`: Solar Charge/Discharge - Solar-based grid management
|
|
156
|
+
- `9`: Full Solar Export - Export all solar production
|
|
157
|
+
|
|
82
158
|
## API Reference
|
|
83
159
|
|
|
84
160
|
### Homevolt
|
|
@@ -116,6 +192,28 @@ Represents a Homevolt EMS device.
|
|
|
116
192
|
- `async fetch_ems_data()`: Fetch EMS data specifically
|
|
117
193
|
- `async fetch_schedule_data()`: Fetch schedule data specifically
|
|
118
194
|
|
|
195
|
+
#### Battery Control Methods
|
|
196
|
+
|
|
197
|
+
**Immediate Control:**
|
|
198
|
+
- `async set_battery_mode(mode, **kwargs)`: Set immediate battery control mode
|
|
199
|
+
- `async charge_battery(**kwargs)`: Charge battery using inverter
|
|
200
|
+
- `async discharge_battery(**kwargs)`: Discharge battery using inverter
|
|
201
|
+
- `async set_battery_idle(**kwargs)`: Set battery to idle mode
|
|
202
|
+
- `async charge_from_grid(**kwargs)`: Charge from grid with power setpoint
|
|
203
|
+
- `async discharge_to_grid(**kwargs)`: Discharge to grid with power setpoint
|
|
204
|
+
- `async charge_from_solar(**kwargs)`: Charge from solar only
|
|
205
|
+
|
|
206
|
+
**Scheduled Control:**
|
|
207
|
+
- `async add_schedule(mode, **kwargs)`: Add a scheduled battery control entry
|
|
208
|
+
- `async delete_schedule(schedule_id)`: Delete a schedule by ID
|
|
209
|
+
- `async clear_all_schedules()`: Clear all schedules
|
|
210
|
+
|
|
211
|
+
**Configuration:**
|
|
212
|
+
- `async enable_local_mode()`: Enable local mode (prevents remote overrides)
|
|
213
|
+
- `async disable_local_mode()`: Disable local mode (allows remote overrides)
|
|
214
|
+
- `async set_parameter(key, value)`: Set a device parameter
|
|
215
|
+
- `async get_parameter(key)`: Get a device parameter value
|
|
216
|
+
|
|
119
217
|
### Data Models
|
|
120
218
|
|
|
121
219
|
#### Sensor
|
|
@@ -147,7 +245,7 @@ Enumeration of sensor types:
|
|
|
147
245
|
|
|
148
246
|
### Exceptions
|
|
149
247
|
|
|
150
|
-
- `
|
|
248
|
+
- `HomevoltError`: Base exception for all Homevolt errors
|
|
151
249
|
- `HomevoltConnectionError`: Connection or network errors
|
|
152
250
|
- `HomevoltAuthenticationError`: Authentication failures
|
|
153
251
|
- `HomevoltDataError`: Data parsing errors
|
|
@@ -5,7 +5,7 @@ from .exceptions import (
|
|
|
5
5
|
HomevoltAuthenticationError,
|
|
6
6
|
HomevoltConnectionError,
|
|
7
7
|
HomevoltDataError,
|
|
8
|
-
|
|
8
|
+
HomevoltError,
|
|
9
9
|
)
|
|
10
10
|
from .homevolt import Homevolt
|
|
11
11
|
from .models import DeviceMetadata, Sensor, SensorType
|
|
@@ -17,8 +17,7 @@ __all__ = [
|
|
|
17
17
|
"HomevoltAuthenticationError",
|
|
18
18
|
"HomevoltConnectionError",
|
|
19
19
|
"HomevoltDataError",
|
|
20
|
-
"
|
|
20
|
+
"HomevoltError",
|
|
21
21
|
"Sensor",
|
|
22
22
|
"SensorType",
|
|
23
23
|
]
|
|
24
|
-
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Constants for the Homevolt library."""
|
|
2
|
+
|
|
3
|
+
# API endpoints
|
|
4
|
+
ENDPOINT_EMS = "/ems.json"
|
|
5
|
+
ENDPOINT_SCHEDULE = "/schedule.json"
|
|
6
|
+
ENDPOINT_CONSOLE = "/console.json"
|
|
7
|
+
ENDPOINT_PARAMS = "/params.json"
|
|
8
|
+
|
|
9
|
+
SCHEDULE_TYPE = {
|
|
10
|
+
0: "Idle",
|
|
11
|
+
1: "Inverter Charge",
|
|
12
|
+
2: "Inverter Discharge",
|
|
13
|
+
3: "Grid Charge",
|
|
14
|
+
4: "Grid Discharge",
|
|
15
|
+
5: "Grid Charge/Discharge",
|
|
16
|
+
6: "Frequency Reserve",
|
|
17
|
+
7: "Solar Charge",
|
|
18
|
+
8: "Solar Charge/Discharge",
|
|
19
|
+
9: "Full Solar Export",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Device type mappings for sensors
|
|
23
|
+
DEVICE_MAP = {
|
|
24
|
+
"grid": "grid",
|
|
25
|
+
"solar": "solar",
|
|
26
|
+
"load": "load",
|
|
27
|
+
"house": "load",
|
|
28
|
+
}
|