这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Conversation

@wborn
Copy link
Member

@wborn wborn commented Jan 18, 2017

This PR improves the Plugwise Circle/Stealth power measurements as follows:

  • Increase precision by using PULSES_PER_KW_SECOND = 468.9385193 which is also used by all other Plugwise implementations on the internet, instead of PULSE_FACTOR = 2.1324759f which is: 1/(468.9385193/1000) but with loss of precision
  • Increase precision by using doubles instead of floats in calculations
  • Use seconds correction that is part of the PowerInformationResponseMessage
  • Fix wrong Energy date/time values being used in PowerBufferResponseMessage
  • Corrected log address calculations in InformationResponseMessage, PowerBufferRequestMessage, PowerBufferResponseMessage because the original address calculation would cause the same logs returned multiple times (inspired by Plugwise-2-pi)
  • Make sure Circle/Stealth last hour power consumption is always the last hour (also after startup) and is updated only after calibration took place

Power measurements now exactly match the decimals found in the Plugwise Source database (though with more precision).

Signed-off-by: Wouter Born <eclipse@maindrain.net>
@watou
Copy link
Contributor

watou commented Jan 18, 2017

Hi @wborn, did you consider and reject using BigDecimal since accuracy and precision are factors here?

    private static final BigDecimal PULSES_PER_KW_SECOND = new BigDecimal("468.9385193");

    private static final BigDecimal PULSES_PER_W_SECOND = PULSES_PER_KW_SECOND.movePointLeft(3);

etc.

@wborn
Copy link
Member Author

wborn commented Jan 19, 2017

I just rewrote the calculations to BigDecimals and found that the percentage error of using doubles in the calculations is: 0.07984247352300347106 %

So I would prefer using doubles over BigDecimals because:

  • the error is small
  • the code is easier to understand with doubles
  • double calculations use less CPU/memory
  • the calculations now have exactly the same results (but with more decimals) as stored in the Plugwise Source database. This also makes it easier to compare and validate the correctness of the Plugwise Binding calculations.

@watou
Copy link
Contributor

watou commented Jan 19, 2017

That sounds like a valuable exercise you went through. Do you think this PR is ready to merge?

@wborn
Copy link
Member Author

wborn commented Jan 19, 2017

Yes I've been using this code without any issues for a week myself now.

Now that the measurements are the same as Plugwise Source, I store the "last hour" kWh values in influxdb and use them in Grafana to draw nice charts. :-)

@watou watou merged commit 6ee86c1 into openhab:master Jan 19, 2017
@watou
Copy link
Contributor

watou commented Jan 19, 2017

Should 6ee86c1 be cherry picked to the 1.9.x branch so it appears in the 2.0.0 release (I'm guessing yes, but WDYT)?

@wborn
Copy link
Member Author

wborn commented Jan 19, 2017

Thanks for merging @watou . Yes it would be nice when it is cherry picked so it also to appears in the 2.0.0 release. I think it will be my last Plugwise 1.9.x contribution since it is more or less feature complete for me now. My next contribution might be a real openHAB 2.0 Plugwise Binding. ;-)

@watou
Copy link
Contributor

watou commented Jan 19, 2017

My next contribution might be a real openHAB 2.0 Plugwise Binding. ;-)

That will be very well received! Thanks so much for your contributions. I will make sure this PR gets into the 2.0.0 path.

watou pushed a commit that referenced this pull request Jan 19, 2017
Signed-off-by: Wouter Born <eclipse@maindrain.net>
@watou
Copy link
Contributor

watou commented Jan 19, 2017

Cherry picked onto 1.9.x branch.

@wborn wborn deleted the plugwise-power-measurement-improvements branch January 19, 2017 18:01
@9037568 9037568 modified the milestones: 1.10.0, 1.9.0 Jun 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants