I am long time user of domoticz and now starting to develop my own concepts for LUA scripting as this is the only way to make calculations based on device values in Domoticz, at least to my understanding.
I'd actually like to calculate the energy consumption of my city heating (Stadswarmte) installationwithout the need to install or tap off additional input signals from the heatmeter as these are all sealed and impossible to access. Reading out the meter via IR of course would be the superior solution but due to multiple factors (money, sealed meter) this is not possible right now, so thought I can calculate the energy consumption based on already available values.
I got available:
Heating temperature out (Voorlooptemperatuur) which is a constant 52 degrees
Heating temperature in (Teruglooptemperatuur) which is mostly around 41 degrees and due to city warming, quite stable
The circulation pump flow, 490 liters per hour
Delta temp out/in 9 degrees
to heat one kg/liter of water by one degree, we usually require 0.12 kwh of energy, so the conclusion is, that the delta temp of 9 degrees makes 0.0108 kwh of heat loss per liter water running through the heating radiators when the heating is switched on.
Calculated on a (peak) flow of 490 liter water per hour running through our city heating system, this would equal up to 5.292 kwh in an hour.
Converting this to GigaJoule (the unit with which my heatmeter measures) this brings up the consumption of the heating system to 0.0003175 gigaJoule per minute in case the circulation pump is switched on.
My idea is, to setup a counter device which will be fed by another dummy counter registering the runtime of the circulation pump, then multiplying the runtime of the pump with the specific energy usage as explained above and then write the energy consumption via LUA script into the final counter device.
Currently I am struggling with the syntax in LUA, I am using an LUA with the below syntax to read the status of the heating pump, add an incremental counter and then multiply this result by the specific usage in GJ, then write the result of this calculation into the dummy counter device:
Code: Select all
local timer_device_ID = 126
commandArray = {}
local TotalMinutesOn = otherdevices_svalues['Stadswarmte Verbruik']
if otherdevices['Circulatiepomp'] == 'On' then
TotalMinutesOn = ((TotalMinutesOn + 1)* 0.0003175)
end
commandArray['UpdateDevice'] = timer_device_ID .. '|0|' .. tostring(TotalMinutesOn)
return commandArray
126 Stadswarmte Verbruik 0.00031760083826615 2017-03-09 16:14:06 0.00031760083826615
I have setup a counter device with the following settings:
every update of the counter results in the counter counting a full gigajoule in place of the minute value.Naam:
Stadswarmte Verbruik
Omschrijving:
Type:
Meter Offset:
0
Waarde hoeveelheid (bijvoorbeeld gewicht):
Gigajoule
Waarde Units ( bijvoorbeeld Kg ):
Gigajoule
Anyone a smart idea on what I am doing wrong here?