Hotwater gas usage

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Hotwater gas usage

Post by edwin1234 »

A forum member pointed me at this script from warren:
But its for power and i want it for hotwater gas usage i have a device warmwater on/off switch and want to see the hotwater gas usage seperatly from the total gas usage. Is it possible somehow?
Or with a different script?
I tried to change the script but cant get it together.
My hotwater device is called “Warmwater”
And Gasdevice is called “GasVerbruik” (measured with rfxcom)

return
{
on =
{
timer =
{
'every minute',
},
},

data =
{
usage = { initial = 0 },
},

logging =
{
level = domoticz.LOG_DEBUG,
marker = "WarmwaterVerbruik"
},

execute = function(dz)
--- Changes below this line
local houseActive = dz.devices('Warmwater').state == 'On' -- change to name of your state switch
local power = dz.devices('GasVerbruik') -- change to name of your P1 meter
local usage = power.usage1 + power.usage2
local housemeter = dz.devices('GasTotaal') -- define as counter inremental
local boilermeter = dz.devices('GasWarmwater') -- define as counter inremental
-- No changes below this line

if houseActive and dz.data.usage ~= 0 then
housemeter.incrementCounter(usage - dz.data.usage)
dz.log('usage ' .. housemeter.name ..': ' .. (usage - dz.data.usage),dz.log_DEBUG)
boilermeter.incrementCounter(0)

elseif dz.data.usage ~= 0 then
boilermeter.incrementCounter(usage - dz.data.usage)
dz.log('usage ' .. boilermeter.name ..': ' .. (usage - dz.data.usage),dz.log_DEBUG)
housemeter.incrementCounter(0)
end

dz.data.usage = usage
end
}
Last edited by edwin1234 on Wednesday 29 December 2021 7:37, edited 1 time in total.
Joep123
Posts: 56
Joined: Monday 26 March 2018 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Hotwater gas usage

Post by Joep123 »

I don't know what kind of devices you have but I think it's impossible.
My P1 meter doesn't send gas readings every single minute.
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Hotwater gas usage

Post by edwin1234 »

Its not a smart gas meter, its a normal one with a sensor on it and read out by rfxmeter from rfxcom
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Hotwater gas usage

Post by edwin1234 »

No one an idea?
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Hotwater gas usage

Post by kiddigital »

So you have a (P1?) gas meter which measures total gas consumption every interval. With the difference in the total usage and 2 measuring timestamps you can calculate the total gas consumption in that period.

Also you have a ‘hot water’ on/off (virtual?) switch so you can see when hot water is being used and when not. Making it possible to determine the time windows when hot water was used.

With these 2 time windows (gas consumption and hot water usage) you could determine what percentage of the gas consumption windows was during one or more hot water consumption periods and calculate that back to the amount of gas consumed during each hot water usage period.

This is far from accurate as there are many factors not being addressed, but very roughly it gives a bit of an idea.

I would probably start with a (Python or dzVents) script that runs every time a new gas consumption reading comes in (so you have the old and new value) and see if 1 or more hot water consumption windows have occurred in the mean time. Don’t forget to process the last ‘open window’ from the previous measurement if any.

And store the calculated gas consumption for each hot water consumption window in a virtual/dummy sensor.

Have fun trying to build it and please share you results
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest