ashleypittman / mec

MyEnergi Client API and Management tools.
GNU General Public License v3.0
31 stars 26 forks source link

power calculation appears wrong? #18

Open cjw296 opened 6 months ago

cjw296 commented 6 months ago

This line:

https://github.com/ashleypittman/mec/blob/master/get_zappi_history.py#L185

...appears to be wrong. I'm interested to know where the 4 in this expression came from?

I plotted some of my data from both Octopus 30 min readings and the Zappi API data, turning their joules into average kW using the above approach and the more naive one of assuming average kW is just energy divided by time:

volts = zappi_data['v1'] / 10
joules = zappi_data['imp']
kw_1 = (joules / volts * 4) / 1000
kw_2 = (joules / 60) / 1000

kw_o = octopus_data['consumption'] *2

ax = gca()
kw_1.plot(ax=ax, label='kw_1')
kw_2.plot(ax=ax, label='kw_2')
kw_o.plot(ax=ax, label='kw_o')
ax.legend()

The plot shows the naive approach lines up with the data from Octopus:

image

I thought I'd chuck in issue in as I couldn't find a reason for the constant 4 so wanted to ask...

ashleypittman commented 2 months ago

If I've understood what you've said correctly then yes, that's a much closer fit. This logic came from me trying to reverse engineer the numbers to get a result that matched the official app. I'll try and test this out with my system and report back.