-
Notifications
You must be signed in to change notification settings - Fork 36
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
Feature/planning/schedule sensor with different units #1128
Feature/planning/schedule sensor with different units #1128
Conversation
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
…ower sensor. Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
… and soc-min, soc-max and soc-at-start in kWh and MWh. Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
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.
My preliminary advice would be to keep/adapt your tests, but to use my revisions of the QuantityField
in #1127 as a basis for the desired feature we both worked on. Up for discussion, of course.
data_key="soc-min", | ||
default_src_unit="MWh", | ||
to_unit="MWh", | ||
validate=validate.Range(min=0), |
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 validator is used on the deserialized value, which I believe would fail in case a string quantity definition has been deserialized to a quantity object, and is then compared to zero.
NB any validators passed are only applied to Quantities. | ||
For example, validate=validate.Range(min=0) will raise a ValidationError in case of negative quantities, | ||
but will let pass any sensor that has recorded negative values. |
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.
Copy pasted without being adapted.
super().__init__(*args, **kwargs) | ||
if _validate is not None: | ||
# Insert validation into self.validators so that multiple errors can be stored. | ||
validator = RepurposeValidatorToIgnoreSensors(_validate) |
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.
Which sensors?!
Actually, my PR doesn't address this, so this is something extra worth cherry-picking from your PR. |
After including the missing pieces from this PR to #1127, we can close this PR and finalize the work on PR #1127 . |
Description
This PR opens the door for scheduling in any power units, for example, in kW. Two changes were introduced for this purpose:
soc-min
,soc-max
andsoc-at-start
in arbitrary energy units.Pending tasks
Related Items
Closes #386