-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix parsing peak usage when value is not set #143
Conversation
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.
Some minor suggestions added
output = "{}\t[{}] at {} occurred {}"\ | ||
.format(str(self.value), str(self.unit), str(self.datetime.astimezone().astimezone(pytz.utc).isoformat()), | ||
str(self.occurred.astimezone().astimezone(pytz.utc).isoformat())) | ||
.format(str(value), str(self.unit), str(timestamp), str(timestamp_occurred)) |
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.
I suggest using an f-formatted string here
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.
f-format is nowhere used in the code atm. Let's keep this for now and maybe do a follow-up PR to replace then all at once?
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 __str__
method of MBusObject
can also cause problems when the current power peak timestamp of BELGIUM_MAXIMUM_DEMAND_MONTH
is not initialised.
E.g., 1-0:1.6.0(632525252525W)(00.000*kW)
.
I will suggest handling this in the same way as the monthly peaks.
Sometimes peak usage is not yet visible in the 13 months history code. It gives a 0.0kW value with timestamp (632525252525W). Also the peak usage value can be invalid, handle this case also.
f796db1
to
389bcef
Compare
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.
Nice,
Thnx @dupondje 👍
Sometimes peak usage is not yet visible in the 13 months history code. It gives a 0.0kW value with timestamp (632525252525W).
This commit fixes handling this case.