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.

Trend Data
#4
After running this for a few days I've noticed that the data that is retrieved is NOT what I'm expecting.

The data does not match the data displayed in the inbuilt trends charts.  Here's the script I'm using to retrieve trend data for the last 3 hours

Code:
<?
require('trends')

local daterange = {}
daterange['end'] = os.time()
daterange['start'] = os.time() - (300 * 12 * 3)  -- 5 mins x 12 mins per hour x 3 hours

local trenddata = {}
trenddata = trends.fetch('Office Rack Temperature', daterange, 3600, true)

local datatable = {}
for index, value in pairs(trenddata) do
  datatable[index] = '{"x":' .. os.date('%d %m %Y %H:%M',value[1]) .. ',"y":' .. value[2] .. '}'
end

write("[[" .. table.concat(datatable, ",") .. "]]")
?>

Here is the data that the script retrieves

Code:
[[{"x":25 06 2024 09:25,"y":19.75},{"x":25 06 2024 09:30,"y":19.75},{"x":25 06 2024 09:35,"y":19.75},{"x":25 06 2024 09:40,"y":19.75},{"x":25 06 2024 09:45,"y":19.75},{"x":25 06 2024 09:50,"y":19.75},{"x":25 06 2024 09:55,"y":19.75},{"x":25 06 2024 10:00,"y":19.75},{"x":25 06 2024 10:05,"y":19.42},{"x":25 06 2024 10:10,"y":19.33},{"x":25 06 2024 10:15,"y":19.27},{"x":25 06 2024 10:20,"y":19.27},{"x":25 06 2024 10:25,"y":19.23},{"x":25 06 2024 10:30,"y":19.17},{"x":25 06 2024 10:35,"y":19.17},{"x":25 06 2024 10:40,"y":19.17},{"x":25 06 2024 10:45,"y":19.17},{"x":25 06 2024 10:50,"y":19.17},{"x":25 06 2024 10:55,"y":18.91},{"x":25 06 2024 11:00,"y":18.85},{"x":25 06 2024 11:05,"y":18.79},{"x":25 06 2024 11:10,"y":18.71},{"x":25 06 2024 11:15,"y":18.71},{"x":25 06 2024 11:20,"y":18.71},{"x":25 06 2024 11:25,"y":18.67},{"x":25 06 2024 11:30,"y":18.6},{"x":25 06 2024 11:35,"y":18.6},{"x":25 06 2024 11:40,"y":18.6},{"x":25 06 2024 11:45,"y":18.6},{"x":25 06 2024 11:50,"y":18.6},{"x":25 06 2024 11:55,"y":18.38},{"x":25 06 2024 12:00,"y":18.33},{"x":25 06 2024 12:05,"y":18.3},{"x":25 06 2024 12:10,"y":18.26},{"x":25 06 2024 12:15,"y":18.26},{"x":25 06 2024 12:20,"y":18.26}]]

Here is a snapshot of the actual data from the trends module

Code:
25/6/2024 9:25,18.44
25/6/2024 9:30,18.82
25/6/2024 9:35,18.82
25/6/2024 9:40,18.82
25/6/2024 9:45,18.82
25/6/2024 9:50,18.82
25/6/2024 9:55,18.82
25/6/2024 10:00,19.04
25/6/2024 10:05,19.37
25/6/2024 10:10,19.37
25/6/2024 10:15,19.37
25/6/2024 10:20,19.37
25/6/2024 10:25,19.37
25/6/2024 10:30,19.64
25/6/2024 10:35,19.64
25/6/2024 10:40,19.64
25/6/2024 10:45,19.64
25/6/2024 10:50,19.64
25/6/2024 10:55,20.4
25/6/2024 11:00,22.5
25/6/2024 11:05,26.23
25/6/2024 11:10,29.38
25/6/2024 11:15,30.3
25/6/2024 11:20,30.3
25/6/2024 11:25,30.3
25/6/2024 11:30,30.3
25/6/2024 11:35,30.3
25/6/2024 11:40,30.3
25/6/2024 11:45,30.3
25/6/2024 11:50,30.3
25/6/2024 11:55,30.3
25/6/2024 12:00,30.3
25/6/2024 12:05,30.3
25/6/2024 12:10,30.3
25/6/2024 12:15,30.3
25/6/2024 12:20,30.3
25/6/2024 12:25,30.3

 Can you see where this is going wrong?  Am I calling trends.fetch correctly?

Many thanks in advance

Kind Regards,
James
Reply


Messages In This Thread
Trend Data - by jamesng - 20.06.2024, 13:16
RE: Trend Data - by admin - 20.06.2024, 13:22
RE: Trend Data - by jamesng - 21.06.2024, 09:59
RE: Trend Data - by jamesng - 25.06.2024, 02:53
RE: Trend Data - by admin - 25.06.2024, 06:52
RE: Trend Data - by jamesng - 25.06.2024, 07:19
RE: Trend Data - by admin - 25.06.2024, 07:32
RE: Trend Data - by jamesng - 25.06.2024, 07:57

Forum Jump: