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 derived rate, fixes #20097 #21620

Merged
merged 8 commits into from
Mar 3, 2019
Merged

fix derived rate, fixes #20097 #21620

merged 8 commits into from
Mar 3, 2019

Conversation

wburgers
Copy link
Contributor

@wburgers wburgers commented Mar 3, 2019

Description:

The rate (m3/h) was calculated as current_reading - previous_reading. So time was not considered.
This PR fixes the rate by calculating the time between the readings and converting that to m3/h.

Related issue (if applicable): fixes #20097

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

Hi @wburgers,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@ghost ghost added the in progress label Mar 3, 2019
homeassistant/components/sensor/dsmr.py Outdated Show resolved Hide resolved
@amelchio amelchio self-requested a review March 3, 2019 16:57
Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

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

Sorry for clicking around, in fact I had one more comment.

tests/components/sensor/test_dsmr.py Outdated Show resolved Hide resolved
wburgers and others added 2 commits March 3, 2019 21:00
Took values from my own smart meter for the test
@ghost ghost assigned amelchio Mar 3, 2019
Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

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

Great, thank you 🎉

@amelchio amelchio merged commit 2017e45 into home-assistant:dev Mar 3, 2019
@ghost ghost removed the in progress label Mar 3, 2019
@leeuwte
Copy link
Contributor

leeuwte commented Mar 6, 2019

by chance I added this component as a custom_component to already use my changes in advance. But I'm getting an error after this PR;

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/config/custom_components/sensor/dsmr.py", line 354, in async_update
    self._state = diff / timediff * 3600
TypeError: unsupported operand type(s) for /: 'decimal.Decimal' and 'datetime.timedelta'

@amelchio
Copy link
Contributor

amelchio commented Mar 6, 2019

@leeuwte Thanks for testing 👍. Please file a GitHub issue to track this regression.

@wburgers wburgers deleted the fix-derived-rate-dsmr branch March 7, 2019 08:54
@balloob balloob mentioned this pull request Mar 20, 2019
@ghost ghost removed the platform: sensor.dsmr label Mar 21, 2019
@ghost ghost added the integration: dsmr label Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSMR hourly gas consumption incorrect
5 participants