Is there any way to get the Max/Min Temp/Humidity/etc for the day without doing a script/virtual devices? Just curious if there is a direct way I'm missing to do this.
Thanks!
-Mike
Thanks!
-Mike
2590 fs2.Add "SELECT Avg(" 2610 fs2.Add DeviceField 2620 fs2.Add ") AS Rave, Min(" 2630 fs2.Add DeviceField 2640 fs2.Add ") AS Rmin, Max(" 2650 fs2.Add DeviceField 2660 fs2.Add ") AS Rmax FROM " 2670 fs2.Add dataTable 2680 If CDate(EndingDate) >= CDate(StartDate) Then 2690 fs2.Add " WHERE " 2700 fs2.Add DateFieldName 2710 fs2.Add " >=" 2720 fs2.Add Pound 2730 fs2.Add StdDate(dStartDate) 2740 fs2.Add Pound 2750 fs2.Add " AND " 2760 fs2.Add DateFieldName 2770 fs2.Add " < " 2780 fs2.Add Pound 2790 fs2.Add StdDate(CDate(queryEndDate)) 2800 fs2.Add Pound 2860 If Not UseSQL Then 2870 fs2.Add " AND (not isNull(" 2880 fs2.Add DeviceField 2890 fs2.Add "))" 2900 If device_type = iDiscreteType Then 2910 fs2.Add " AND (not isNUll(Duration))" 2920 End If 2930 End If End if 3010 SQL = fs2.Value 80 Set objConn = CreateObject("ADODB.Connection") 90 objConn.Open DBProvider & gTemperatureDatabase 3030 Set rst = objConn.Execute(SQL)
Event : ComputeStatistics("[1;V1;V2;V3") Sub ComputeStatistics(DC) const GLOBALVAR = "MinMaxAve" const WEIGHT = .95 const SENSOR_DC = 0 const MIN_DC = 1 const MAX_DC = 2 const AVE_DC = 3 'get the 4 device codes passed arrDC = split(DC,";") 'get the current sensor reading SensorValue = hs.DeviceString(arrDC(SENSOR_DC)) 'Moving Average PriorAverage = hs.DeviceString(arrDC(AVE_DC)) hs.SetDeviceString arrDC(AVE_DC), PriorAverage * WEIGHT + (1-WEIGHT) * SensorValue 'Min if hs.DeviceString(arrDC(MIN_DC)) < SensorValue then hs.SetDeviceString(arrDC(MIN_DC)) = SensorValue end if 'Max if hs.DeviceString(arrDC(MAX_DC)) > SensorValue then hs.SetDeviceString(arrDC(MAX_DC)) = SensorValue end if 'reset min & max at start of new day if not isNumeric(hs.GetVar(GLOBALVAR)) then hs.CreateVar GLOBALVAR hs.SaveVar GLOBALVAR,day(now) else if day(now) <> hs.GetVar(GLOBALVAR) then hs.SaveVar GLOBALVAR, day(now) hs.SetDeviceString arrDC(MIN_DC), SensorValue hs.SetDeviceString arrDC(MAX_DC), SensorValue End if end if end sub
Comment