-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Energy round #53696
Conversation
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
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 |
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.
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.
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.
Not intended to change anything else than rounding
Do not think I understand what you mean 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.
NVM it was the order that throws me off in the old version. It does absolutely the same. 👍
* 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>
Breaking change
Proposed change
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: