-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add missing update method for sensor entity base class #69
Add missing update method for sensor entity base class #69
Conversation
Hopefully this fixes #59 (comment) and #63 (comment). |
Confirmed, both the energy and water sensors are updating themselves again. |
Something still seems to be a little bit off. It seems like when the washing machine is started, the predicted or previous energy usage is returned, before it's reset to 0. This has the nasty side effect of essentially doubling the energy usage in the statistics table, because every reset down to 0 means that subsequent increases are counted again. Any ideas what's going on here? I'm still a bit too unfamiliar with the Miele API. |
mmm it seems that the api returns the previous energy usage if the washing cycle at 14:15 has not been interrupted. And could be a Miele's side undesired behavior. Otherwise we can assume the data is a forecast.
description of eco feedback is quite obscure:
Maybe the forecast variable = 0 means that the currentEnergyConsumption is the actual program consumption, and we have to take care of it; when = 1 currentEnergyConsumption represent a forecast of the selected program (maybe not started) and we should skip it? |
Interesting thought! Yes, that may very well be the case. I'll write a mail and ask for clarification from developer@miele.com though, thanks for the tip. 👍 |
Still waiting for a response from Miele. But I did some more testing. When I started the dishwasher after it had been running earlier today, this is what the "ecoFeedback": {
"currentWaterConsumption": {
"unit": "l",
"value": 8
},
"currentEnergyConsumption": {
"unit": "kWh",
"value": 0.7
},
"waterForecast": 0.3,
"energyForecast": 0.3
}, So unfortunately this doesn't seem to hold true:
When I pressed any button on the dishwasher after turning it on, the "ecoFeedback": {
"currentWaterConsumption": {
"unit": "l",
"value": 0
},
"currentEnergyConsumption": {
"unit": "kWh",
"value": 0
},
"waterForecast": 0.3,
"energyForecast": 0.3
}, Even worse though.. This is the history from today 😒 Seems to randomly return 0 while the dishwasher is running. |
Hi! Sorry haven't been checking this issue myself yet, simply since I haven't done any laundry recently yet 😆 So couldn't check the endpoints but seem like u already put in some good efforts! If the "pre-spike" before a program starts is only there when the status is nut 5,6 or 7 than this seems like a proper fix for now. As for the 0 dives during a program, is this only true for one measurement? If so possibly we can just only change the value to 0 after we got the value twice in a row? |
Now it's convenient to have the recorder data in MariaDB 😎 The raw data corresponding to the screenshot in #69 (comment):
I guess "Not connected" could mean that my dishwasher momentarily lost the connection to Miele's cloud? It's actually possible that there were some intermittent network issues yesterday, so that could explain this situation. But nevertheless, I think it's something that needs to be properly handled by the integration, because surely others can experience internet downtime too.
So yes, in my case it was only one time in a row (see the data above). But if the internt connection is broken for a longer time, I suppose there could be more than one in a row. It feels like we should cache the last known value, and keep returning that as long as the status is "Not connected". What do you think about that? I'll also try to dig out a bit more detailed data about the pre-run spikes now. |
Oh, but now I also saw this:
So it's not only EDIT: More complete data for those three rows:
And for the "Not connected" case:
|
I pushed a new commit where a known (and hopefully sane) value is cached and returned in case of error situations. Please take a look whenever you have time. There's quite a bit to clean up there yet, but I'll be running it at home for a few days now at least. |
hi @slovdahl ! That is some proper research, well done and interesting to see. Just 2 questions. If we see NULL in your table, is the value than actually NULL or was it any of these states? "ecoFeedback" not in device_state or Second remark is that the energy and water consumption sensor classes are quite similair, do you think it would be good to merge them? Or leave them seperate as they are currently? |
With the current state of the PR, the energy consumption is not reset until the Miele device is started the next time or HA is restarted (because of the cached value). This was not actually intentional on my part, but I wonder if it's just easiest to keep it that way 🤔 I can't think of any problems it would cause, and trying to detect just means we need a lot more logic that makes the code harder to understand and maintain. Thoughts?
Good question! I thought about it too, but the honest answer at this point is that I don't know for sure. I suppose I would need to e.g. log raw responses from the Miele API to really know 🤔
Yeah, I think it would be a good idea to deduplicate the code a bit 👍 I'll look into that once we have something that works reliably. Maybe that can be done in a follow-up PR? |
Everything still looking good, I haven't seen any spurious resets the past 3 days. But still no response from Miele. |
I'll merge your PR for now, still before pushing it to main I want to try to improve it a bit. I'll try to get some work in it today. Thanks for all the research! |
* Add missing update method for sensor entity base class Related to #58. * Handle unavailable data gracefully
Related to #58.