This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Outside compensation curve
#9
(16.01.2025, 17:08)Erwin van der Zwart Wrote: For the outdoor temp combined with a curve i usually use a 3 days average, this can simply be done by attaching a trend to your measurement object and use this small script.

Code:
require('trends')
dateslastthreedays = {}
dateslastthreedays['start'] = os.date('*t', os.time() - (86400 * 4))
dateslastthreedays['end'] = os.date('*t', os.time() - (86400 * 1))
threedaysaverage = trends.fetchone('OUTDOOR TEMP', dateslastthreedays)

The only trend I have right now is outdoor temperature with a 5-min resolution.
I tried your script and can't really make it work.
I get incorrect values. I would rather like to use a span of the last 9 hours average temperature or so, not from four days agou until yesterday which i read your script.
I tried change 86400 * 4 to 86400 * 1 and the "end" to 86400 * 0, but that gives 0 as temperature. 

Any good suggestions?

Quote:require('trends')

-- Define time range for the timespan
local lastninehours = {}
lastninehours['start'] = os.date('*t', os.time() - (3600 * 9)) -- 9 hours back
lastninehours['end'] = os.date('*t', os.time()) -- Current time

-- Fetch the average temperature for the timespan
local ninehoursaverage = trends.fetchone('Utetemp', lastninehours)

-- Fetch the current temperature from KNX address 0/3/0
local currenttemperature = grp.getvalue('0/3/0') -- Assumes grp.getvalue function is used

if ninehoursaverage and currenttemperature then
    -- Calculate the highest value between the average temperature and the current temperature
    local highesttemperature = math.max(ninehoursaverage, currenttemperature)
   
    -- Send the highest value to KNX address 5/5/20
    grp.write('5/5/20', highesttemperature)
   
    -- Log both the average temperature and the temperature sent
    log("Average temperature for the last 9 hours: " .. tostring(ninehoursaverage))
    log("Temperature sent to 5/5/20: " .. tostring(highesttemperature))
else
    log("Could not fetch the average temperature or the current temperature.")
end
Reply


Messages In This Thread
Outside compensation curve - by oyvindnordbo - 04.12.2018, 07:13
RE: Outside compensation curve - by admin - 04.12.2018, 07:29
RE: Outside compensation curve - by admin - 04.12.2018, 09:20
RE: Outside compensation curve - by Daniel - 04.12.2018, 09:22
RE: Outside compensation curve - by merel - 04.12.2018, 13:45
RE: Outside compensation curve - by jerryhenke - 16.01.2025, 21:56
RE: Outside compensation curve - by admin - 17.01.2025, 08:18

Forum Jump: