Announcement

Collapse
No announcement yet.

HS3 Running event from Command Line

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

    #16
    Originally posted by mrhappy View Post
    Check that your dll's are up to date in whatever folder you have the hs3eventrun.exe file in, HS make changes to these sometimes which can lead to them being out of date.
    Brilliant thank you that got everything back up and working. Steve

    Comment


      #17
      Originally posted by Rupp View Post
      Attached is a small c# application I wrote a while back that can run the new JSON commands for HS3. It really only works well with triggering events as I just ignore the return value. I dropped the RunJSON.exe in my HS3 directory and created a shortcut to it on my desktop. Then simply edit the short cut adding your JSON command to the end of the target ie
      Code:
      "C:\Program Files (x86)\HomeSeer HS3\RunJSON.exe" http://172.17.32.31:81/JSON?request=runevent&group=Speaking&name=SpeakTheTime

      Hi Rupp, I tried your program on Windows 7 (on both 32 and 64 bit versions) and the program crashes ("Program Stopped Working"). Could this be corrupt?

      Comment


        #18
        While this is an older thread, I still found the contents valuable.

        Mr. Happy's script works fine.

        Rupp's works great too. But I added double quotes around the JSON command in his example:

        Code:
        "C:\Program Files (x86)\HomeSeer HS3\RunJSON.exe" "http://172.17.32.31:81/JSON?request=runevent&group=Speaking&name=SpeakTheTime"

        Comment


          #19
          vb.net syntax

          Originally posted by mrhappy View Post
          I have written an app that might be of use to some, it will accept an event name by command line and then try and trigger the event.
          I need some advice regarding the syntax to be used to execute this 'command line' from within a vb.net script. I've tried several approaches but haven't got it to work yet.

          Thank you

          Comment


            #20
            Originally posted by frankc View Post
            I need some advice regarding the syntax to be used to execute this 'command line' from within a vb.net script. I've tried several approaches but haven't got it to work yet.

            Thank you
            I'm a bit confused really what you are trying to do - could you elaborate a bit further? I mean to run that bit of code as a compiled EXE from vb.net you could use the Process.Start call (http://www.dotnetperls.com/process-vbnet) but I would wonder why because you could just embed that code into VB to start with.

            Comment


              #21
              I'm further confused - I don't have a RunJSON.exe in my HS3 root directory.
              I haven't ventured with JSON in HS3 yet... Am I missing something?

              Robert
              HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

              Comment


                #22
                Originally posted by mrhappy View Post
                to run that bit of code as a compiled EXE from vb.net you could use the Process.Start call (http://www.dotnetperls.com/process-vbnet) but I would wonder why because you could just embed that code into VB to start with.
                I'm wanting to run an event from a windows vb.net form application. So as soon as I can run an HS3 event from the compiled application, I'll be set. A line similar to the following would be the right way to do it I think. But I'm not sure of the syntax:

                results = System.Diagnostics.Process.Start("C:\Program Files (x86)\Homeseer HS3\HS3EventRun.exe eventname='Test Event'")

                And perhaps a better way to run the event from the compiled program is to include the vb piece of your source code for "HS3EventRun.exe" rather than the .exe app. I think that is what you mean by "embed that code into VB to start with". But I haven't got that piece figured out.

                I know that Rich's JSON/vb.net example accomplishes this goal, but I haven't quite distilled it down far enough to find the appropriate syntax to execute a JSON command from a vb.net compiled program. Most likely your 'HS3EventRun' uses similar source code to Rich's example (??)

                Does that make sense?

                I appreciate the guidance with this MH.

                Comment


                  #23
                  Originally posted by langenet View Post
                  I'm further confused - I don't have a RunJSON.exe in my HS3 root directory.
                  I haven't ventured with JSON in HS3 yet... Am I missing something?

                  Robert
                  You can get 'RunJSON.exe from a link within this thread. There is also a second .exe available in this thread. Each of them is just saved to your HS3 root directory.

                  JSON allows you to control events and devices from scripts external to HS3. I have done that quite a bit. For example, read the status of lights and turn lights on and off. But what I haven't been able to figure out is how to use JSON commands from within a vb.net compiled program. I'm pretty sure there isn't much to it, but I haven't quite got it figured out. That is what each of the .exe applications do. They use JSON to control HS3 from a compiled vb.net or C# application.

                  In another thread, Rich provides an example where he is using JSON from within a vb.net application. And it works great. He includes the source code and you can compile it with VS Community 2015, which is free.

                  There are also some other "server" type applications written by HS3 users. I use those as well, but from scripts - not from compiled windows forms vb.net apps.

                  Comment


                    #24
                    Originally posted by frankc View Post
                    I'm wanting to run an event from a windows vb.net form application. So as soon as I can run an HS3 event from the compiled application, I'll be set. A line similar to the following would be the right way to do it I think. But I'm not sure of the syntax:

                    results = System.Diagnostics.Process.Start("C:\Program Files (x86)\Homeseer HS3\HS3EventRun.exe eventname='Test Event'")

                    And perhaps a better way to run the event from the compiled program is to include the vb piece of your source code for "HS3EventRun.exe" rather than the .exe app. I think that is what you mean by "embed that code into VB to start with". But I haven't got that piece figured out.

                    I know that Rich's JSON/vb.net example accomplishes this goal, but I haven't quite distilled it down far enough to find the appropriate syntax to execute a JSON command from a vb.net compiled program. Most likely your 'HS3EventRun' uses similar source code to Rich's example (??)

                    Does that make sense?

                    I appreciate the guidance with this MH.
                    Does this help at all, this is a forms application that will try and connect to HS (change your IP address), pop up a message box and then if it connects you can press a button and write to the HS log. You should be able to put most of this in your own forms application - sorry I thought I included the source code in my example but guess I forgot or removed it.
                    Last edited by mrhappy; December 28, 2016, 03:19 PM.

                    Comment


                      #25
                      Got It

                      Yes. Thank you MH!

                      The piece I was missing for using JSON with vb.net is:

                      PHP Code:
                      Dim req As WebRequest WebRequest.Create(uri)
                                  
                      req.ContentType contentType
                                  req
                      .Method method
                      Dim stream 
                      req.GetRequestStream()
                                      
                      stream.Write(jsonDataBytes0jsonDataBytes.Length
                      I didn't know enough to use "stream" to send JSON post commands to HS. I pulled that piece out of Rich's JSON example.

                      Another step that doesn't seem possible is to attach additional parameters to a JSON command to run an HS3 event such as:

                      "Post data: {'action' : 'runevent', 'group' : 'GROUPNAME', 'name' : 'EVENTNAME'}"

                      Thank you for the help!

                      Comment


                        #26
                        Originally posted by mrhappy View Post
                        Does this help at all, this is a forms application that will try and connect to HS (change your IP address), pop up a message box and then if it connects you can press a button and write to the HS log.
                        MH...

                        Would you post that forms application demo again? I wanted to review it one more time. Thank you!

                        Comment


                          #27
                          I am trying to use Rupp method to trigger an event from my desktop. My group is called kitchen and the event in that group is "ceiling light on". I droped RunJSON.exe in my HS3 directory and created a shortcut to it on my desktop. Than I edit the short cut adding "C:\Program Files (x86)\HomeSeer HS3\RunJSON.exe" http://192.168.1.111:5580/JSON?reque...n&name=Ceiling Light on" to the target. What am I missing?
                          Thx

                          Comment


                            #28
                            Originally posted by rmuziani View Post
                            I am trying to use Rupp method to trigger an event from my desktop. My group is called kitchen and the event in that group is "ceiling light on". I droped RunJSON.exe in my HS3 directory and created a shortcut to it on my desktop. Than I edit the short cut adding "C:\Program Files (x86)\HomeSeer HS3\RunJSON.exe" http://192.168.1.111:5580/JSON?reque...n&name=Ceiling Light on" to the target. What am I missing?
                            Thx
                            Try putting single quotes around the event name (e.g. name='Ceiling Light on').

                            If that doesn't work, you can trigger an event via the event id (request=runevent&id=###). I can't remember if there is an easier way to get the event id's but you can use the json command request=getevents.
                            Len


                            HomeSeer Version: HS3 Pro Edition 3.0.0.435
                            Linux version: Linux homeseer Ubuntu 16.04 x86_64
                            Number of Devices: 633
                            Number of Events: 773

                            Enabled Plug-Ins
                            2.0.54.0: BLBackup
                            2.0.40.0: BLLAN
                            3.0.0.48: EasyTrigger
                            30.0.0.36: RFXCOM
                            3.0.6.2: SDJ-Health
                            3.0.0.87: weatherXML
                            3.0.1.190: Z-Wave

                            Comment


                              #29
                              Does anyone have a link to the Hs3eventrun exe. Guess the links are a no go at this time.
                              Stuart

                              Comment


                                #30
                                does this method work in HS4?

                                Comment

                                Working...
                                X