Announcement

Collapse
No announcement yet.

Run Python script from event handler

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

    Run Python script from event handler

    I've seen some posts about running python scripts in HS, so it must be possible. But it's not working for me, I get in log (some posts even report this error):

    Running script: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: startIndex-> at System.String.IndexOf(String value, Int32 startIndex, Int32 count, StringComparison comparisonType) at System.String.IndexOf(String value, Int32 startIndex)

    Some options:
    1. Run script with .py extension directly - the option I tried unsucessfuly. I even installed ActivePython 2.5.5.7 which some got working
    2. "Run another Program or Process" and call python interpreter - this should work for sure
    3. IronPython from Microsoft - should then be possible to call Python from .NET
    4. Ask HS support - didn't work (surprise, surprise)

    Anybody can share success story?

    #2
    "Run another Program or Process" and call python interpreter should work. See here for an example calling ActivePerl. Your script should be the first parameter. Make sure to enclose that in quotes if there are any spaces in the pathname (as there will be if the script is in the HS3 scripts directory). Any parameters to the script go after that, just like if it was being run from the command line.

    Downside is that any output doesn't go to the HomeSeer HS3 log. The program opens in a cmd window which disappears as soon as the program completes. So you'll want to debug it first in a command window, or write the output to a file.

    Comment


      #3
      Originally posted by zwolfpack View Post
      "Run another Program or Process" and call python interpreter should work. See here for an example calling ActivePerl. Your script should be the first parameter. Make sure to enclose that in quotes if there are any spaces in the pathname (as there will be if the script is in the HS3 scripts directory). Any parameters to the script go after that, just like if it was being run from the command line.

      Downside is that any output doesn't go to the HomeSeer HS3 log. The program opens in a cmd window which disappears as soon as the program completes. So you'll want to debug it first in a command window, or write the output to a file.
      As I said, this option should work, but it's least desirable. If nothing else works - then yeah, I'll do that

      Comment

      Working...
      X