HOWTO | City Heating (Stadswarmte) usage calculation

Moderator: leecollings

Post Reply
dervogt
Posts: 26
Joined: Thursday 30 June 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Amsterdam
Contact:

HOWTO | City Heating (Stadswarmte) usage calculation

Post by dervogt »

Hello to all,

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&param=updateuservariable&vname=valvecount&vtype=2&vvalue='..ValveCount})
                  message0 = ('Uservariable valvecount updated')
                  print (message0)
                  
                end   
Modification two:

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&param=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
Then deploy the following script in you scripts directory or events editor, Setting: LUA, Time based script:

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
I understand that there will be way more sophisticated and accurate methods to capture your city heating consumption, but for me this is accurate enough and I prefer overcounting in Domoticz then my heatmeter does this. This way I got a nice rough estimate of my energy bill and can better assess my efforts of further conserving energy in our apartment. Also, this way I can be pretty sure that if my ernegy bill gives more consumption than this counter, there is something wrong with the way they measured my consumption.

SUggestions for improvements are welcome, specifically I am not yet happy with the way I log the data in Domoticz...
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest