-
Notifications
You must be signed in to change notification settings - Fork 13
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
[WIP] Proof of Concept for importing hourly consumption #20
Conversation
This imports the hourly consumption into the statistics entity. If the integration is set-up for the first time, the current meter reading is fetched and used as a baseline.
I think I solved this by not fetching the total meter reading in the beginning. It's a bit unfortunate, but maybe there is a better way to do that... |
|
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 tried my best to share some thought about it, although it was not easy to follow all of your steps. But I am pretty sure you are on the right track there. Thanks a lot for taking this effort. Let me know when I can be of any help.
custom_components/wnsm/sensor.py
Outdated
if len(last_inserted_stat) == 0 or len(last_inserted_stat[entity_id]) == 0: | ||
# No previous data | ||
|
||
# FIXME: This seems not to work and after some time you get a negative consumption |
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.
could that be related to the example of the "linz" sensor being of type SensorStateClass.TOTAL
and this here being of type SensorStateClass.TOTAL_INCREASING
?
total increasing may only be incremented. maybe belatedly updating it causes internal discrepancies. we could think of changing the sensor to be a total one. but for downwards-compatibility it may be wise to add a sensor capable of this granularity of type TOTAL
(if that's the culprit)
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.
That could be the case. But I'm also not entirely sure how it happened. I noticed it twice in the docker image I used for testing, that after some time I got a negative peak. But only in the statistics - which is probably unrelated to the state class? But I have to admit, I do not know all the details of hassio sensors by heart...
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.
sure. I'd suggest let's focus on the above discussions and try to get it to work regarding the API, afterwards we can (if it still persists) focus on this quirk :)
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.
That is very likely a question for the homeassistant forum :D
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 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.
love it. hopefully we'll get an answer to that
made some comments on the PR, feel free to review it whenever you have time. :) |
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.9.0 to 4.0.0. - [Release notes](https://github.com/pytest-dev/pytest-cov/releases) - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-cov@v2.9.0...v4.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
closing this one in favor of #35 |
This imports the hourly consumption into the statistics entity. If the integration is set-up for the first time, the current meter reading is fetched and used as a baseline.
As discussed in #8, this is a proof of concept... I'm not experienced with the HA API, so maybe some things are stupid 😅
Also there are a lot of TODO in the code, where I did not have a good answer for...