Announcement

Collapse
No announcement yet.

Max/Min Temp / Humidity,etc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Max/Min Temp / Humidity,etc

    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

    #2
    These are displayed in the table format on the temperature asp page. I generate the data for the page from the database with the following sequence. If you want to script something to do it on the fly then you can use this for some ideas.

    Code:
    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)

    Comment


      #3
      Originally posted by Michael McSharry
      These are displayed in the table format on the temperature asp page. I generate the data for the page from the database with the following sequence. If you want to script something to do it on the fly then you can use this for some ideas.
      Michael can you please go into more detail on this response? I am also looking for min/max daily for each zone, and although I am familiar with scripting I'm not sure what to do with the code you posted. Thanks!


      ***EDIT- Sorry about the possibly pre-mature post. After looking down a few more threads I see that this has been discussed. I will continue researching....


      ***EDIT#2- I am not using the charts and their associated pages because I am using mainlobby for my gui, so what is the easiest way to track min/max? The post below was related to groups on the charts. Thx
      Last edited by JPlatt50; March 22, 2006, 05:11 PM.

      Comment


        #4
        Krumpy's interface to ML requires you to have Homeseer devices populated with what is to be shown on ML. It does not support a dynamic interface. This means you will need to define 3 virtual devices for each sensor you want to shown on ML and then run a periodic event with a script that will populate these devices. The event rate should be about the same as the update rate of the sensor.

        In this situation you need to decide if you are going to use a moving average for the "average" or are going to do an mean over a specific period of time. If you do a mean calculation then the database is going to be your easiest source since you will need to have access to all the data over the period of interest. If you are going to do a moving average then the info in the virtual device will be sufficient.

        The example below shows a script that is called from a periodic event with the input parameters being the HS devices that contain the information of interest. If your have your sensor in the DeviceValue or if you have the DeviceString with HTML encoding then you will need to make the appropriate change to get the SensorValue to be used. With the moving average you define the weight to determine your preference for previous vs current. I set it up so each sample represent 5% of the average. I set it up for daily statistics. If you want weekly then just change the reset criteria at the end of the script.

        Code:
        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

        Working...
        X