Announcement

Collapse
No announcement yet.

Need help with scripting.

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

    Need help with scripting.

    Hi

    I'm trying to design an ui for homeseer. Was looking at some other designs and one had made it so he could see when his kid was delivered and picked up from kindergarden with the help from phlocation2 and geofence.
    I got the following script from him to register the delivery:

    &hs.SetDeviceString(754, "Levert ("+DateTime.Now.ToString("HH:mm")+")", True)

    It should write a string to a virtual device that HStouch could pull out and display.

    I get this error message:

    Running script(2) &hs.SetDeviceString(754, "Levert ("+DateTime.Now.ToString("HH:mm")+")", True), init error: Require object: 'DateTime'

    What am I missing?

    #2
    The issue is the use of VBScript and/or VB.NET scripting in your immediate script command.

    You can either use:

    VBScript:
    Code:
    &hs.SetDeviceString(754, "Levert (" & Hour(now) & ":" & Minute(Now) & ")", True)
    or

    VB.NET:
    Code:
    &nhs.SetDeviceString(754, "Levert (" & DateTime.Now.ToString("HH:mm") & ")", True)
    Note the &nhs. rather than &hs.

    The use of &nhs will create a temporary script to perform this action.
    Jon

    Comment


      #3
      Thanks. I will try that. But why is the script working for the original person, but not me? He sent me both screenshots and the code.

      Comment


        #4
        The code you gave me worked. Thanks!

        Need help for the last bit. I have two events that starts a timer called "Barnehage" when i deliver my kid and a event that stops the timer when i pick up my kid.

        When I pick my kid a script should pull out the timer and place it on a virtual device as a string:


        &hs.SetDeviceString(748, TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Hours & "t " & TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Minutes & "m", True)



        Got this error:

        Running script(2) &hs.SetDeviceString(748, TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Hours & "t " & TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Minutes & "m", True), init error: Require object: 'hs.TimerValue(...)'

        Comment


          #5
          Originally posted by Radhoo View Post
          The code you gave me worked. Thanks!

          Need help for the last bit. I have two events that starts a timer called "Barnehage" when i deliver my kid and a event that stops the timer when i pick up my kid.

          When I pick my kid a script should pull out the timer and place it on a virtual device as a string:


          &hs.SetDeviceString(748, TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Hours & "t " & TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Minutes & "m", True)



          Got this error:

          Running script(2) &hs.SetDeviceString(748, TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Hours & "t " & TimeSpan.FromSeconds(hs.TimerValue("Barnehage").TotalSeconds ).Minutes & "m", True), init error: Require object: 'hs.TimerValue(...)'
          Change &hs. to &nhs.
          Jon

          Comment


            #6
            Thanks.

            Still wondering why the copied codes dont work on my homeseer, but works on the original author's homeseer. Does he have a plugin installed that I dont?

            Comment


              #7
              I have no idea but it has nothing to do with other plugins.
              Jon

              Comment


                #8
                Found the reason. He is using Linux and I'm using win10.

                Thanks for all the help. It is working now.

                Comment


                  #9
                  That makes sense since VBScript is not supported in Linux.....
                  Jon

                  Comment

                  Working...
                  X