Originally posted by mrhappy
View Post
Announcement
Collapse
No announcement yet.
HS3 Running event from Command Line
Collapse
X
-
Originally posted by Rupp View PostAttached 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
-
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
-
vb.net syntax
Originally posted by mrhappy View PostI 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.
Thank you
Comment
-
Originally posted by frankc View PostI 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
-
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?
RobertHS3PRO 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
-
Originally posted by mrhappy View Postto 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.
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
-
Originally posted by langenet View PostI'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
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
-
Originally posted by frankc View PostI'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.Last edited by mrhappy; December 28, 2016, 03:19 PM.
Comment
-
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(jsonDataBytes, 0, jsonDataBytes.Length)
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
-
Originally posted by mrhappy View PostDoes 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.
Would you post that forms application demo again? I wanted to review it one more time. Thank you!
Comment
-
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
-
Originally posted by rmuziani View PostI 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
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
Comment