Skip to content

Comments

Support new forecasting endpoints (/sensors/{id}/forecasts/trigger and /sensors/{id}/forecasts/{uuid})#180

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/support-forecasting-endpoints
Draft

Support new forecasting endpoints (/sensors/{id}/forecasts/trigger and /sensors/{id}/forecasts/{uuid})#180
Copilot wants to merge 3 commits intomainfrom
copilot/support-forecasting-endpoints

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

FlexMeasures server v0.31.0 introduced POST /sensors/{id}/forecasts/trigger and GET /sensors/{id}/forecasts/{uuid} for async forecast job execution. This adds client-side support for both.

New methods

  • trigger_forecast(sensor_id, ...) — POSTs to /sensors/{id}/forecasts/trigger, returns forecast job UUID. Training params (train_start, train_period, retrain_frequency, regressors, etc.) are serialized into a nested config dict per the server schema.
  • get_forecast(sensor_id, forecast_id) — GETs /sensors/{id}/forecasts/{uuid}, polling on 202 until the job completes (200). Returns {values, start, duration, unit}.
  • trigger_and_get_forecast(sensor_id, ...) — Convenience wrapper combining both.

Usage

# Trigger and poll until complete
forecast = await client.trigger_and_get_forecast(
    sensor_id=5,
    start="2025-01-05T00:00:00+00:00",
    end="2025-01-07T00:00:00+00:00",
    train_start="2025-01-01T00:00:00+00:00",
    retrain_frequency="PT24H",
    future_regressors=[2, 3],
)
# {"values": [...], "start": "...", "duration": "PT48H", "unit": "kW"}

# Or step-by-step
forecast_id = await client.trigger_forecast(sensor_id=5, start="...", end="...")
forecast = await client.get_forecast(sensor_id=5, forecast_id=forecast_id)

Requires FlexMeasures server ≥ 0.31.0. get_forecast respects the client's existing polling_timeout, polling_interval, and max_polling_steps settings.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support new forecasting endpoints</issue_title>
<issue_description>New forecasting API endpoints were introduced in the FlexMeasures server: [POST] /sensors/(id)/forecasts/trigger <api/v3_0.html#post--api-v3_0-sensors-id-forecasts-trigger>_ and [GET] /sensors/(id)/forecasts/(uuid) <api/v3_0.html#get--api-v3_0-sensors-id-forecasts-uuid>_ to forecast sensor data [see PR FlexMeasures/flexmeasures-client#1813 <https://www.github.com/FlexMeasures/flexmeasures/pull/1813>, PR FlexMeasures/flexmeasures-client#1823 <https://www.github.com/FlexMeasures/flexmeasures/pull/1823> and PR FlexMeasures/flexmeasures-client#1917 <https://www.github.com/FlexMeasures/flexmeasures/pull/1917>_]. We need to support these endpoints in the FlexMeasures client.</issue_description>

<agent_instructions>Make sure to use #1917 for the latest schema versions! And call the test-specialist as a sub-agent in your task. Make sure the test-specialist actually creates new tests and, super important, runs them successfully (not just says it ran them successfully by inspecting code).</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 23, 2026 19:26
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…ecast

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI changed the title [WIP] Support new forecasting API endpoints in client Support new forecasting endpoints (/sensors/{id}/forecasts/trigger and /sensors/{id}/forecasts/{uuid}) Feb 23, 2026
Copilot AI requested a review from Flix6x February 23, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support new forecasting endpoints

2 participants