Guys,
Need some help!
Im using the scripts/snippets as mentioned a few pages ago, but in some kind of way my measurements are incorrect. See below.
Code: Select all
2019-01-12 20:44:24.693 (P1) P1 Smart Meter (Power)
2019-01-12 20:44:24.728 Status: LUA: ----- PowerGeneration = 0.000 W
2019-01-12 20:44:24.728 Status: LUA: ----- EnergyGeneration = 5298730.000 Wh
2019-01-12 20:44:24.728 Status: LUA: ----- PowerImport = 460 W
2019-01-12 20:44:24.728 Status: LUA: ----- EnergyImportLow = 2058351 Wh
2019-01-12 20:44:24.728 Status: LUA: ----- EnergyImportHigh = 1732276 Wh
2019-01-12 20:44:24.728 Status: LUA: ----- EnergyImport = 3790627 Wh
2019-01-12 20:44:24.728 Status: LUA: ----- PowerExport = 0 W
2019-01-12 20:44:24.728 Status: LUA: ----- EnergyExportLow = 1141386 Wh
2019-01-12 20:44:24.729 Status: LUA: ----- EnergyExportHigh = 2645175 Wh
2019-01-12 20:44:24.729 Status: LUA: ----- EnergyExport = 3786561 Wh
2019-01-12 20:44:24.729 Status: LUA: ----- PowerConsumption = 460 W
2019-01-12 20:44:24.729 Status: LUA: ----- EnergyConsumption = 5302796 Wh
At the moment I'm not generating any energy, but it register import. Any suggestions to solve this?
Am using the following calculation:
Code: Select all
----------------------------------------------------------------------------------------------------------
-- CommandArray
----------------------------------------------------------------------------------------------------------
commandArray = {}
-- Generated
PowerGeneration, EnergyGeneration = otherdevices_svalues[GenerationDeviceName]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
print(" ----- EnergyGeneration = " .. EnergyGeneration .. " Wh");
end
-- Imported
EnergyImportLow, EnergyImportHigh, EnergyExportLow, EnergyExportHigh, PowerImport, PowerExport = otherdevices_svalues[EnergyDeviceName]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
EnergyImport = EnergyImportLow + EnergyImportHigh
EnergyExport = EnergyExportLow + EnergyExportHigh
if Debug=="YES" then
print(" ----- PowerImport = " .. PowerImport .. " W");
print(" ----- EnergyImportLow = " .. EnergyImportLow .. " Wh");
print(" ----- EnergyImportHigh = " .. EnergyImportHigh .. " Wh");
print(" ----- EnergyImport = " .. EnergyImport .. " Wh");
print(" ----- PowerExport = " .. PowerExport .. " W");
print(" ----- EnergyExportLow = " .. EnergyExportLow .. " Wh");
print(" ----- EnergyExportHigh = " .. EnergyExportHigh .. " Wh");
print(" ----- EnergyExport = " .. EnergyExport .. " Wh");
end
-- Calculate consumption
PowerConsumption = PowerGeneration + PowerImport - PowerExport
if Debug=="YES" then
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
end
EnergyConsumption = EnergyGeneration + EnergyImport - EnergyExport
if Debug=="YES" then
print(" ----- EnergyConsumption = " .. EnergyConsumption .. " Wh");
end
In some kind of way its perhaps related to the following:
Code: Select all
----------------------------------------------------------------------------------------------------------
-- Domoticz IDX and names of the needed devices
----------------------------------------------------------------------------------------------------------
local GenerationDeviceName = "kWh Meter" -- Device name of the Generated energy
local EnergyDeviceName = "Power" -- Name of the energy device that shows imported and exported energy
local ConsumptionIDX = "5829" -- IDX of the energy device that shows calculated Consumption
local ConsumptionDeviceName = "Electricity" -- Name of the energy device that shows calculated Consumption
For the "ConsumtionDeviceName" im using a virtual sensor (Electric, (instant + counter)).
Thanks in advance!