Announcement

Collapse
No announcement yet.

Windspeed Between Query

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

    Windspeed Between Query

    Hi All,

    Hopefully someone can point me in the right direction, since i am drawing a mental blank, Basically i have a weather station on my roof and want to tweet every 3 or 4 hours what the current windspeed & direction is, and then correspond this Beaufort Wind Scale

    I can use my.Trigger to set an event to trigger when it is between X and Y which would be perfect for what i want to do, so i would create 5 or 10 events, each with different ranges, and they would just tweet the appropriate information.

    The issue with that approach is that whenever the weather hits one of those thresholds it would begin tweeting like crazy, which is not what i want, since i only want it done once every hour or two or three.

    Does anyone have any suggestions or pointers they could give me?

    Thanks
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

    #2
    I think i got the idea, but keep getting an error in my script, can anyone give me a tip as to what i have done wrong?

    Code:
    Select Case CStr(hs.DeviceValue("X30")/10)
    
    Case 0 to 1
    hs.Plugin("TwittSeer").Tweet("Wind: CALM in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 1.1 to 5
    hs.Plugin("TwittSeer").Tweet("Wind: LIGHT AIR in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 6 to 11
    hs.Plugin("TwittSeer").Tweet("Wind: LIGHT BREEZE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 12 to 19
    hs.Plugin("TwittSeer").Tweet("Wind: GENTLE BREEZE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 20 to 28
    hs.Plugin("TwittSeer").Tweet("Wind: MODERATE BREEZE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 29 to 38
    hs.Plugin("TwittSeer").Tweet("Wind: FRESH BREEZE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 39 to 49
    hs.Plugin("TwittSeer").Tweet("Wind: STRONG BREEZE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 50 to 61
    hs.Plugin("TwittSeer").Tweet("Wind: MODERATE OR NEAR GALE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 62 to 74
    hs.Plugin("TwittSeer").Tweet("Wind: GALE OR FRESH GALE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 75 to 88
    hs.Plugin("TwittSeer").Tweet("Wind: STRONG GALE in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 89 to 102
    hs.Plugin("TwittSeer").Tweet("Wind: WHOLE GALE OR STORM in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 103 to 117
    hs.Plugin("TwittSeer").Tweet("Wind: VIOLENT STORM in Pakenham @ EXPR(DV(X30)/100) km / hr; Beaufort Number: EXPR(DV(X37)/100)")
    Case 118 to 153
    hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 1 in Pakenham @ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 1")
    Case 154 to 177
    hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 2 in Pakenham @ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 2")
    Case 178 to 209
    hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 3 in Pakenham @ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 3")
    Case 210 to 249
    hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 4 in Pakenham @ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 4")
    Case 250 to 1000
    hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 5 in Pakenham @ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 5")
    Case Else
    End Select
    I get the following error:

    Script compile error: Statement cannot appear outside of a method body.on line 14
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

    Comment


      #3
      Although I would expect a different error (perhaps something like type mismatch) this line looks wrong to me;

      Select Case CStr(hs.DeviceValue("X30")/10)

      it would be fine if you were comparing strings but you are looking at decimals/doubles. Perhaps replacing CStr with CDec or CDbl may work.

      Comment


        #4
        Originally posted by mrhappy View Post
        Although I would expect a different error (perhaps something like type mismatch) this line looks wrong to me;

        Select Case CStr(hs.DeviceValue("X30")/10)

        it would be fine if you were comparing strings but you are looking at decimals/doubles. Perhaps replacing CStr with CDec or CDbl may work.
        That makes sense, i did give both a go and got errors still
        HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

        Facebook | Twitter | Flickr | Google+ | Website | YouTube

        Comment


          #5
          [solved]

          Works well with your suggestion, had to tinker a bit but came up with this at the end which seems to work fine.

          Code:
          Sub main(params as object)
          
          Select Case cDBL((hs.DeviceValue("X30")/100))
          
          Case 0 to 1
          hs.Plugin("TwittSeer").Tweet("Wind: CALM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 0")
          hs.Writelog("Cumulus - Wind", "Wind: CALM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 0") 
          Case 1.1 to 5
          hs.Plugin("TwittSeer").Tweet("Wind: LIGHT AIR in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 1") 
          hs.Writelog("Cumulus - Wind","Wind: LIGHT AIR in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 1") 
          Case 6 to 11
          hs.Plugin("TwittSeer").Tweet("Wind: LIGHT BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 2") 
          hs.Writelog("Cumulus - Wind","Wind: LIGHT BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 2")  
          Case 12 to 19
          hs.Plugin("TwittSeer").Tweet("Wind: GENTLE BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number:  3")
          hs.Writelog("Cumulus - Wind","Wind: GENTLE BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 3")  
          Case 20 to 28
          hs.Plugin("TwittSeer").Tweet("Wind: MODERATE BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 4") 
          hs.Writelog("Cumulus - Wind","Wind: MODERATE BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 4") 
          Case 29 to 38
          hs.Plugin("TwittSeer").Tweet("Wind: FRESH BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 5") 
          hs.Writelog("Cumulus - Wind","Wind: FRESH BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 5")  
          Case 39 to 49
          hs.Plugin("TwittSeer").Tweet("Wind: STRONG BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 6") 
          hs.Writelog("Cumulus - Wind","Wind: STRONG BREEZE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 6")  
          Case 50 to 61
          hs.Plugin("TwittSeer").Tweet("Wind: MODERATE OR NEAR GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 7") 
          hs.Writelog("Cumulus - Wind","Wind: MODERATE OR NEAR GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 7")  
          Case 62 to 74
          hs.Plugin("TwittSeer").Tweet("Wind: GALE OR FRESH GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 8") 
          hs.Writelog("Cumulus - Wind","Wind: GALE OR FRESH GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 8")  
          Case 75 to 88
          hs.Plugin("TwittSeer").Tweet("Wind: STRONG GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 9") 
          hs.Writelog("Cumulus - Wind","Wind: STRONG GALE in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 9")  
          Case 89 to 102
          hs.Plugin("TwittSeer").Tweet("Wind: WHOLE GALE OR STORM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 10 - CAUTION") 
          hs.Writelog("Cumulus - Wind","Wind: WHOLE GALE OR STORM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 10")  
          Case 103 to 117
          hs.Plugin("TwittSeer").Tweet("Wind: VIOLENT STORM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 11 - CAUTION") 
          hs.Writelog("Cumulus - Wind","Wind: VIOLENT STORM in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Beaufort Number: 11")  
          Case 118 to 153
          hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 1 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 1")
          hs.Writelog("Cumulus - Wind","Wind: HURRICANE - CAT 1 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 1") 
          Case 154 to 177
          hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 2 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 2")
          hs.Writelog("Cumulus - Wind","Wind: HURRICANE - CAT 2 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 2") 
          Case 178 to 209
          hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 3 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 3")
          hs.Writelog("Cumulus - Wind","Wind: HURRICANE - CAT 3 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 3")
          Case 210 to 249
          hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 4 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 4")
          hs.Writelog("Cumulus - Wind","Wind: HURRICANE - CAT 4 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 4") 
          Case 250 to 1000
          hs.Plugin("TwittSeer").Tweet("Wind: HURRICANE - CAT 5 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 5")
          hs.Writelog("Cumulus - Wind","Wind: HURRICANE - CAT 5 in Pakenham @ ~ EXPR(DV(X30)/100) km / hr; Saffir-Simpson Hurricane Scale: 5") 
          Case Else
          hs.Writelog("Cumulus - Wind","Error determining Wind Category") 
          End Select
          End Sub
          HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

          Facebook | Twitter | Flickr | Google+ | Website | YouTube

          Comment

          Working...
          X