based on my previous thread about City Heating (Stadswarmte), I have now developed a script solution which can calculate the actual heat consumption and heating power in Domoticz and LUA, just based on a few variables and without using additional hardware than I already had in my home.
As the heatmeter in my City Heating installation is completely sealed, I was not able to access the meter for any kind of reading and buying an IR read/write head is just not in the budget right now and will also negatively impact the battery life of my heatmeter.
In my home I am running a Max! Heating system with radiopgraphic radiator valves controlled by a Max!Cube and linked to the Domoticz installation via the Max solution in this forum documented.
Before you start, you will need to find out a few things about your heating installation, usually you can read most of it from the display of your heatmeter:
- Temperature outgoing flow (mine is 51 degrees celsius)
- Temperature return flow (mine 42 degrees celsius)
- PeakFlow of the Circulation pump in Liters/Hour (mine is 495l/h)
- Number of Total Radiator valves on the installation (I got total 8 installed, 5 of them are automated via Max!)
Things to be done in preperation in Domoticz:
- Create a few virtual devices
Custom Sensor, Unit Watt for logging the heating radiator output
Usage Sensor, Electric for logging the current heating consumption, should be normally in Gigajoule but I covert to Watt in the scripts to make it better comparable with the P1 Smart Meter stats
Counter, Electric to log the Total consumption, should normally be in Gigajoule but also here I am converting to Watt for better comparison
- Create uservariables:
valvecount, String, Base value=0
totalvalves, String, Base value= the amount of total radiator valve in your home
-Modify the heating script from the Max Integration to also update the uservariable we just created:
Modification one:
Code: Select all
-- Count the number of valves that are open more than BoilerOnPercent
if tonumber(sValvePercentOpen) >= BoilerOnPercent then
ValveCount = ValveCount + 1
table.insert(commandArray, {['OpenURL'] = 'http://127.0.0.1:8080/json.htm?type=command¶m=updateuservariable&vname=valvecount&vtype=2&vvalue='..ValveCount})
message0 = ('Uservariable valvecount updated')
print (message0)
end
Code: Select all
if (PercentMax < (BoilerOnPercent - HysterysisOffPercent)) and (otherdevices[BoilerSwitch] == 'On') then -- If the number of valves open more than BoilerOnPercent minus HysterysisOffPercent
commandArray[BoilerSwitch]='Off' -- turn off boiler
table.insert(commandArray, {['OpenURL'] = 'http://127.0.0.1:8080/json.htm?type=command¶m=updateuservariable&vname=valvecount&vtype=2&vvalue=0'})
message0 = ('Uservariable valvecount updated, Boiler Off')
if printData == true then
print ("Test Off 1/1 passed")
print ("Command sent - Turn OFF Boiler ")
print (message0)
end
end
Code: Select all
local total_stadswarmte = 131
local current_stadswarmte = 130
local heating_power = 129
local heating_combined = 132
local MinutesOn = (otherdevices_svalues['Circulatiepomp Timer']) --change this to the name of your virtual counter of your pump
local ValveCount = (uservariables['valvecount']) --change this according to the usevariable set
local TotalValves = (uservariables ['totalvalves'])
local TotalPumpFlow = 490
local DeltaT = 9
local TotalFlow = (((0.003762 * TotalPumpFlow) / 60) * DeltaT) --this is the calculation for the total maximum flow
commandArray = {}
TotalMinutesOn = (((MinutesOn * TotalFlow)/1000)*277.78) --this is the calculation for the overall pump runtime and heat usage in KiloWatt
CurrentConsumption = ((TotalFlow / TotalValves) * ValveCount) --this is the calculation for the current heat consumption per single valve open, multiplied by the amount of open valves
if otherdevices['Circulatiepomp'] == 'On' then
HeatingPower = (((TotalFlow / TotalValves)*277.78)* ValveCount)*1000 -- this is the calculation for current heating power in KiloWatt
commandArray[1] = {['UpdateDevice'] = total_stadswarmte .. '|0|' .. tostring(TotalMinutesOn)} --update Stadswarmte Total counter
commandArray[2] = {['UpdateDevice'] = current_stadswarmte .. '|0|' .. tostring(CurrentConsumption)} --update Current Counter
commandArray[3] = {['UpdateDevice'] = heating_power .. '|0|' .. tostring(HeatingPower)} --update Current Counter
commandArray[4] = {['UpdateDevice'] = heating_combined .. '|0|' .. tostring(HeatingPower).. ';' .. tostring(TotalMinutesOn)} --update combined Counter
parseDebug1 = ('Total Consumption Stadswarmte=' .. tostring(TotalMinutesOn) .. ' KiloWatt | Current Consumption Stadswarmte=' .. tonumber(CurrentConsumption) .. ' GigaJ | Heating Power (KiloWatt) ' .. tostring(HeatingPower)) --compile debug message
parseDebug2 = ('Count open valves=' .. tostring(ValveCount) .. ' Total Flow is ' .. tostring(TotalFlow)) --compile second debug message
print (parseDebug1) --print debug message
print (parseDebug2) --print debug message
end
if otherdevices['Circulatiepomp'] == 'Off' then --check device status Circulatiepomp
HeatingPower = (((TotalFlow / TotalValves)*277.78)* 0)*1000 -- this is the calculation for current heating power in KiloWatt
commandArray[1] = {['UpdateDevice'] = total_stadswarmte .. '|0|' .. tostring(TotalMinutesOn)} --update Stadswarmte Total counter
commandArray[2] = {['UpdateDevice'] = current_stadswarmte .. '|0|0'} --update Current Counter
commandArray[3] = {['UpdateDevice'] = heating_power .. '|0|0'} --update Current Counter
commandArray[4] = {['UpdateDevice'] = heating_combined .. '|0|' .. tostring(HeatingPower) .. ';' .. tostring(TotalMinutesOn)} --update combined Counter
parseDebug1 = ('Total Consumption Stadswarmte=' .. tostring(TotalMinutesOn) .. ' KiloWatt | Current Consumption Stadswarmte=' .. tonumber(CurrentConsumption) .. ' GigaJ | Heating Power (KiloWatt) ' .. tostring(HeatingPower)) --compile debug message
parseDebug2 = ('Count open valves=' .. tostring(ValveCount) .. ' Total Flow is ' .. tostring(TotalFlow)) --compile second debug message
print (parseDebug1) --print debug message
print (parseDebug2) --print debug message
print ('Stadswarmte no usage update necessary')
end
return commandArray
SUggestions for improvements are welcome, specifically I am not yet happy with the way I log the data in Domoticz...