Posts: 212
Threads: 61
Joined: May 2018
Reputation:
4
I think I have one of those.. we'll talk tomorrow ?
Posts: 7741
Threads: 42
Joined: Jun 2015
Reputation:
446
Why not use Trends for this?
Posts: 212
Threads: 61
Joined: May 2018
Reputation:
4
I agree with Admin, a nice trendview would give you what you need.
Posts: 64
Threads: 14
Joined: Feb 2018
Reputation:
2
Uhm.. Because I want it as a value in my other user interface. :|
Posts: 64
Threads: 14
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