No announcement yet.

Minimum maximum script not working with negative temps

  • Filter
  • Time
  • Show
Clear All
new posts

  • Minimum maximum script not working with negative temps

    I have this script to determine minimum and maximum temperatures for the day. So far its been working fine, but now the temperatures dropped below 0 I have an issue. Going below 0, the minimum shows correctly, but when its going up again the lowest minimum goes up (and obviously it shouldn't). So as an example, the lowest temperature on my weather_temp was -2.5 degrees, and it showed that as minimum. Then the temperature did go up to -1.9 degrees, and the minimum value changed from -2.5 to -1.9 which should not happen.
    This is the script I am using:

    Sub Main(ByVal parms as Object)
     Dim out_temp = hs.devicevalueEx(14)
     Dim min_out = hs.devicevalueEx(768)
     Dim max_out = hs.devicevalueEx(767)
     Dim weather_temp = hs.devicevalueEx(19)
     Dim min_weather = hs.devicevalueEx(769)
     Dim max_weather = hs.devicevalueEx(770)
     Dim garage_temp = hs.devicevalueEx(15)
     Dim min_garage = hs.devicevalueEx(771)
     Dim max_garage = hs.devicevalueEx(772)
     If out_temp < min_out
      hs.setdevicevaluebyref(768, out_temp, true)
      hs.setdevicestring(768, out_temp, true)
     End If
     If out_temp > max_out
      hs.setdevicevaluebyref(767, out_temp, true)
      hs.setdevicestring(767, out_temp, true)
     End If
      If weather_temp < min_out
      hs.setdevicevaluebyref(769, weather_temp, true)
      hs.setdevicestring(769, weather_temp, true)
     End If
     If weather_temp > max_out
      hs.setdevicevaluebyref(770, weather_temp, true)
      hs.setdevicestring(770, weather_temp, true)
     End If
      If garage_temp < min_garage
      hs.setdevicevaluebyref(771, garage_temp, true)
      hs.setdevicestring(771, garage_temp, true)
     End If
     If garage_temp > max_garage
      hs.setdevicevaluebyref(772, garage_temp, true)
      hs.setdevicestring(772, garage_temp, true)
     End If
    End Sub
    Last edited by mikee123; January 18th, 2017, 05:09 AM.

  • #2
    I found the problem. I was using the wrong min_ and max_ variables... instead of min_weather I used min_out

    Tried to delete the post but it wouldn't let me, not sure why...