API Reference¶
This section provides auto-generated API documentation for flowerpower-mqtt.
The documentation is generated from the source code docstrings using mkdocstrings.
flowerpower_mqtt ¶
FlowerPower MQTT Plugin
A simple MQTT plugin for FlowerPower that triggers pipeline execution when messages arrive on subscribed topics, with configurable QoS levels and optional RQ job queue integration for asynchronous processing.
Classes¶
FlowerPowerMQTTConfig ¶
Bases: Struct
Main configuration for FlowerPower MQTT plugin.
Source code in src/flowerpower_mqtt/config.py
MQTTConfig ¶
Bases: Struct
MQTT broker configuration.
Source code in src/flowerpower_mqtt/config.py
JobQueueConfig ¶
Bases: Struct
Job queue configuration.
Source code in src/flowerpower_mqtt/config.py
SubscriptionConfig ¶
Bases: Struct
Individual subscription configuration.
Source code in src/flowerpower_mqtt/config.py
FlowerPowerMQTTError ¶
ConnectionError ¶
Bases: FlowerPowerMQTTError
Raised when MQTT connection fails.
SubscriptionError ¶
Bases: FlowerPowerMQTTError
Raised when MQTT subscription fails.
ConfigurationError ¶
Bases: FlowerPowerMQTTError
Raised when configuration is invalid.
MQTTPlugin ¶
Main interface for FlowerPower MQTT plugin.
Provides simple API for connecting to MQTT brokers, subscribing to topics, and triggering FlowerPower pipeline execution with support for different QoS levels and execution modes.
Source code in src/flowerpower_mqtt/__init__.py
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 178 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 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
Attributes¶
Functions¶
__init__ ¶
__init__(
broker: str = "localhost",
port: int = 1883,
base_dir: str = ".",
use_job_queue: bool = False,
redis_url: str = "redis://localhost:6379",
config: Optional[FlowerPowerMQTTConfig] = None,
**mqtt_kwargs
)
Initialize MQTT plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
broker
|
str
|
MQTT broker hostname |
'localhost'
|
port
|
int
|
MQTT broker port |
1883
|
base_dir
|
str
|
FlowerPower project base directory |
'.'
|
use_job_queue
|
bool
|
Enable RQ job queue for async execution |
False
|
redis_url
|
str
|
Redis connection URL for job queue |
'redis://localhost:6379'
|
config
|
Optional[FlowerPowerMQTTConfig]
|
Complete configuration object (overrides other params) |
None
|
**mqtt_kwargs
|
Additional MQTT client configuration |
{}
|
Source code in src/flowerpower_mqtt/__init__.py
from_config
classmethod
¶
Create plugin instance from configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Union[str, Path]
|
Path to YAML configuration file |
required |
Returns:
| Type | Description |
|---|---|
MQTTPlugin
|
Configured MQTTPlugin instance |
Source code in src/flowerpower_mqtt/__init__.py
connect
async
¶
Connect to MQTT broker.
Source code in src/flowerpower_mqtt/__init__.py
disconnect
async
¶
Disconnect from MQTT broker.
Source code in src/flowerpower_mqtt/__init__.py
__aenter__
async
¶
__aexit__
async
¶
subscribe
async
¶
Subscribe to MQTT topic and link to FlowerPower pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
MQTT topic pattern to subscribe to |
required |
pipeline_name
|
str
|
Name of FlowerPower pipeline to execute |
required |
qos
|
int
|
QoS level (0=at most once, 1=at least once, 2=exactly once) |
0
|
execution_mode
|
str
|
Execution mode (sync, async, mixed) |
'sync'
|
Source code in src/flowerpower_mqtt/__init__.py
subscribe_bulk
async
¶
Subscribe to multiple topics at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriptions
|
List[Dict[str, Any]]
|
List of subscription dictionaries |
required |
Source code in src/flowerpower_mqtt/__init__.py
unsubscribe
async
¶
Unsubscribe from MQTT topic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
MQTT topic pattern to unsubscribe from |
required |
Source code in src/flowerpower_mqtt/__init__.py
start_listener
async
¶
Start listening for MQTT messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
background
|
bool
|
If True, run listener in background task |
False
|
execution_mode
|
Optional[str]
|
Override execution mode for all pipelines |
None
|
Source code in src/flowerpower_mqtt/__init__.py
stop_listener
async
¶
Stop MQTT message listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait for graceful shutdown |
10.0
|
Source code in src/flowerpower_mqtt/__init__.py
get_subscriptions ¶
Get current subscriptions.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of subscription information dictionaries |
Source code in src/flowerpower_mqtt/__init__.py
get_statistics ¶
Get plugin statistics.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with current statistics |
Source code in src/flowerpower_mqtt/__init__.py
save_config ¶
Save current configuration to YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Union[str, Path]
|
Path where to save configuration |
required |
Source code in src/flowerpower_mqtt/__init__.py
Functions¶
create_simple_mqtt_plugin
async
¶
create_simple_mqtt_plugin(
broker: str = "localhost",
topic: str = "test/topic",
pipeline: str = "test_pipeline",
qos: int = 0,
base_dir: str = ".",
) -> MQTTPlugin
Create and configure a simple MQTT plugin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
broker
|
str
|
MQTT broker hostname |
'localhost'
|
topic
|
str
|
MQTT topic to subscribe to |
'test/topic'
|
pipeline
|
str
|
FlowerPower pipeline name |
'test_pipeline'
|
qos
|
int
|
QoS level |
0
|
base_dir
|
str
|
FlowerPower project directory |
'.'
|
Returns:
| Type | Description |
|---|---|
MQTTPlugin
|
Configured and connected MQTTPlugin instance |
Source code in src/flowerpower_mqtt/__init__.py
Modules¶
cli ¶
Command Line Interface for FlowerPower MQTT Plugin.
Provides a comprehensive CLI for managing MQTT connections, subscriptions, and pipeline execution with beautiful rich output.
Classes¶
Functions¶
get_config_path ¶
Get configuration file path.
Source code in src/flowerpower_mqtt/cli.py
load_plugin ¶
load_plugin(
config: Optional[Path] = None,
broker: Optional[str] = None,
port: Optional[int] = None,
base_dir: Optional[str] = None,
use_job_queue: bool = False,
redis_url: Optional[str] = None,
) -> MQTTPlugin
Load MQTTPlugin from config or parameters.
Source code in src/flowerpower_mqtt/cli.py
handle_async ¶
Handle async functions in CLI commands.
Source code in src/flowerpower_mqtt/cli.py
connect ¶
connect(
broker: str = typer.Option(
"localhost", "--broker", "-b", help="MQTT broker hostname"
),
port: int = typer.Option(1883, "--port", "-p", help="MQTT broker port"),
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
base_dir: str = typer.Option(
".", "--base-dir", help="FlowerPower project directory"
),
use_job_queue: bool = typer.Option(
False, "--job-queue", help="Enable RQ job queue"
),
redis_url: str = typer.Option(
"redis://localhost:6379", "--redis-url", help="Redis URL for job queue"
),
save_config: bool = typer.Option(
False, "--save-config", help="Save configuration to file"
),
)
Connect to MQTT broker.
Source code in src/flowerpower_mqtt/cli.py
subscribe ¶
subscribe(
topic: str = typer.Argument(..., help="MQTT topic to subscribe to"),
pipeline: str = typer.Argument(..., help="FlowerPower pipeline name"),
qos: int = typer.Option(0, "--qos", "-q", help="QoS level (0, 1, or 2)"),
execution_mode: str = typer.Option(
"sync", "--mode", "-m", help="Execution mode (sync, async, mixed)"
),
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
save_config: bool = typer.Option(
False, "--save-config", help="Save subscription to config file"
),
)
Subscribe to MQTT topic.
Source code in src/flowerpower_mqtt/cli.py
listen ¶
listen(
background: bool = typer.Option(
False, "--background", "-bg", help="Run listener in background"
),
execution_mode: Optional[str] = typer.Option(
None,
"--override-mode",
help="Override execution mode for all pipelines",
),
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
timeout: Optional[int] = typer.Option(
None, "--timeout", help="Stop after specified seconds"
),
)
Start listening for MQTT messages.
Source code in src/flowerpower_mqtt/cli.py
status ¶
status(
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
json_output: bool = typer.Option(False, "--json", help="Output as JSON"),
)
Show current plugin status and statistics.
Source code in src/flowerpower_mqtt/cli.py
disconnect ¶
disconnect(
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
)
)
Disconnect from MQTT broker.
Source code in src/flowerpower_mqtt/cli.py
config_create ¶
config_create(
output: Path = typer.Option(
"mqtt_config.yml", "--output", "-o", help="Output configuration file"
),
interactive: bool = typer.Option(
False, "--interactive", "-i", help="Interactive configuration"
),
with_job_queue: bool = typer.Option(
False, "--job-queue", help="Enable job queue configuration"
),
)
Create a new configuration file.
Source code in src/flowerpower_mqtt/cli.py
config_validate ¶
Validate configuration file.
Source code in src/flowerpower_mqtt/cli.py
config_show ¶
config_show(
config_file: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
format_output: str = typer.Option(
"yaml", "--format", help="Output format (yaml, json)"
),
)
Show current configuration.
Source code in src/flowerpower_mqtt/cli.py
config_edit ¶
config_edit(
config_file: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
editor: Optional[str] = typer.Option(
None, "--editor", help="Editor to use (default: $EDITOR)"
),
)
Edit configuration file.
Source code in src/flowerpower_mqtt/cli.py
monitor ¶
monitor(
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
interval: int = typer.Option(
5, "--interval", "-i", help="Update interval in seconds"
),
duration: Optional[int] = typer.Option(
None, "--duration", "-d", help="Monitor duration in seconds"
),
json_output: bool = typer.Option(False, "--json", help="Output as JSON"),
)
Monitor MQTT plugin in real-time.
Source code in src/flowerpower_mqtt/cli.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
list_subscriptions ¶
list_subscriptions(
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
active_only: bool = typer.Option(
False, "--active", help="Show only subscriptions with messages"
),
json_output: bool = typer.Option(False, "--json", help="Output as JSON"),
)
List all MQTT subscriptions.
Source code in src/flowerpower_mqtt/cli.py
unsubscribe ¶
unsubscribe(
topic: str = typer.Argument(..., help="Topic to unsubscribe from"),
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
save_config: bool = typer.Option(
False, "--save-config", help="Save changes to config file"
),
)
Unsubscribe from MQTT topic.
Source code in src/flowerpower_mqtt/cli.py
jobs_status ¶
jobs_status(
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
json_output: bool = typer.Option(False, "--json", help="Output as JSON"),
)
Show job queue status.
Source code in src/flowerpower_mqtt/cli.py
jobs_worker ¶
jobs_worker(
action: str = typer.Argument(
..., help="Worker action (start, stop, status)"
),
count: int = typer.Option(1, "--count", "-c", help="Number of workers"),
config: Optional[Path] = typer.Option(
None, "--config", "-c", help="Configuration file"
),
)
Manage RQ workers.
Source code in src/flowerpower_mqtt/cli.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | |
client ¶
MQTT client wrapper with QoS support for FlowerPower integration.
Classes¶
MQTTMessage ¶
Bases: Struct
Immutable wrapper for MQTT messages with additional metadata and deserialization support.
Source code in src/flowerpower_mqtt/client.py
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 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 178 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 325 | |
Validate fields after initialization.
Source code in src/flowerpower_mqtt/client.py
Deserialize payload as JSON using msgspec.
Source code in src/flowerpower_mqtt/client.py
Deserialize payload as YAML.
Source code in src/flowerpower_mqtt/client.py
Deserialize payload as MessagePack using msgspec.
Source code in src/flowerpower_mqtt/client.py
Deserialize payload as Python pickle.
Deserialize payload as Protocol Buffers.
Source code in src/flowerpower_mqtt/client.py
Deserialize payload as PyArrow IPC format.
Source code in src/flowerpower_mqtt/client.py
Serialize data to JSON format.
Serialize data to YAML format.
Serialize data to MessagePack format.
Serialize data to Python pickle format.
Serialize Protocol Buffers message.
Source code in src/flowerpower_mqtt/client.py
Serialize data to PyArrow IPC format.
Source code in src/flowerpower_mqtt/client.py
Serialize data using the specified format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_name
|
str
|
Format name ('json', 'yaml', 'msgpack', 'pickle', 'protobuf', 'pyarrow') |
required |
data
|
Any
|
Data to serialize |
required |
**kwargs
|
Additional arguments for specific formats |
{}
|
Returns:
| Type | Description |
|---|---|
bytes
|
Serialized data as bytes |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported |
Source code in src/flowerpower_mqtt/client.py
Automatically detect and deserialize payload format.
Detection order (most common to least common): 1. JSON - Most common for MQTT payloads 2. MessagePack - Efficient binary format 3. YAML - Human-readable structured data 4. PyArrow IPC - Columnar data format 5. Pickle - Python-specific binary format
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
Deserialized data or None if no format matches |
Source code in src/flowerpower_mqtt/client.py
Deserialize payload using the specified format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_name
|
str
|
Format name ('json', 'yaml', 'msgpack', 'pickle', 'protobuf', 'pyarrow') |
required |
**kwargs
|
Additional arguments for specific formats |
{}
|
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
Deserialized data or None if deserialization fails |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported |
Source code in src/flowerpower_mqtt/client.py
MQTTClient ¶
MQTT client wrapper with QoS support and subscription management.
Source code in src/flowerpower_mqtt/client.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | |
Initialize MQTT client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MQTTConfig
|
MQTT configuration |
required |
Source code in src/flowerpower_mqtt/client.py
async
¶async
¶async
¶Establish connection to MQTT broker with automatic reconnection.
Source code in src/flowerpower_mqtt/client.py
async
¶Disconnect from MQTT broker.
Source code in src/flowerpower_mqtt/client.py
async
¶subscribe(
topic: str,
pipeline: str,
qos: int = 0,
execution_mode: str = "sync",
deserialization_format: str = "auto",
) -> None
Subscribe to MQTT topic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
MQTT topic pattern to subscribe to |
required |
pipeline
|
str
|
FlowerPower pipeline name to execute |
required |
qos
|
int
|
QoS level (0, 1, or 2) |
0
|
execution_mode
|
str
|
Pipeline execution mode (sync, async, mixed) |
'sync'
|
deserialization_format
|
str
|
Format to use for deserializing message payloads (json, yaml, msgpack, pickle, protobuf, pyarrow, auto) |
'auto'
|
Source code in src/flowerpower_mqtt/client.py
async
¶Unsubscribe from MQTT topic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
MQTT topic pattern to unsubscribe from |
required |
Source code in src/flowerpower_mqtt/client.py
Add message handler function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Callable[[MQTTMessage], None]
|
Function to call when messages arrive |
required |
Remove message handler function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Callable[[MQTTMessage], None]
|
Handler function to remove |
required |
Source code in src/flowerpower_mqtt/client.py
async
¶Listen for incoming MQTT messages and dispatch to handlers.
Source code in src/flowerpower_mqtt/client.py
Get subscription info for a topic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
Topic pattern |
required |
Returns:
| Type | Description |
|---|---|
Optional[RuntimeSubscription]
|
RuntimeSubscription or None if not found |
Source code in src/flowerpower_mqtt/client.py
Find subscription that matches a specific topic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
Specific topic to match against patterns |
required |
Returns:
| Type | Description |
|---|---|
Optional[RuntimeSubscription]
|
First matching RuntimeSubscription or None |
Source code in src/flowerpower_mqtt/client.py
config ¶
Configuration management for FlowerPower MQTT plugin.
Classes¶
MQTTConfig ¶
Bases: Struct
MQTT broker configuration.
Source code in src/flowerpower_mqtt/config.py
JobQueueConfig ¶
Bases: Struct
Job queue configuration.
Source code in src/flowerpower_mqtt/config.py
SubscriptionConfig ¶
Bases: Struct
Individual subscription configuration.
Source code in src/flowerpower_mqtt/config.py
FlowerPowerMQTTConfig ¶
Bases: Struct
Main configuration for FlowerPower MQTT plugin.
Source code in src/flowerpower_mqtt/config.py
RuntimeSubscription
dataclass
¶
Runtime subscription data with additional metadata.
Source code in src/flowerpower_mqtt/config.py
exceptions ¶
Custom exceptions for FlowerPower MQTT plugin.
Classes¶
FlowerPowerMQTTError ¶
ConnectionError ¶
Bases: FlowerPowerMQTTError
Raised when MQTT connection fails.
SubscriptionError ¶
Bases: FlowerPowerMQTTError
Raised when MQTT subscription fails.
PipelineExecutionError ¶
Bases: FlowerPowerMQTTError
Raised when pipeline execution fails.
JobQueueError ¶
Bases: FlowerPowerMQTTError
Raised when job queue operations fail.
ConfigurationError ¶
Bases: FlowerPowerMQTTError
Raised when configuration is invalid.
job_handler ¶
RQ job handler functions for pipeline execution.
Classes¶
Functions¶
execute_pipeline_job ¶
execute_pipeline_job(
pipeline_name: str,
message_data: Dict[str, Any],
base_dir: str,
topic: str,
qos: int,
execution_metadata: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]
RQ job function for executing FlowerPower pipelines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_name
|
str
|
Name of the pipeline to execute |
required |
message_data
|
Dict[str, Any]
|
MQTT message data to pass as pipeline input |
required |
base_dir
|
str
|
FlowerPower project base directory |
required |
topic
|
str
|
MQTT topic the message came from |
required |
qos
|
int
|
QoS level of the message |
required |
execution_metadata
|
Optional[Dict[str, Any]]
|
Additional metadata for execution |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict containing execution status and results |
Source code in src/flowerpower_mqtt/job_handler.py
get_job_status ¶
Get the status of a job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
RQ job ID |
required |
job_queue_manager
|
JobQueueManager
|
JobQueueManager instance |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict containing job status information |
Source code in src/flowerpower_mqtt/job_handler.py
cleanup_completed_jobs ¶
cleanup_completed_jobs(
job_queue_manager: JobQueueManager, max_age_hours: int = 24
) -> Dict[str, int]
Clean up completed jobs older than specified age.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_queue_manager
|
JobQueueManager
|
JobQueueManager instance |
required |
max_age_hours
|
int
|
Maximum age of jobs to keep |
24
|
Returns:
| Type | Description |
|---|---|
Dict[str, int]
|
Dict with cleanup statistics |
Source code in src/flowerpower_mqtt/job_handler.py
listener ¶
MQTT listener with FlowerPower pipeline execution and job queue integration.
Classes¶
MQTTListener ¶
MQTT listener that processes messages and executes FlowerPower pipelines. Supports both synchronous and asynchronous execution via RQ job queue.
Source code in src/flowerpower_mqtt/listener.py
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 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 178 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 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
Initialize MQTT listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mqtt_client
|
MQTTClient
|
Connected MQTT client instance |
required |
config
|
FlowerPowerMQTTConfig
|
FlowerPower MQTT configuration |
required |
Source code in src/flowerpower_mqtt/listener.py
async
¶Start MQTT message listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
background
|
bool
|
If True, run listener in background task |
False
|
Source code in src/flowerpower_mqtt/listener.py
async
¶Stop MQTT message listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait for graceful shutdown |
10.0
|
Source code in src/flowerpower_mqtt/listener.py
Get listener statistics.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with current statistics |