WarpMQTT2Api API Documentation
mqtt_client
Created on 2025-05-09
@author: wf
MqttClient
MQTT client
Source code in warp/mqtt_client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
__init__(mqtt_config, callback)
Initialize with configurations
Source code in warp/mqtt_client.py
18 19 20 21 22 23 24 |
|
on_connect(client, userdata, flags, rc, properties=None)
Connection callback
Source code in warp/mqtt_client.py
26 27 28 29 30 31 32 33 34 35 36 |
|
on_message(client, userdata, msg)
Message callback
Source code in warp/mqtt_client.py
38 39 40 41 42 43 44 |
|
run()
Run the client loop
Source code in warp/mqtt_client.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
mqtt_config
Created on 09.05.2025
@author: wf
MqttConfig
Configuration for the MQTT to Warp3 middleware
Source code in warp/mqtt_config.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
addArgs(parser)
classmethod
Add command line arguments for MqttConfig to the given parser.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
The argument parser to add arguments to |
required |
Source code in warp/mqtt_config.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
ofArgs(args=None)
classmethod
Create a configuration from command line arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
Optional list of command line arguments. If None, sys.argv is used. |
None
|
Returns:
Name | Type | Description |
---|---|---|
MqttConfig |
Configuration object |
Source code in warp/mqtt_config.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
warp3
Created on 2025-05-09
@author: wf
MeterReading
dataclass
Source code in warp/warp3.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
time: datetime
property
Convert timestamp string to datetime object
active_power(prev)
calculate the active power
Source code in warp/warp3.py
33 34 35 36 37 38 39 40 41 42 43 44 |
|
PowerMeter
Active power meter for Warp3 Wallbox
Source code in warp/warp3.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
__init__()
constructor
Source code in warp/warp3.py
182 183 184 185 186 187 188 189 190 |
|
check_warp3_availability()
Check availability of Warp3 API by verifying firmware version and meter configuration.
Returns:
Type | Description |
---|---|
bool
|
True if both firmware info and meter config are available, else False. |
Source code in warp/warp3.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
handle_message(msg)
Handle incoming MQTT message
Source code in warp/warp3.py
236 237 238 239 240 241 242 243 244 245 246 |
|
maininstance()
Main instance setup and execution
Source code in warp/warp3.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
schedule_update()
Schedule next update using a timer
Source code in warp/warp3.py
201 202 203 204 205 |
|
send_update()
Send latest stored power value to wallbox this is called regularly as per the scheduled interval
Source code in warp/warp3.py
254 255 256 257 258 259 260 261 262 263 264 |
|
start()
Start the power meter
Source code in warp/warp3.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
update_wallbox(power_value)
Send power value to wallbox
Source code in warp/warp3.py
248 249 250 251 252 |
|
WallboxConfig
Configuration for the Warp3 wallbox
Source code in warp/warp3.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
addArgs(parser)
classmethod
Add command line arguments for WallboxConfig to the given parser.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
The argument parser to add arguments to |
required |
Source code in warp/warp3.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
calcPower(payload)
Calculate power from payload using MeterReading class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload |
The decoded JSON payload from MQTT message |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Calculated power in watts |
Source code in warp/warp3.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
ofArgs(args=None)
classmethod
Create a configuration from command line arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
Optional list of command line arguments. If None, sys.argv is used. |
None
|
Returns:
Name | Type | Description |
---|---|---|
WallboxConfig |
Configuration object |
Source code in warp/warp3.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
main()
Main entry point
Source code in warp/warp3.py
327 328 329 330 |
|
warp3_api
Created on 2025-05-09
@author: wf
Warp3Api
API client for TinkerForge/Warp3 Wallbox
Source code in warp/warp3_api.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
__init__(host)
Initialize with wallbox host
Source code in warp/warp3_api.py
15 16 17 18 19 |
|
api_get(cmd)
Call the wallbox API with the given command and filter the JSON result
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd |
API command |
required |
Returns:
Type | Description |
---|---|
API response |
Source code in warp/warp3_api.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
describe_meter(meter)
Describe the meter configuration using value_id explanations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meter |
dict
|
The meter configuration dictionary. |
required |
Returns:
Type | Description |
---|---|
str
|
A human-readable description string. |
Source code in warp/warp3_api.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
get_meter_config(meter_id=1)
Get meter configuration
Source code in warp/warp3_api.py
46 47 48 49 |
|
get_version()
Get wallbox firmware version
Source code in warp/warp3_api.py
41 42 43 44 |
|
update_meter(value, meter_id=1)
Update meter value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
Power value in Watts |
required | |
meter_id |
Meter ID (default 1) |
1
|
Returns:
Type | Description |
---|---|
True if successful, False otherwise |
Source code in warp/warp3_api.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|