types
frequenz.client.dispatch.types ¤
Type wrappers for the generated protobuf messages.
Attributes¤
frequenz.client.dispatch.types.TargetCategoryInputType
module-attribute
¤
TargetCategoryInputType = (
TargetCategory
| ComponentCategory
| BatteryType
| InverterType
| EvChargerType
)
Type for the input to TargetCategories constructor.
frequenz.client.dispatch.types.TargetComponents
module-attribute
¤
TargetComponents: TypeAlias = TargetIds | TargetCategories
Target components.
Can be one of the following:
- A set of target component IDs (TargetIds)
- A set of target component categories with opt. types (TargetCategories)
This is a frozen set, so it is immutable. The target components are used to specify the components that a dispatch should target.
Classes¤
frequenz.client.dispatch.types.BatteryType ¤
frequenz.client.dispatch.types.Dispatch
dataclass
¤
Represents a dispatch operation within a microgrid system.
Source code in frequenz/client/dispatch/types.py
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 |
|
Attributes¤
active
instance-attribute
¤
active: bool
Indicates whether the dispatch is active and eligible for processing.
create_time
instance-attribute
¤
create_time: datetime
The creation time of the dispatch in UTC. Set when a dispatch is created.
dry_run
instance-attribute
¤
dry_run: bool
Indicates if the dispatch is a dry run.
Executed for logging and monitoring without affecting actual component states.
duration
instance-attribute
¤
duration: timedelta | None
The duration of the dispatch, represented as a timedelta.
end_time
class-attribute
instance-attribute
¤
end_time: datetime | None = None
The end time of the dispatch in UTC.
Calculated and sent by the backend service.
next_run
property
¤
next_run: datetime | None
Calculate the next run of a dispatch.
RETURNS | DESCRIPTION |
---|---|
datetime | None
|
The next run of the dispatch or None if the dispatch is finished. |
payload
instance-attribute
¤
The dispatch payload containing arbitrary data.
It is structured as needed for the dispatch operation.
recurrence
instance-attribute
¤
recurrence: RecurrenceRule
The recurrence rule for the dispatch.
Defining any repeating patterns or schedules.
started
property
¤
started: bool
Check if the dispatch has started.
A dispatch is considered started if the current time is after the start time but before the end time.
Recurring dispatches are considered started if the current time is after the start time of the last occurrence but before the end time of the last occurrence.
type
instance-attribute
¤
type: str
User-defined information about the type of dispatch.
This is understood and processed by downstream applications.
until
property
¤
until: datetime | None
Time when the dispatch should end.
Returns the time that a running dispatch should end. If the dispatch is not running, None is returned.
RETURNS | DESCRIPTION |
---|---|
datetime | None
|
The time when the dispatch should end or None if the dispatch is not running. |
update_time
instance-attribute
¤
update_time: datetime
The last update time of the dispatch in UTC. Set when a dispatch is modified.
Functions¤
from_protobuf
classmethod
¤
Convert a protobuf dispatch to a dispatch.
PARAMETER | DESCRIPTION |
---|---|
pb_object
|
The protobuf dispatch to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dispatch
|
The converted dispatch. |
Source code in frequenz/client/dispatch/types.py
next_run_after ¤
Calculate the next run of a dispatch.
PARAMETER | DESCRIPTION |
---|---|
after
|
The time to calculate the next run from.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
datetime | None
|
The next run of the dispatch or None if the dispatch is finished. |
Source code in frequenz/client/dispatch/types.py
to_protobuf ¤
to_protobuf() -> Dispatch
Convert a dispatch to a protobuf dispatch.
RETURNS | DESCRIPTION |
---|---|
Dispatch
|
The converted protobuf dispatch. |
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.DispatchEvent
dataclass
¤
Represents an event that occurred during a dispatch operation.
Source code in frequenz/client/dispatch/types.py
Attributes¤
Functions¤
from_protobuf
classmethod
¤
from_protobuf(
pb_object: StreamMicrogridDispatchesResponse,
) -> DispatchEvent
Convert a protobuf dispatch event to a dispatch event.
PARAMETER | DESCRIPTION |
---|---|
pb_object
|
The protobuf dispatch event to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DispatchEvent
|
The converted dispatch event. |
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.DispatchId ¤
Bases: BaseId
A unique identifier for a dispatch.
Source code in frequenz/client/dispatch/types.py
Attributes¤
Functions¤
__eq__ ¤
Check if this instance is equal to another object.
Equality is defined as being of the exact same type and having the same underlying ID.
Source code in frequenz/core/id.py
__hash__ ¤
__hash__() -> int
Return the hash of this instance.
The hash is based on the exact type and the underlying ID to ensure that IDs of different types but with the same numeric value have different hashes.
Source code in frequenz/core/id.py
__init__ ¤
__init__(id_: int) -> None
Initialize this instance.
PARAMETER | DESCRIPTION |
---|---|
id_
|
The numeric unique identifier.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the ID is negative. |
Source code in frequenz/core/id.py
__init_subclass__ ¤
Initialize a subclass, set its string prefix, and perform checks.
PARAMETER | DESCRIPTION |
---|---|
str_prefix
|
The string prefix for the ID type (e.g., "MID"). Must be unique across all ID types.
TYPE:
|
allow_custom_name
|
If True, bypasses the check that the class name must end with "Id". Defaults to False.
TYPE:
|
**kwargs
|
Forwarded to the parent's init_subclass.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If |
Source code in frequenz/core/id.py
__lt__ ¤
Check if this instance is less than another object.
Comparison is only defined between instances of the exact same type.
Source code in frequenz/core/id.py
__new__ ¤
Create a new instance of the ID class, only if it is a subclass of BaseId.
frequenz.client.dispatch.types.EvChargerType ¤
Bases: Enum
Enum representing the type of EV charger.
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.Event ¤
Bases: Enum
Enum representing the type of event that occurred during a dispatch operation.
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.InverterType ¤
Bases: Enum
Enum representing the type of inverter.
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.TargetCategories ¤
Bases: frozenset[TargetCategory]
A set of target component categories and types.
This is a frozen set, so it is immutable.
Source code in frequenz/client/dispatch/types.py
Functions¤
__new__ ¤
__new__(*categories_input: TargetCategoryInputType) -> Self
Create a new TargetCategories instance.
PARAMETER | DESCRIPTION |
---|---|
*categories_input
|
TargetCategory instances or raw ComponentCategory/specific types (BatteryType, InverterType, EvChargerType) to be wrapped.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
A new TargetCategories instance. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If an item in categories_input is not a TargetCategory nor one of the wrappable types. |
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.TargetCategory
dataclass
¤
Represents a category and optionally a type.
Source code in frequenz/client/dispatch/types.py
Attributes¤
category
property
¤
Get the category of the target.
RETURNS | DESCRIPTION |
---|---|
ComponentCategory
|
The category of the target. |
target
instance-attribute
¤
target: (
ComponentCategory
| BatteryType
| EvChargerType
| InverterType
)
The target category of the dispatch.
Implicitly derived from the types.
type
property
¤
type: BatteryType | EvChargerType | InverterType | None
Get the type of the category.
RETURNS | DESCRIPTION |
---|---|
BatteryType | EvChargerType | InverterType | None
|
The type of the category. |
frequenz.client.dispatch.types.TargetIds ¤
A set of target component IDs.
This is a frozen set, so it is immutable.
Source code in frequenz/client/dispatch/types.py
Functions¤
__new__ ¤
__new__(*ids: SupportsInt) -> Self
Create a new TargetIds instance.
PARAMETER | DESCRIPTION |
---|---|
*ids
|
The target IDs to initialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
A new TargetIds instance. |
Source code in frequenz/client/dispatch/types.py
frequenz.client.dispatch.types.TimeIntervalFilter
dataclass
¤
Filter for a time interval.