Skip to content

Feat: sensor data source type filter#2127

Merged
Flix6x merged 13 commits into
mainfrom
feat/sensor-data-source-type-filter-2045
May 5, 2026
Merged

Feat: sensor data source type filter#2127
Flix6x merged 13 commits into
mainfrom
feat/sensor-data-source-type-filter-2045

Conversation

@BelhsanHmida

@BelhsanHmida BelhsanHmida commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Description

  • Add source_type query filtering to GET /api/v3_0/sensors/<id>/data
  • Reuse the existing belief query source_types filtering support
  • Add tests for matching, non-matching, and blank source types
  • Reject blank or whitespace-only source_type values with 422
  • Added changelog item in documentation/changelog.rst

Look & Feel

Example request:
GET /api/v3_0/sensors/<id>/data?start=2021-05-02T00:00:00+02:00&duration=PT1H20M&horizon=PT0H&unit=m³/h&resolution=PT20M&source_type=user

Example response:
{"status":"PROCESSED","values":[91.5,92.1,null,null],...}

Non-matching example:
source_type=scheduler returns values: [null, null, null, null]

Invalid example:
source_type= returns 422 with Source type must not be blank.

How to test

  • pytest flexmeasures/api/v3_0/tests/test_sensor_data.py -v
  • test_get_sensor_data_filtered_by_source_type
  • test_get_sensor_data_rejects_blank_source_type

Related Items

closes #2045


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Context:
- Issue #2045 asks for filtering GET sensor data by data source type.
- The belief query stack already accepts source type filters.

Change:
- Add the source_type request field.
- Pass it to Sensor.search_beliefs as source_types when loading sensor data.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:
- Issue #2045 adds source_type filtering to GET sensor data.
- The endpoint description lists supported optional query parameters.

Change:
- Mention source_type in the GET sensor data endpoint description.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:
- Issue #2045 needs coverage for source type filtering on GET sensor data.
- The existing sensor data fixture includes user and demo script sources.

Change:
- Add matching user and demo script source_type cases.
- Add a non-matching scheduler source_type case returning empty values.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for filtering sensor data retrieval by data source type on the v3.0 sensor data endpoint, leveraging the existing search_beliefs(..., source_types=...) filtering in the data layer.

Changes:

  • Add source_type as an optional query/body parameter for GET /api/v3_0/sensors/<id>/data.
  • Wire the parameter into the underlying beliefs query via source_types=[source_type].
  • Add parametrized API tests covering matching and non-matching source types.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
flexmeasures/api/v3_0/tests/test_sensor_data.py Adds tests verifying filtering behavior for source_type.
flexmeasures/api/v3_0/sensors.py Documents the new source_type optional parameter in the endpoint docs.
flexmeasures/api/common/schemas/sensor_data.py Introduces source_type field in request parsing and passes it into sensor.search_beliefs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread flexmeasures/api/common/schemas/sensor_data.py
Comment thread flexmeasures/api/v3_0/tests/test_sensor_data.py Outdated
Comment thread flexmeasures/api/v3_0/sensors.py
@read-the-docs-community

read-the-docs-community Bot commented Apr 23, 2026

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #32407045 | 📁 Comparing cf59a0f against latest (20f8110)

  🔍 Preview build  

3 files changed
± changelog.html
± _autosummary/flexmeasures.api.v3_0.sensors.html
± api/v3_0.html

Comment thread flexmeasures/api/common/schemas/sensor_data.py Outdated
Comment thread documentation/changelog.rst Outdated
Comment thread flexmeasures/api/common/schemas/sensor_data.py Outdated
@Flix6x Flix6x added this to the 0.33.0 milestone May 4, 2026
BelhsanHmida and others added 6 commits May 5, 2026 01:21
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida requested a review from Flix6x May 5, 2026 00:35
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x merged commit 23c2765 into main May 5, 2026
12 checks passed
@Flix6x Flix6x deleted the feat/sensor-data-source-type-filter-2045 branch May 5, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add source type filter to GET endpoint for sensor data

4 participants