Page 1 of 1

Update daily gas usage

Posted: Wednesday 31 October 2018 18:47
by Joep123
I use script below to update a custom sensor to monitor my daily gas usage based on degree days. It works fine.
Actually I want to use a gas sensor (or a RFX sensor). I tried to update these sensors with

Code: Select all

domoticz.devices('Gas per graaddag').updateGas(GasUsageperDegreesday)
but then the gas counter will be updated in stead of the daily usage.

Can anyone help me to update the daily usage?

Code: Select all

return {
          on   = { timer    = { "at 23:58"}},

  execute = function(domoticz)
        local Date = domoticz.time.year..domoticz.time.month..domoticz.time.day
        local meantempOutside = domoticz.devices('Gemiddelde Temp buiten').temperature
        local baseTemp = 18
        local factor = 1
        local degreesday = baseTemp - meantempOutside
        if (domoticz.time.month >= 4 and domoticz.time.month <= 9) then factor = 0.8 end
        if (domoticz.time.month >= 11 or domoticz.time.month <= 2) then factor = 1.1 end
        degreesdays = degreesday * factor
        local GasUsage = domoticz.devices('Gas').counterToday
        local GasUsageperDegreesday = domoticz.round((GasUsage / degreesdays),3)
        if (degreesday <= 0) then 
            degreesdays = 0 
            GasUsageperDegreesday = 0
        end
        domoticz.log('Gemiddelde temperatuur buiten (laatste 24u): '..meantempOutside)
        domoticz.log('Gasverbruik vandaag: '..GasUsage..' m3')
        domoticz.log('Aantal graaddagen: '..degreesdays)
        domoticz.log('Gasverbruik: '..GasUsageperDegreesday..' m3 per graaddag')
        
        domoticz.devices('Gas per graaddag').updateCustomSensor(GasUsageperDegreesday)

  end
}

Re: Update daily gas usage

Posted: Wednesday 31 October 2018 23:55
by waaren
Joep123 wrote: Wednesday 31 October 2018 18:47 I use script below to update a custom sensor to monitor my daily gas usage based on degree days. It works fine.
Actually I want to use a gas sensor (or a RFX sensor). I tried to update these sensors with

Code: Select all

domoticz.devices('Gas per graaddag').updateGas(GasUsageperDegreesday)
but then the gas counter will be updated in stead of the daily usage.
Can anyone help me to update the daily usage?
@Joep123, the daily usage of a domoticz gas sensor is a calculated value. In the database only the total is stored and domoticz "knows" the total amount at 0:00 (from another table)

select ID,Name,sValue from deviceStatus where id = 36;
ID|Name|sValue
36|Gas|2113123

select * from meter_calendar where deviceRowid=36 and Date=date("now","-1 day") ;
DeviceRowID|Value|Counter|Date
36|3427|2109548|2018-10-30

2113123
2109548 -
3575
Gas meter (36)
Gas meter (36)
gas.png (24.65 KiB) Viewed 1419 times
So trying to store GasUsageperDegreesday in a gas sensor device is not going to give you the information you want to see.

Re: Update daily gas usage

Posted: Thursday 01 November 2018 7:25
by Joep123
Thanks for your clear post Waaren.

I guess a RFX Meter (type gas) will be the same?
I'm looking for a nice way the store GasUsageperDegreesday into a chart (like gas, energy).

Re: Update daily gas usage

Posted: Friday 09 November 2018 9:40
by hendrikenrenny
Hi,

The script is running perfectly and everyday I get the m3/graaddag. I used the script on ehoco.nl.

However, the dummy sensor m3/graaddag doesnot generate a report as you can see with every sensor (eg electricity), where it is reported per day/month the m3/graaddag.

Does anybody know how-to do that?

Second question: the sensor does produce a graph, but it is a line graph where I would prefer a bar. Do you have suggestions how to change that?

Thanks,