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 export
#10
This logging works perfect.

1. If I would like to do the same but with hours, or days to make the csv. Could you help me with this?

2. I see that there is a bug in the trend viewer. When using the trend viewer to look at days I can se that for instance 8 of oktober, is the 9 of oktober in the monts vierw of the trend

3. Is there an easy to use accumulate function? In my case I got a lot of readings of energy and water, I would like to have a function that uses the trend files once an hour to add last hour value. This is to get a accumulated energy value for many months. Like I start this at 15.00. I use 500 watts in an hour. At 16.00 i would like to add 500 to group adress  x\x\x so that new value is 500. say if i turn down the demand and only use 200watt in an hour. at 17.00 i would like to add 200 to x\x\x and make it 700. and so on...

4. Underneath is my logging by hours I use at the moment.
This produces a csv file that looks like
"Tid(Time)"    "Aktiv effekt L1(Power usage L1)"
"10.okt 10.00"   "500"
"11.okt 11.00"   "400"


and so on for the last 24 hours
If I want to impement another trends values is that possible?
Like
"Tid(Time)"    "Aktiv effekt L1(Power usage L1)" "Aktiv effekt L2(Power usage L2)" "Aktiv effekt L2(Power usage L2)"
"10.okt 10.00"   "500"  "400"  "200"

"11.okt 11.00"   "400"  "500"  "250"



time = os.time()

date = {
  stime = time - 86400,
  etime = time,
}

values = trends.fetch('aktiv effekt L1', 'hour', date)

buffer = {}

count = 0
average = 0
resolution = 60 -- in minutes

row = string.format('%q,%q', "Tid", "aktiv L1")
  table.insert(buffer, row)

for _, data in ipairs(values) do
  count = count + 1
  average = average + data[ 2 ]
  if count == resolution then
    date = os.date('%d.%b %H:%M', time -86400)
    value = average / resolution
    row = string.format('%q,%q', date, value)
    
    table.insert(buffer, row)

    time = time + 60 * resolution

    count = 0
    average = 0
  end
 
end
     
if #buffer > 0 then
  data = table.concat(buffer, '\n\r')
  res, err = socket.ftp.put({
xxxxxx
x
xxxx


Thanks for an helping hand
Reply


Messages In This Thread
Trend export - by PassivPluss - 22.09.2015, 21:11
RE: Trend export - by admin - 23.09.2015, 06:44
RE: Trend export - by PassivPluss - 23.09.2015, 07:53
RE: Trend export - by PassivPluss - 01.10.2015, 19:33
RE: Trend export - by admin - 02.10.2015, 06:57
RE: Trend export - by PassivPluss - 16.10.2015, 07:35
RE: Trend export - by admin - 16.10.2015, 08:44
RE: Trend export - by PassivPluss - 16.10.2015, 10:20
RE: Trend export - by admin - 16.10.2015, 10:52
RE: Trend export - by PassivPluss - 29.10.2015, 22:51
RE: Trend export - by Erwin van der Zwart - 02.11.2015, 07:28
RE: Trend export - by PassivPluss - 02.11.2015, 19:24

Forum Jump: