Gets gas consumption from the electrical energy of the gas boiler

Moderator: leecollings

Post Reply
pfloryann
Posts: 204
Joined: Wednesday 09 January 2019 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.2
Location: BlooeSky
Contact:

Gets gas consumption from the electrical energy of the gas boiler

Post 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
}
LE: in my case only the gas boiler using gas.

I hope it helps you too.
Last edited by pfloryann on Monday 23 February 2026 10:20, edited 1 time in total.
Domoticz on Raspberry Pi 4 Debian 13 x64
Zigbee2mqtt and zigbee devices (Xiaomi, Ikea,Tuya, Philips, Osram), Broadlink, Solar power Victron Energy, Yeelight, Xiaomi Purifier Pro, Roborock S5
kimot
Posts: 113
Joined: Saturday 25 November 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

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

Post 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.
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
willemd
Posts: 738
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

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

Post 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.
pfloryann
Posts: 204
Joined: Wednesday 09 January 2019 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.2
Location: BlooeSky
Contact:

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

Post by pfloryann »

I said an estimated consumption, not precise, but for me it is useful even if the value is +/- compared to the real value, but not by much. I use for this a php function that monitors the consumption of the Viessman Vitodens W100 boiler (when its consumption exceeds 10w, in standby it consumes 3.5w) using a zigbee socket. I tried to reproduce this function in domoticz maybe there are people who would like to use it. I know it is possible with a p1, but the gas meter at the gas distributor is a classic one, not digital and that is why I tried to obtain at least an estimated consumption this way. In my case only the gas boiler using gas.
Domoticz on Raspberry Pi 4 Debian 13 x64
Zigbee2mqtt and zigbee devices (Xiaomi, Ikea,Tuya, Philips, Osram), Broadlink, Solar power Victron Energy, Yeelight, Xiaomi Purifier Pro, Roborock S5
willemd
Posts: 738
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

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

Post by willemd »

If you want to make it more accurate, you could take into account that the pump normally keeps on running for some time (often 1 minute) after the heating has stopped.

If this is after a 5 minute heating period (and if you assume the pump is the main electricity consumer) then this has a different effect of course then after a 20 minute or longer heating period.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest