LUA Energy Meter/ Cost
Posted: Thursday 08 August 2019 12:41
Hi,
I have a script with LUA to Energy Meter and Costs with two tariffs.
And I have a problem, when I update domoticz to 4.10717 start the problem.
At this moment device P1 Smart Meter and General Volatage stops working.
And the log with domoticz:
I have a script with LUA to Energy Meter and Costs with two tariffs.
And I have a problem, when I update domoticz to 4.10717 start the problem.
At this moment device P1 Smart Meter and General Volatage stops working.
And the log with domoticz:
and the scripts in LUA2019-08-08 12:40:37.262 Error: EventSystem: in Elektrownia: [string "commandArray = {}
..."]:29: attempt to perform arithmetic on global 'EnergyImportLow' (a nil value)
commandArray = {}
DEBUG = false
if(EnergyImportLow == nil)then
EnergyImportLow =0
EnergyImportHigh =0
EnergyExportLow = 0
EnergyExportHigh =0
PowerImport = 0
PowerExport = 0
end
local nomCompteurPrincipal = 'PC Podlicznik' --OWL
local idxCompteurIntelligent = '21'
local nomCompteurIntelligent = 'Koszty PC'--HPHC
local nomHeureCreuse = 'Tania Taryfa' -- Switch Heures Creuses
if (devicechanged['PC Podlicznik'])then
-- On récupere la valeur du compteur unique => consEnergy
-- consEnergy = (otherdevices_svalues['PC Podlicznik'])
ConsPower, consEnergy = string.match(otherdevices_svalues['PC Podlicznik'], "(%d+%.*%d*);(%d+%.*%d*)")
--on somme les compteurs HP et HC => EnergyImport
--http://www.domoticz.com/wiki/Upload_ene ... o_PVoutput
EnergyImportLow, EnergyImportHigh, PowerImport= otherdevices_svalues['PC Podlicznik']:match("([^;]+);([^;]+);([^;]+)")
EnergyImport = EnergyImportLow + EnergyImportHigh
EnergyExport = EnergyExportLow + EnergyExportHigh
print(" ----- PowerImport = " .. PowerImport .. " W");
print(" ----- EnergyImportLow = " .. EnergyImportLow .. " Wh");
print(" ----- EnergyImportHigh = " .. EnergyImportHigh .. " Wh");
print(" ----- EnergyImport = " .. EnergyImport .. " Wh");
--On calcule le delta avec le compteur actuel
delta = consEnergy - EnergyImport
--On ajoute le delta sur le bon tarif
if (otherdevices[nomHeureCreuse] == 'On') then
EnergyImportLow = EnergyImportLow + delta
else
EnergyImportHigh = EnergyImportHigh + delta
end
--On modifie le compteur intelligent
commandArray['UpdateDevice'] = idxCompteurIntelligent.."|0|"..EnergyImportLow..";"..EnergyImportHigh..";0;0;"..ConsPower..";0"
end
return commandArray