Gets gas consumption from the electrical energy of the gas boiler

Moderator: leecollings

Post Reply
pfloryann
Posts: 203
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
}
I hope it helps you too.
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: 737
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.
Post Reply

Who is online

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