-
Notifications
You must be signed in to change notification settings - Fork 48
Feature/save soc values as a sensor #1018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Ahmad-Wahid
wants to merge
17
commits into
main
Choose a base branch
from
feature/planning/save-soc-values-as-a-sensor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c1d8f46
create an soc sensor and a schedule for it
Ahmad-Wahid 23160b9
run pre-commit
Ahmad-Wahid 91eb16e
add soc param to get soc sensor value and save the soc schedule
Ahmad-Wahid 1b3651e
Merge remote-tracking branch 'origin/main' into feature/planning/save…
Ahmad-Wahid 7f01658
rename get-soc-sensor-value function
Ahmad-Wahid 1d57049
Merge remote-tracking branch 'origin/main' into feature/planning/save…
Ahmad-Wahid d17fe37
refactor the schema and cli inputs
Ahmad-Wahid 3dd9968
Merge branch 'main' into feature/planning/save-soc-values-as-a-sensor
Flix6x 5d8b14d
fix: extend type annotation
Flix6x 3833c2e
refactor: flatten if/else-block
Flix6x 42b121a
feature: add unit validation
Flix6x 91d3e74
Merge remote-tracking branch 'refs/remotes/origin/main' into feature/…
Flix6x 359fa13
Refactor return value of test util using dataclasses
Flix6x 405012c
fix: add test and fix unit conversion for SoC schedule
Flix6x c095707
revert: remove deserialization case, see https://github.com/FlexMeasu…
Flix6x 858a7c3
fix: tests
Flix6x 6dede52
revert: accidentally reintroduced code block upon resolving merge con…
Flix6x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1216,9 +1216,16 @@ def create_schedule(ctx): | |||||||
| "--soc-at-start", | ||||||||
| "soc_at_start", | ||||||||
| type=QuantityField("%", validate=validate.Range(min=0, max=1)), | ||||||||
| required=True, | ||||||||
| required=False, | ||||||||
| help="State of charge (e.g 32.8%, or 0.328) at the start of the schedule.", | ||||||||
| ) | ||||||||
| @click.option( | ||||||||
| "--soc", | ||||||||
| "soc", | ||||||||
| type=VariableQuantityField("MWh"), | ||||||||
| required=False, | ||||||||
| help="State of charge (e.g sensor:<id>, or 0.328) at the start of the schedule.", | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ) | ||||||||
| @click.option( | ||||||||
| "--soc-target", | ||||||||
| "soc_target_strings", | ||||||||
|
|
@@ -1353,6 +1360,7 @@ def add_schedule_for_storage( # noqa C901 | |||||||
| start: datetime, | ||||||||
| duration: timedelta, | ||||||||
| soc_at_start: ur.Quantity, | ||||||||
| soc: ur.Quantity | Sensor | None, | ||||||||
| charging_efficiency: ur.Quantity | Sensor | None, | ||||||||
| discharging_efficiency: ur.Quantity | Sensor | None, | ||||||||
| soc_gain: ur.Quantity | Sensor | None, | ||||||||
|
|
@@ -1402,7 +1410,8 @@ def add_schedule_for_storage( # noqa C901 | |||||||
| ) | ||||||||
| raise click.Abort() | ||||||||
| capacity_str = f"{power_sensor.get_attribute('max_soc_in_mwh')} MWh" | ||||||||
| soc_at_start = convert_units(soc_at_start.magnitude, soc_at_start.units, "MWh", capacity=capacity_str) # type: ignore | ||||||||
| if soc_at_start is not None: | ||||||||
| soc_at_start = convert_units(soc_at_start.magnitude, soc_at_start.units, "MWh", capacity=capacity_str) # type: ignore | ||||||||
| soc_targets = [] | ||||||||
| for soc_target_tuple in soc_target_strings: | ||||||||
| soc_target_value_str, soc_target_datetime_str = soc_target_tuple | ||||||||
|
|
@@ -1429,6 +1438,7 @@ def add_schedule_for_storage( # noqa C901 | |||||||
| belief_time=server_now(), | ||||||||
| resolution=power_sensor.event_resolution, | ||||||||
| flex_model={ | ||||||||
| "soc": soc, | ||||||||
| "soc-at-start": soc_at_start, | ||||||||
| "soc-targets": soc_targets, | ||||||||
| "soc-min": soc_min, | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.