Announcement

Collapse
No announcement yet.

System.Diagnostics dll

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

    System.Diagnostics dll

    I'm having trouble running a script in homeseer that uses a List type. I'm not that good at programming. Anyone know how to fix this error I'm getting:

    Jun-26 4:03:30 PM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\GuiSettings2.vb: compiler initialization failed unexpectedly: The system cannot find the file specified.
    Jun-26 4:03:30 PM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\GuiSettings2.vb: could not find library 'System.Diagnostics.dll'

    #2
    Can you post your complete script? You may need to add a reference to that dll in your settings.ini file:

    Code:
    [settings]
    ScriptingReferences=System.Diagnostics;System.Diagnostics.dll
    although you may be able to just add the following to the beginning of your script:

    Code:
    Imports System.Diagnostics
    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Originally posted by sparkman View Post
      Can you post your complete script? You may need to add a reference to that dll in your settings.ini file:

      Code:
      [settings]
      ScriptingReferences=System.Diagnostics;System.Diagnostics.dll
      although you may be able to just add the following to the beginning of your script:

      Code:
      Imports System.Diagnostics
      Cheers
      Al

      I've tried putting them both in the settings file as references and also used the imports statements as noted below and I still can't get it to work. It appears I am having problems with the "Process" and "List" types.

      Imports System.Diagnostics
      Imports System.Collections

      Public Sub Main(ByVal strdvRef As String)

      Dim output As String
      Dim lines() As String
      Dim linesplit() As String
      Dim myTesla As New List(Of String)
      Dim newList As New List(Of String)
      Dim table As New Hashtable
      Dim checkKey As Boolean
      Dim tempfile As String = System.IO.Path.GetTempFileName
      Using Process As New Process
      Process.StartInfo = New ProcessStartInfo("C:\Users\Jay\AppData\Roaming\npm\teslacmd. cmd")
      Process.StartInfo.Arguments = "-u joy.krupp@gmail.com -p xxots -O 1 -c /c 1> """ + tempfile + """ 2>&1"
      Process.StartInfo.WorkingDirectory = "C:\Users\Jay\AppData\Roaming\npm\"
      Process.StartInfo.UseShellExecute = False
      Process.StartInfo.CreateNoWindow = True
      Process.Start()
      Process.WaitForExit()
      output = System.IO.File.ReadAllText(tempfile)
      lines = IO.File.ReadAllLines(tempfile)

      For Each line As String In lines

      myTesla.Add(line)
      Next

      '***Take out symobls and such from the response in text file
      For Each couple As String In myTesla
      couple = couple.Trim({","c, "{"c, "'"c, ":"c, ":"c})
      couple = Replace(couple, ":", " ")
      couple = Replace(couple, "'", " ").Trim
      linesplit = couple.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)

      '***Add values to a hashtable for easy retrieval
      table.Add(linesplit(0), linesplit(1))
      Next
      System.IO.File.Delete(tempfile)
      End Using

      '***Check if data was placed in right format
      checkKey = table.ContainsKey("charging_state")

      '***If so start giving homeseer some values and device strings
      If checkKey = True Then
      If table.Item("charge_port_door_open") = "true" Then
      hs.SetDeviceValueByRef(1344, 100, False)
      hs.SetDeviceString(1344, "Open", True)
      Else
      hs.SetDeviceValueByRef(1344, 0, False)
      hs.SetDeviceString(1344, "Closed", True)
      End If
      If table.Item("charging_state") = "Disconnected" Then
      hs.SetDeviceValueByRef(1096, 0, False)
      hs.SetDeviceString(1096, table.Item("charging_state"), False)
      Else
      hs.SetDeviceValueByRef(1096, 100, False)
      hs.SetDeviceString(1096, table.Item("charging_state"), False)
      End If

      '***Establish more homeseer values
      hs.SetDeviceValueByRef(1345, table.Item("charge_rate"), False)
      hs.SetDeviceString(1345, table.Item("charge_rate"), False)

      hs.SetDeviceValueByRef(1349, table.Item("charger_voltage"), False)
      hs.SetDeviceString(1349, table.Item("charger_voltage"), False)

      hs.SetDeviceValueByRef(1350, table.Item("battery_current"), False)
      hs.SetDeviceString(1350, table.Item("battery_current"), False)

      '***Error so send a push message
      Else
      hs.PluginFunction("Pushover 3P", "", "Pushscript", New Object() {"Me", "Error Reaching Jay's Car", output, Nothing, "falling", Nothing, Nothing, Nothing})
      hs.WriteLog("Tesla", output)
      End If

      End Sub

      Comment


        #4
        Make sure there's only one scriptingreferences line in the settings.ini file and make sure to restart HS after making a change to that. Is the error message still the same?

        Cheers
        Al
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #5
          Also, there may be a different way to accomplish what you need. It looks like you are trying to run an external command, capture its output, and then parse the output to look for specific items and update hs as needed. There's probably other ways to accomplish that. Can you post the output of the external command?

          Cheers
          Al
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            Originally posted by sparkman View Post
            Also, there may be a different way to accomplish what you need. It looks like you are trying to run an external command, capture its output, and then parse the output to look for specific items and update hs as needed. There's probably other ways to accomplish that. Can you post the output of the external command?

            Cheers
            Al
            Putting those references into the settings file put errors all over my log when I restarted homeseer. I put in both System.Diagnostics and System.Collections in the references section to no avail so I took them out:
            ScriptingReferences = System.xml;System.xml.dll,System.Diagnostics;System.Diagnost ics.dll,System.Collections;System.Collections.dll


            Here is the output of a cmd program that is underlying java based to get data for my car:

            { charging_state: 'Complete',
            charge_limit_soc: 90,
            charge_limit_soc_std: 90,
            charge_limit_soc_min: 50,
            charge_limit_soc_max: 100,
            charge_to_max_range: false,
            battery_heater_on: null,
            not_enough_power_to_heat: false,
            max_range_charge_counter: 0,
            fast_charger_present: false,
            fast_charger_type: '<invalid>',
            battery_range: 229.57,
            est_battery_range: 240.73,
            ideal_battery_range: 265.58,
            battery_level: 90,
            usable_battery_level: 90,
            battery_current: 0,
            charge_energy_added: 17.27,
            charge_miles_added_rated: 58.5,
            charge_miles_added_ideal: 67.5,
            charger_voltage: 0,
            charger_pilot_current: 40,
            charger_actual_current: 0,
            charger_power: 0,
            time_to_full_charge: 0,
            trip_charging: false,
            charge_rate: 0,
            charge_port_door_open: true,
            motorized_charge_port: false,
            scheduled_charging_start_time: null,
            scheduled_charging_pending: false,
            user_charge_enable_request: null,
            charge_enable_request: true,
            eu_vehicle: false,
            charger_phases: null,
            charge_port_latch: 'Engaged',
            charge_current_request: 30,
            charge_current_request_max: 40,
            managed_charging_active: false,
            managed_charging_user_canceled: false,
            managed_charging_start_time: null }

            Comment


              #7
              Thanks for letting me bounce that stuff off you Sparkman. I figured it out. I wasn't carrying through the imports system far enough for the types I was using. When I put this at the top of my script it worked. Hopefully, now I won't forget to charge my car again!

              Imports System.Collections.Generic
              Imports System.Diagnostics

              Comment


                #8
                Originally posted by jayman13 View Post
                Thanks for letting me bounce that stuff off you Sparkman. I figured it out. I wasn't carrying through the imports system far enough for the types I was using. When I put this at the top of my script it worked. Hopefully, now I won't forget to charge my car again!

                Imports System.Collections.Generic
                Imports System.Diagnostics
                Great, glad you got it resolved. Not sure why you got errors when modifying the scripting references. Make sure there's no space before and after the =. What kind of errors did you get?

                Cheers
                Al
                HS 4.2.8.0: 2134 Devices 1252 Events
                Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                Comment

                Working...
                X