Page 1 of 1

Gets gas consumption from the electrical energy of the gas boiler

Posted: Saturday 21 February 2026 12:25
by pfloryann
Hi,
Below I will explain how I managed to obtain an approximate daily gas consumption by transforming the electrical energy consumed by the gas boiler.
The boiler is monitored by a smart plug and I created a custom sensor in domoticz that records daily gas consumption.

To be able to obtain an approximate gas consumption, you must first monitor the consumption on the gas meter for a day. Similarly, you monitor the energy consumption in Kw for that day.

Daily Gas consumption = Daily energy consumption of the gas boiler (in Kilowatt) x Multiplier

Calculate daily consumption smart plug (counterToday in domoticz) x Multiplier, for example in my case the multiplier value is 21 to obtain the approximate gas consumption, but you can also test with other values ​​until it gives the correct result.

Then create the following dzvents script:

Code: Select all

return {
active = true,
on = {
devices = { 139 } -- idx smart plug
},

execute = function(domoticz, device)
-----------------------------------------------------
-- CONFIGURATION
-----------------------------------------------------
local MULTIPLICATOR = 21 -- multiplier replace with your own value
local GAZ_IDX = 520 -- 🟢 replace with the idx of your sensor Custom Sensor "Estimated Gas Consumption"

--------------------------------------------------------------------
-- MAIN LOGIC
--------------------------------------------------------------------
local val = device.counterToday or 0
local consumKWh = 0

if type(val) == "string" then
consumKWh = tonumber(val:match("([%d%.]+)")) or 0
else
consumKWh = tonumber(val) or 0
end

local consumGaz = consumKWh * MULTIPLICATOR

local gazDevice = domoticz.devices(GAZ_IDX)
if gazDevice then
gazDevice.updateCustomSensor(consumGaz)
domoticz.log(string.format(
"idx[%d]: %.3f kWh → Gas estimated: %.3f m³ (x%.3f)",
device.id, consumKWh, consumGaz, MULTIPLICATOR
), domoticz.LOG_INFO)
else
domoticz.log(string.format("Error: we did not find the device with idx %d", GAZ_IDX), domoticz.LOG_ERROR)
end
end
}
I hope it helps you too.

Re: Gets gas consumption from the electrical energy of the gas boiler

Posted: Saturday 21 February 2026 20:20
by kimot
I don't know much about gas boilers, but I highly doubt that the gas consumption for heating will have any direct relationship with the boiler's electricity consumption.
( electronics, power supply for some kind of burner servo drive )
But maybe if there is just an ON/OFF burner valve, it could be recalculated in your way.

Re: Gets gas consumption from the electrical energy of the gas boiler

Posted: Saturday 21 February 2026 20:30
by willemd
Monitoring for a day gives you very little data and high inaccuracy. Long terms regression analysis could show something .... or not, depending on the fact whether there is a relationship. My guess is that electricity usage is mainly caused by the waterpump, not related to the amount of gas, especially if you have a modulating gas heater.

You probably get more accurate results by multiplying gas usage by the average energy value of the gas used (9.8 for natural gas in NL), assuming you have a high efficiency boiler.

To get your gas m3 consumption in the first place you can use a P1 meter or a dedicated device, like Opentherm Gateway OTGW, depending on country/equipment. With OTGW you can get actually time the burner is active and multiply that with an avg flowrate. With p1 you can get actual m3 gas used.