-
Couldn't load subscription status.
- Fork 20
Pass through 0W requests to the microgrid API independent of exclusion bounds #801
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
Changes from all commits
d55eb48
7d2661c
f4c575e
c801aa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -685,7 +685,16 @@ def distribute_power( | |
| Returns: | ||
| Distribution result | ||
| """ | ||
| if power >= 0.0: | ||
| if is_close_to_zero(power): | ||
| return DistributionResult( | ||
| distribution={ | ||
| inverter.component_id: 0.0 | ||
| for _, inverters in components | ||
| for inverter in inverters | ||
| }, | ||
| remaining_power=0.0, | ||
| ) | ||
|
Comment on lines
+688
to
+696
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. In this case, if I understand correctly, you are setting it to zero if it is close to zero, right? 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. yup, this is the value that gets sent to the microgrid API. |
||
| if power > 0.0: | ||
| return self._distribute_consume_power(power, components) | ||
| return self._distribute_supply_power(power, components) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the power is close to zero, shouldn't we use
Power.zero()instead ofvalue? What happens if the API receives something that is close to zero but not exactly zero?I understand in general we need to compare using is close comparison because of floats work, but if we treat zero specially we might run into problems too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adjusting to zero is done in the PowerDistributor. In the PowerManager, we do this check just to decide if the value needs should be clamped to the exclusion bounds or not.