Skip to content
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

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

dupondje
Copy link
Collaborator

@dupondje dupondje commented Nov 2, 2023

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.

Copy link

@jbouwh jbouwh left a 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

dsmr_parser/objects.py Outdated Show resolved Hide resolved
dsmr_parser/objects.py Outdated Show resolved Hide resolved
dsmr_parser/objects.py Outdated Show resolved Hide resolved
dsmr_parser/objects.py Outdated Show resolved Hide resolved
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))
Copy link

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

Copy link
Collaborator Author

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?

Copy link
Contributor

@ejpalacios ejpalacios left a 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.
Copy link

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Nice,
Thnx @dupondje 👍

@dupondje dupondje merged commit e8a8627 into ndokter:master Nov 6, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants