-
Notifications
You must be signed in to change notification settings - Fork 16
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
Keep power meter values as they reset when power is lost to the shelly device #102
Comments
You should ask Allterco Robotics (the company behind Shelly) about this. My app just read the values which are returned by the Shelly. I'm not planning on solving this on my end. |
Dear Jelger, I logged a case but that did not go as planned. Thanks in advance for your time taken! |
That's a shame. Implementing this in my app for each driver with the meter_power capability is not hard but a lot of work. I'd like to spend my time on feature requests that benefit more people. So if you can find more people interested in this I will consider it. And of course I'm open to pull requests from other developers that want to help out develop the app. That's the whole idea of open source software. I'll open this this ticket and label it as feature request. |
I'd like to have this feature too. I'm using it together with Power by the Hour app. This to measure the power usage over the last week / month / year for my dryer , laundry machine and my dishwasher. Now it constantly resets and cannot do anything with the data. Thanks! |
I was thinking about this the other day but I cant really come up with a proper solution. If either of you can come up with a bulletproof logic on how to functionally achieve this I'm willing to look into it. You will need to describe how I can maintain a seperate count of the power meter independent of the value returned by the Shelly itself. If you can not come up with a solution as well I'll close this issue again. |
If I'm not mistaken this is a feature request at Shelly too. I have been thinking of this a bit but only think I can come up with is writing everything to a value and importing it if there has been a moment of connection loss (FW update for example) measuring the difference and if the value is 0 import the previous value. But there are lot's of if's. |
Hi Jelger, |
That is a option indeed, but that doesn't solve the FW upgrade gap, or these should be scheduled at midnight too. |
No
What is there to discuss? As mentioned I need a bulletproof and stand-alone solution before I will implement this as it will affect all users and should not raise issues. And as @mhoogenbosch mentioned there are still a lot of if's that do not give me this garantee.
The reboot solution or even maintaining your own power meter value in a variable with some custom logic is already possible with the current app and some next level flow building. For now the only proper solution is to solve this in the Shelly firmware and I dont see that happening and there probably is a good reason why this value does not survive a reboot. |
that would be the solution then i guess.... just rebooting all shellys to have something workable from a kwh counting perspective.... @jghaanstra |
So the logic would look like this?
|
Maybe more like this as we need one more failsafe value to capture another occurrence after the first one:
this way the first line would hit if it is business as usual and the second would hit if there is a firmware upgrade or a reboot after the long term value has been created. my programming is rusty so you might have an easier way to determine the states but this is what i was thinking of... |
Ok, seems viable. Do all GEN1 Shelly devices loose the power meter value after a reboot? |
according to the API documentation it looks that way. The plug S does it for sure (have lots of those....). The ones that do somehow have a surviving power meter will not run into the else step as the meter will always be higher ;) |
@BuyerJ Tryed it your way on my own "app" for testing. Did not work as excepted the way to described. I ended up with a solution that increment the positive difference between current and previous: fetch('http://x.x.x.x/rpc/PM1.GetStatus?id=0')
.then((res) => res.json())
.then((json) => {
const current = json.aenergy.total || 0; // Wh
const longterm = this.getStoreValue('longterm') || 0;
const previous = this.getStoreValue('previous_power') || current;
const change = current - previous;
if (change > 0) {
const totalWh = longterm + change;
this.log('incremented', change);
this.setStoreValue('longterm', totalWh);
this.setCapabilityValue('meter_power', totalWh / 1000);
}
this.setStoreValue('previous_power', current);
})
.catch((err) => {
// do stuff
}); Seems like its working with my limited testing |
Who can help me set this up? I get frustrated every time after each power outage that the values are reset. Should I set this as a HomeyScript for each Shelly device? ✅ Script Success Or, how can I set this up via an advanced flow? |
I think i created my own homey app with this one. The |
Sure, can you help me a little bit with how I can do this myself? |
I have the code i used here: https://github.com/joachimvenaas/site.venaas.diydevices/tree/main/drivers/heatpump |
Dear Developer,
when the power is lost to a shelly plug S (at least) the power meter is reset to 0.
the power in the homey insights gets back to 0 in this case as well. (and also "power by the hour" suffers from this.)
is there a possibility to keep track of the last value say every hour or so and whenever there is a value reported by the device that is lower than the last value, have an option to add the older higher value to the one that is currently showing?
It may even be a manual value add to the value of the plug but should preferably be an automated process with a manual override if needed to intervene manually.
could you consider this as after a power outage all usage values of the shelly plugs look bad.
thanks in advance!
The text was updated successfully, but these errors were encountered: