Skip to content
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

PowerDelta 1xx is missing changes that (even) WebUI gets #7515

Closed
9 tasks
muhkuhgh opened this issue Jan 14, 2020 · 9 comments
Closed
9 tasks

PowerDelta 1xx is missing changes that (even) WebUI gets #7515

muhkuhgh opened this issue Jan 14, 2020 · 9 comments
Assignees
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended

Comments

@muhkuhgh
Copy link

muhkuhgh commented Jan 14, 2020

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

It seems that the PowerDelta function uses its own but inferior Energy.power_history or gets triggered less often. I haven't searched the whole Code yet.

But this should be enough to clarify:
I put on a dynamic load.
I observe the values in the WebUI.. I see e. g.
starting at 0
7 W
15 W
13 W
3 W
0

I have PowerDelta set so 102 before. So it should fire on every 2 Watt change. But in the console log I will only find

15
3

Shouldn't PowerDelta be at least as good as the WebUI? In this case the 13 W was missing but also coming or going to 0 is always missing.

Regarding the no values coming/going from/to 0 caught by PowerDelta 1xx.. this may be caused by the divide by 0 "fix".

This fix is only needed for percentual <=100 Power Delta commands as far as I found it in the code here

if ((delta > 0) && (min_power > 0)) { // Fix divide by 0 exception (#6741)

As we only need to divice through min_power for that case..

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • [ x ] Searched the problem in issues
  • [ x ] Searched the problem in the docs
  • [ x ] Searched the problem in the forum
  • [ x ] Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): _____
  • [ x ] Tasmota binary firmware version number used: 8.1
    • [ x ] Pre-compiled
    • Self-compiled
      • IDE / Compiler used: _____
  • Flashing tools used: _____
  • Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:


  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:


  • Provide the output of this command: Status 0:
  STATUS 0 output here:


  • Provide the output of the Console log output when you experience your issue; if applicable:
    (Please use weblog 4 for more debug information)
  Console output here:


TO REPRODUCE

Steps to reproduce the behavior:

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

@ascillato
Copy link
Contributor

Which device are you using?

Please, can you complete the template. Please share status 0 output and the console output when this behavior happens. Remember to set weblog to 4 for that.

@muhkuhgh
Copy link
Author

Which device are you using?

Please, can you complete the template. Please share status 0 output and the console output when this behavior happens. Remember to set weblog to 4 for that.

Sorry, I will expand it when I come home. For the time being you may have a look at my edit regarding the to/from 0 Problem.
Gosund SP112 and Avatar AWP07L.

@muhkuhgh
Copy link
Author

muhkuhgh commented Jan 15, 2020

For the to/from 0 not getting caught it should be enough to move the "min_power > 0" condition in these lines here to only affect the <101 condition part... to fix the fix. That's like 1 Minute of coding, but I don't know how to create a prober pull request.. like just enclosuring the '(delta * 100) / min_power)' part with a 'if(min_power>0) else false' part..

if ((delta > 0) && (min_power > 0)) { // Fix divide by 0 exception (#6741)

@arendst
Copy link
Owner

arendst commented Jan 16, 2020

See #7509 (comment) for some background information.

Your reference to delta is wrong. The goal of PowerDelta is measuring power difference not absolute power. So delta must contain a value representing the power from three seconds ago related to the current power. If it is equal there is no PowerDelta.

Your low power measurements are also at the bottom of what your cheap hardware can measure. Expect no valid data below 5W.

To measure power changes the code compares a sample from three seconds ago to the current value and acts accordingly. If you change loads within this time do not expect intermediate results.

Decent results for a 20W load are:

16:56:43 MQT: stat/shp5/RESULT = {"POWER1":"ON"}
16:56:43 MQT: stat/shp5/POWER1 = ON
16:56:45 MQT: tele/shp5/SENSOR = {"Time":"2020-01-16T16:56:45","ENERGY":{"TotalStartTime":"2019-06-03T15:18:50","Total":15.122,"Yesterday":0.076,"Today":0.058,"Power":19.16,"ApparentPower":22.13,"ReactivePower":11.10,"Factor":0.87,"Voltage":224.7,"Current":0.098}}
16:56:58 MQT: stat/shp5/RESULT = {"POWER1":"OFF"}
16:56:58 MQT: stat/shp5/POWER1 = OFF
16:57:00 MQT: tele/shp5/SENSOR = {"Time":"2020-01-16T16:57:00","ENERGY":{"TotalStartTime":"2019-06-03T15:18:50","Total":15.122,"Yesterday":0.076,"Today":0.058,"Power":4.57,"ApparentPower":11.83,"ReactivePower":10.90,"Factor":0.39,"Voltage":227.0,"Current":0.052}}

@ascillato2
Copy link
Collaborator

Closing this issue as it has been answered.


Support Information (Guide)

See Wiki for more information.
See FAQ for common questions/answers and links if none of your question is in the list.
See Chat for more user experience.
See Community for forum.
See Code of Conduct

@ascillato2 ascillato2 added the question Type - Asking for Information label Jan 16, 2020
@muhkuhgh
Copy link
Author

muhkuhgh commented Jan 16, 2020

See #7509 (comment) for some background information.

Your reference to delta is wrong. The goal of PowerDelta is measuring power difference not absolute power. So delta must contain a value representing the power from three seconds ago related to the current power. If it is equal there is no PowerDelta.

Thank you for your time and the detailed answer. But sadly It doesn't satisfy me at all :(
=> What did you lead to assume I interpreted it any different?
With PowerDelta set to 102 it should send me an update for every change greater 2 Watt it notices...
But if the load was 10 Watt for 10 seconds then 0 for 10 Seconds then 20 Watt for 10 Seconds and then goes back to 0 it should notice 10,0,20,0. But all I get is 10 and 20. Because with the FIX for not dividing through zero (min_power>0) it no longer works coming from or going down to zero! Allthough for the absolute powerdelta computation that condition is not needed, as we only need the division for the relative percentual powerdelta.. Where am I wrong here? I really don't get it (yet?)

Also, why must it contain a value from three seconds ago? Why not just doing the delta maths everytime also the webui gets new values? (On a side note: Three seconds? Why am I getting much faster messages from PowerDelta than (see below))

Your low power measurements are also at the bottom of what your cheap hardware can measure. Expect no valid data below 5W.

=> I am also using this for a master thesis for one of my students I am currently in charge of.. this circuitry is designed around low loads.. But still for most of my plugs all I want is not to miss it going down or coming up from zero.

To measure power changes the code compares a sample from three seconds ago to the current value and acts accordingly. If you change loads within this time do not expect intermediate results.

=> How does it come then, that my Gosund SP112 flashed with the latest stock 8.1 tasmota is reporting up to 4 values per second (only using PowerDelta 102 command) and so catches the peak of the fridge turning on every time perfectly?

2020-01-16 16:20:13 | 2
2020-01-16 16:21:30 | 920
2020-01-16 16:21:30 | 873
2020-01-16 16:21:30 | 183
2020-01-16 16:21:34 | 112
2020-01-16 16:21:35 | 97
2020-01-16 16:21:35 | 95
2020-01-16 16:21:37 | 91
2020-01-16 16:25:14 | 82

Decent results for a 20W load are:

16:56:43 MQT: stat/shp5/RESULT = {"POWER1":"ON"}
16:56:43 MQT: stat/shp5/POWER1 = ON
16:56:45 MQT: tele/shp5/SENSOR = {"Time":"2020-01-16T16:56:45","ENERGY":{"TotalStartTime":"2019-06-03T15:18:50","Total":15.122,"Yesterday":0.076,"Today":0.058,"Power":19.16,"ApparentPower":22.13,"ReactivePower":11.10,"Factor":0.87,"Voltage":224.7,"Current":0.098}}
16:56:58 MQT: stat/shp5/RESULT = {"POWER1":"OFF"}
16:56:58 MQT: stat/shp5/POWER1 = OFF
16:57:00 MQT: tele/shp5/SENSOR = {"Time":"2020-01-16T16:57:00","ENERGY":{"TotalStartTime":"2019-06-03T15:18:50","Total":15.122,"Yesterday":0.076,"Today":0.058,"Power":4.57,"ApparentPower":11.83,"ReactivePower":10.90,"Factor":0.39,"Voltage":227.0,"Current":0.052}}

@arendst
Copy link
Owner

arendst commented Jan 16, 2020

Ah regarding 0 I see the issue. Will look into it.

My devices almost never return to 0 so I didn't see it. Now it makes sense.

@arendst arendst reopened this Jan 16, 2020
@arendst arendst added the bug Type - Confirmated Bug label Jan 16, 2020
@muhkuhgh
Copy link
Author

muhkuhgh commented Jan 16, 2020

Ah regarding 0 I see the issue. Will look into it.

My devices almost never return to 0 so I didn't see it. Now it makes sense.

Thank you so much - I was starting do despair ;-)
The big problem here for me is, that It worked perfectly fine with my SP112 as they show 2W at no load... but my AWP07L go down to 0.. and if I e. g only log telemtry values every 5 minutes and with PowerDelta 1xx.. it ruins the Enegry computation when I integrate up to 5 more minutes with the last caught value being 500 W e. g. because it went to Zero afterwards but it takes time till the next telemtry message to be aware of that...

Of course I thought about work arounds like PowerLow/high commands or getting the data from the energylogs (which of course would be more precise anyway but also can have downsides) but they seemed so unnecessary as there was no reason for the PoweDelta >100 command to exclude 0 ;-)

For the to/from 0 not getting caught it should probably be enough to move the "min_power > 0" condition in these lines here to only affect the <101 condition part... to fix the fix. That's like 1 Minute of coding, but I don't know how to create a prober pull request.. like just enclosuring the '(delta * 100) / min_power)' part with a 'if(min_power>0) else false' part..

if ((delta > 0) && (min_power > 0)) { // Fix divide by 0 exception (#6741)

@ascillato2 ascillato2 removed the question Type - Asking for Information label Jan 16, 2020
arendst added a commit that referenced this issue Jan 17, 2020
Fix PowerDelta calculation not detecting zero power (#7515)
@arendst arendst added the fixed Result - The work on the issue has ended label Jan 17, 2020
@arendst arendst self-assigned this Jan 17, 2020
@ascillato
Copy link
Contributor

@muhkuhgh

Hi, This issue has been fixed in the actual codebase. Please, can you test latest changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

4 participants