Announcement

Collapse
No announcement yet.

hs.ping() does not work

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

  • hs.ping() does not work

    when running the below code I get this error

    Compiling script /usr/local/HomeSeer/scripts/Occupancy_Ping.cs: {interactive}(15,25): error CS1061: Type `Scheduler.hsapplication' does not contain a definition for `Ping' and no extension method `Ping' of type `Scheduler.hsapplication' could be found (are you missing a using directive or an assembly reference?)

    What could be the issue here? i have a more complicated script that doesn't use hs.Ping() and it works ok.


    Code:
    using System;
    
    object Main(object[] Parms) {
    
        Int32 Pingable = hs.Ping(Parms[0]);
        if ( Pingable == 1 ) {
            hs.CounterIncrement("OccupancyPing");
        } else {
            hs.CounterReset("OccupancyPing");
        }
        return 0;
    }

  • #2
    I use this vb.net script routinely and it works fine.
    Code:
        Public Sub Main(ByVal Parms As Object)
    
            Dim Google As String = "8.8.8.8"
            Dim intR As Integer
    
        intR = hs.Ping(Google)
    
        If intR = 0 Then 
             hs.WriteLog ("Internet", "OK")
        Else
             hs.WriteLog ("Internet", "??")
        End If
    
        End Sub
    What is the form of your 'Params[0]'? It needs to be a string containing the IP address of the site you want to check.
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.500

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      I'll try that, I'm starting to learn C# so don't want to confuse myself with VB.
      The Parms[0] is just the first array element that's passed from the parameters field on the event.

      I've previously used Parms[0].ToString() to the same results.

      Could it be possible that the Ping function isn't exposed properly to C#? I'll try your method when I get home.

      Comment


      • #4
        I would expect hs.ping(Parms[0].ToString) to work if Parms(0) is a valid IP address.
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.500

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

        Comment


        • #5
          It seems that hs.Ping() just doesn't work in C#, dumb.

          I did re-purpose your script, so thank you!

          Code:
          Public Sub Main(Optional ByVal Parms As String = "")
          
              Dim intR As Integer
              Integer intR = hs.Ping(Parms)
              hs.CounterReset("OccupancyPing")
              If intR = 0 Then
                  hs.CounterIncrement("OccupancyPing")
              Else
                  hs.CounterReset("OccupancyPing")
              End If
          
          End Sub
          Last edited by ACiDGRiM; July 12th, 2018, 09:11 PM.

          Comment

          Working...
          X