Page 1 of 1
Total value from P1 Gas to custom sensor
Posted: Tuesday 28 May 2019 20:15
by Knibor
Hi,
Is it possible to convert the value from P1 Gas "total counter" with value 21.558 to a virtual "General Custom"
Re: Total value from P1 Gas to custom sensor
Posted: Tuesday 28 May 2019 21:30
by Gravityz
modified the p1 meter script for gas
Code: Select all
local fetchIntervalMins = 1 -- (Integer) Minutes frequence of this script execution 1 = every minute, 10 = every 10 minutes, etc ) must be one of (1,2,3,4,5,6,10,12,15,20,30)
local ScriptVersion = '0.1.0'
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
logging = {
-- level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
},
execute = function(domoticz, item)
-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local P1data = 282 -- Gas, P1 Smart Meter device
local idxu1 = 290 -- Virtual gas meter device
-- Get values from device P1Data of the Smart Meter
local SMdata = domoticz.devices(P1data)
local function updateCounter(idx,value)
domoticz.devices(idx).updateGas(value)
end
updateCounter(idxu1,SMdata.counter)
end
}
Re: Total value from P1 Gas to custom sensor
Posted: Tuesday 28 May 2019 21:44
by waaren
Knibor wrote: Tuesday 28 May 2019 20:15
Hi,
@
Is it possible to convert the value from P1 Gas "
total counter" with value 21.558 to a virtual "General Custom"
Sure but if I take the label literally and you only need the usage of the current year then you need to keep track of the usage of previous years which complicates it a bit (not much because you would have the script store that value in a domoticz variable).
Without that added complexity it could look as short as this.
Code: Select all
return {
on = { timer = {'at *:19'}, -- at least once / hour at a quiet moment
devices = {'Gas verbruik dit jaar'}}, -- and when the meter got updated
execute = function( dz )
local totalGas = dz.devices('Totaal Gasverbruik dit jaar')
local gas = dz.devices('Gas verbruik dit jaar')
totalGas.updateCustomSensor(gas.counter)
end
}
@Gravityz , question was about updating a custom sensor. The method updateGas does not exist for such a sensor.
Re: Total value from P1 Gas to custom sensor
Posted: Tuesday 28 May 2019 21:53
by Gravityz
@waaren, clear. only looked at the icon

Re: Total value from P1 Gas to custom sensor
Posted: Thursday 30 May 2019 9:07
by Knibor
Hi, thanks for the script gentlemen, the last script works perfectly now.