Posts: 238
	Threads: 66
	Joined: May 2018
	
Reputation: 
4
	 
	
	
		I think I have one of those.. we'll talk tomorrow ?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 8413
	Threads: 45
	Joined: Jun 2015
	
Reputation: 
481
	 
	
	
		Why not use Trends for this?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 238
	Threads: 66
	Joined: May 2018
	
Reputation: 
4
	 
	
	
		I agree with Admin, a nice trendview would give you what you need.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 67
	Threads: 16
	Joined: Feb 2018
	
Reputation: 
2
	 
	
	
		Uhm.. Because I want it as a value in my other user interface. :|
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 67
	Threads: 16
	Joined: Feb 2018
	
Reputation: 
2
	 
	
	
		I couldn't understand how to transform that to a script that could be useful, so I googled lua average value and found this in another thread:
-- storage key
key = 'temp_average'
-- time between average value send (in seconds)
maxtime = 60 * 60 
-- resulting average value
result = '4/3/34'
time = os.time()
data = storage.get(key)
if not data then
  data = { values = {}, time = time }
end
value = event.getvalue()
table.insert(data.values, value)
delta = time - data.time
if delta >= maxtime or delta < 0 then
  storage.delete(key)
  avg = 0
  count = #data.values
  for _, value in ipairs(data.values) do
    avg = avg + value
  end
  grp.write(result, avg / count)
else
  storage.set(key, data)
end
Is there a way to make this start the count at the beginning of the clock hour?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 167
	Threads: 20
	Joined: Apr 2017
	
Reputation: 
2
	 
	
	
		you can use 'Scheduled' en put the scipt there.
Set running for every hour at 00 minutes