Skip to content

Conversation

@eduardiazf
Copy link
Contributor

@eduardiazf eduardiazf commented Oct 23, 2025

Summary

This PR adds functionality to list and manage electrical component connections within microgrids, representing the physical wiring between components in the microgrid infrastructure.

Changes

New Core Functionality

  • ComponentConnection class (_connection.py):
    • Represents a single electrical link between two components
    • Tracks source and destination component IDs following physical wiring direction
    • Includes operational lifetime tracking with helper methods (is_operational_at(), is_operational_now())
    • Validates that source and destination components are different
    • Direction aligned with current flow away from grid connection point (or islanding point)

API Client Enhancement

  • New method: list_microgrid_electrical_component_connections() in AssetsApiClient:
    • Lists all electrical component connections for a given microgrid
    • Optional filtering by source_component_ids and/or destination_component_ids
    • Returns list[ComponentConnection | None]

CLI Enhancement

  • New command: component-connections <microgrid-id>
    • Retrieves and displays electrical component connections in JSON format
    • Options:
      • --source: Filter by source component ID(s) (can be specified multiple times)
      • --destination: Filter by destination component ID(s) (can be specified multiple times)
    • Examples:
      # Get all connections for microgrid 123
      assets-cli component-connections 123
      
      # Filter by source component
      assets-cli component-connections 123 --source 5
      
      # Filter by multiple sources and destinations
      assets-cli component-connections 123 --source 5 --source 6 --destination 10
      
      # Pipe to jq for further processing
      assets-cli component-connections 123 | jq ".[]"

Supporting Infrastructure

  • JSON serialization (_connection_json.py): Converts connections to JSON format
  • Protobuf conversion (_connection_proto.py):
    • Parses protobuf messages into ComponentConnection objects
    • Validates connection data with detailed issue reporting (major/minor issues)
    • Handles missing or invalid operational lifetime gracefully
    • Logs warnings for invalid connections

Resources

@eduardiazf eduardiazf requested review from a team as code owners October 23, 2025 08:13
@eduardiazf eduardiazf requested a review from Marenz October 23, 2025 08:13
@github-actions github-actions bot added the part:docs Affects the documentation label Oct 23, 2025
@eduardiazf eduardiazf added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Oct 23, 2025
@github-actions github-actions bot added the part:tests Affects the unit, integration and performance (benchmarks) tests label Oct 23, 2025
@eduardiazf eduardiazf force-pushed the feat/electrical-component-connections branch 3 times, most recently from 01796b4 to 4f8d31b Compare October 23, 2025 09:59
…ons for microgrids

This commit introduces a new command to the CLI for retrieving and displaying electrical component connections within a specified microgrid. The new method `list_microgrid_electrical_component_connections` in the `AssetsApiClient` allows filtering by source and destination component IDs. Additionally, utility functions for printing component connections in JSON format have been added, along with the necessary data structures and protobuf handling for `ComponentConnection` objects.

The CLI command enhances usability by allowing users to filter connections and output results in a machine-readable format.

Signed-off-by: eduardiazf <[email protected]>
    This commit introduces new test cases for the `list_microgrid_electrical_component_connections` method, covering scenarios for successful connections, empty results, and error handling. The tests ensure that the API behaves as expected under various conditions, enhancing the reliability of the electrical component connection functionality.

Signed-off-by: eduardiazf <[email protected]>
@eduardiazf eduardiazf force-pushed the feat/electrical-component-connections branch from 4f8d31b to 97f65fc Compare October 23, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant