Calculate energy from recorded power samples
This commit is contained in:
1 parent
2117236366
commit
b76897d8f8
4 files changed
+24
-13
No files matched your search
@@ -13,6 +13,14 @@ with tempfile.TemporaryDirectory(prefix='healthapp-shelly-test-') as name:
|
||||
result=shelly.summarize(raw,root/'measured.csv',2500,17500,1000)
|
||||
assert result['integrated_joules']==1500 and abs(result['counter_joules']-1500)<.0001
|
||||
assert result['measurement_seconds']==15 and result['average_watts']==100
|
||||
assert result['power_sample_count']==15 and result['nominal_sample_coverage_seconds']==15
|
||||
# Variable power distinguishes a direct sample sum from trapezoidal integration.
|
||||
with raw.open() as f: variable=list(csv.DictReader(f))
|
||||
variable[3]['shelly_power_watts']='200'
|
||||
with raw.open('w') as f:
|
||||
w=csv.DictWriter(f,fieldnames=fields);w.writeheader();w.writerows(variable)
|
||||
variable_result=shelly.summarize(raw,root/'variable.csv',2500,17500,1000)
|
||||
assert variable_result['integrated_joules']==1600
|
||||
for start,end in [(-1000,17500),(2500,25000)]:
|
||||
try:shelly.summarize(raw,root/'bad.csv',start,end,1000)
|
||||
except ValueError:pass
|
||||
|
||||
Reference in new issue
Block a user