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

Energy round #53696

Merged
merged 3 commits into from
Jul 29, 2021
Merged

Energy round #53696

merged 3 commits into from
Jul 29, 2021

Conversation

Danielhiversen
Copy link
Member

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
@Danielhiversen Danielhiversen requested a review from a team as a code owner July 29, 2021 14:46
@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (energy) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

homeassistant/components/energy/sensor.py Outdated Show resolved Hide resolved
@frenck frenck added this to the 2021.8.0 milestone Jul 29, 2021
Co-authored-by: Franck Nijhof <git@frenck.dev>
@@ -205,7 +206,8 @@ def _update_cost(self) -> None:
else:
# Update with newly incurred cost
old_energy_value = float(self._last_energy_sensor_state.state)
self._attr_state = cur_value + (energy - old_energy_value) * energy_price
self._cur_value += (energy - old_energy_value) * energy_price
Copy link
Member

Choose a reason for hiding this comment

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

There is another functional change in here, which I'm not sure if it was done on purpose or not.

The value is now only calculated for the changed part and next summed on the existing value. Previously, it would calculate it over whole value.

The difference is, is that if the price is correct, it will only be applied to the new differences, not the total value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not intended to change anything else than rounding
Do not think I understand what you mean here.

Copy link
Member

Choose a reason for hiding this comment

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

NVM it was the order that throws me off in the old version. It does absolutely the same. 👍

@frenck frenck merged commit 24a5899 into dev Jul 29, 2021
@frenck frenck deleted the energy_round branch July 29, 2021 16:44
balloob pushed a commit that referenced this pull request Jul 29, 2021
* Energy. Round cost

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Energy. Round cost

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Update homeassistant/components/energy/sensor.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
@github-actions github-actions bot locked and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rounding on new integration energy cost/compensation sensor
4 participants