-
Notifications
You must be signed in to change notification settings - Fork 15
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] Importing hourly consumption #35
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.
Thanks! edit: I get the same float error now after restarting HA. And the first time you get this other error, which seems to be cause by the database upgrade. |
I just pushed a workaround and also asked in the HA community: https://community.home-assistant.io/t/get-last-statistics-returned-str-then-datetime-now-float/542311 |
Codecov Report
@@ Coverage Diff @@
## main #35 +/- ##
==========================================
- Coverage 31.77% 29.56% -2.21%
==========================================
Files 9 9
Lines 384 433 +49
Branches 48 55 +7
==========================================
+ Hits 122 128 +6
- Misses 258 301 +43
Partials 4 4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Seems to fix the logs at least. |
Looks like there was indeed in the changeling a breaking change listed to statistics that relates to using timestamp columns |
Thanks for digging this up. It's funny that the "only" breaking change is the unavailability during migration... |
There should be an associated statistics_meta entry for the cost sensor that gets created along with the consumption sensor right? Would it be possible to write the statistics entries for the cost sensor at the same time as writing the statistics for the consumption sensor? I noticed that with this branch, the cost sensor does not get created in the statistics_meta table, however, there is a sensor that is created with the same name as the consumption sensor suffixed with "_cost" Would it then be feasible to take an input_number sensor for example and use this as the basis for the statistics entries for the cost sensor? I think that in order for this to work, you would also first need to create the meta entry, but perhaps it might do the trick... |
I do not know the internals of HA that much, but I would guesstimate that writing statistics does not help, as statistics are not states. |
The costs entity is only visible in the devtools -> statistics tab, and for me it exists as soon as the sensor from the integration is created. |
ah, you have to configure costs for the sensor first. I had checked "do not track costs". |
@reox I've to admit that, I haven't installed the PR on my system. afaik it replaces the sensor by its historical counterpart. Is this correct and also a suitable solution iyo? |
yes! I started to implement this, but got lost in setting up the devcontainer.. apparently, the one that is configured right now is deprecated and shall not be used. So, my plan was to add another parameter to |
Now I feel stupid.. On closer thought on the summer/wintertime issue: it is no issue at all. UTC is monotonic and does not jump around. Thus, I'm certain that the things get imported correctly and just the UI has to display them properly. |
okay, so the only thing that might be neat is #83 and i created a new ticket for that. We could now start to merge this into a dual-sensor setup, where we have both the consumption and the meter reading! |
Sorry for the late reply. I'll try to split this up into two separate sensors then. |
should we remove it again @TheRealVira ? |
I would really love the hourly consumption - does it make sense to try the statistics branch yet, or should I wait a bit more? |
sure! If you are starting from scratch anyways, maybe test #89 directly :) |
No, I'm not starting from scratch, I have the main branch running for several months already. Above are some mentions of things that still need to be done. Will they impact the experience if I try it now or should I be good to go? |
@reox I moved your branch and created a new PR, so we can follow up in the base repo. You should be able to commit.