Announcement

Collapse
No announcement yet.

Call python script and manage output

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

    Call python script and manage output

    I'm running HS3 on Windows 10. I would like to call a python script and add the output from that script to a virtual device.

    I have python set up and the script works as expected from cmd line. What should I do to make this work in HS3?

    #2
    Hi ,

    Maybe this would help ?
    i never tested it

    https://sourceforge.net/projects/pywin32/

    regards




    Originally posted by Freddan101 View Post
    I'm running HS3 on Windows 10. I would like to call a python script and add the output from that script to a virtual device.

    I have python set up and the script works as expected from cmd line. What should I do to make this work in HS3?
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

    Comment


      #3
      Originally posted by Freddan101 View Post

      I have python set up and the script works as expected from cmd line. What should I do to make this work in HS3?
      I run command line programs within events as follows:
      Choose "run another program or process"

      click the edit program and navigate to your python executable, choosing your executable, click submit.

      In the "enter any command parameters to be appended to the program or file being launched:" enter your path\python-script just as you do on the command line.
      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


        #4
        What kind of python script are you trying to run ?
        Maybe there is already a script for it that works with homeseer.

        I never used python with homeseer..

        regards


        Originally posted by lveatch View Post
        I run command line programs within events as follows:
        Choose "run another program or process"

        click the edit program and navigate to your python executable, choosing your executable, click submit.

        In the "enter any command parameters to be appended to the program or file being launched:" enter your path\python-script just as you do on the command line.
        Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
        Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




        HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

        Comment


          #5
          I started to look at at this myself a few weeks ago. There are two ways to turn python code into an executable. I haven't tried either of those yet. And, they still require python to be installed, which I was trying to eliminate. It's not ideal but I may just run it on my Synology (which already has python installed).. But probably just won't bother since it will be more work than benefit.

          Sent from my SM-G950U using Tapatalk

          Comment


            #6
            Originally posted by lveatch View Post
            I run command line programs within events as follows:
            Choose "run another program or process"

            click the edit program and navigate to your python executable, choosing your executable, click submit.

            In the "enter any command parameters to be appended to the program or file being launched:" enter your path\python-script just as you do on the command line.
            Thank you. That was simple enough.

            Is there a way that I can take care of the output from the script? Or do I need to that with a vb script somehow? I would like to add the output to a virtual device.

            Comment


              #7
              Originally posted by Freddan101 View Post
              Thank you. That was simple enough.

              Is there a way that I can take care of the output from the script? Or do I need to that with a vb script somehow? I would like to add the output to a virtual device.
              There are ways but I found these had mixed results as a response from a console window may not always be what you are expecting, there is the ProcessStartInfo.RedirectStandardOutput which you can use in a script to launch an application and then direct the output say to a stream which you can deal with. Is there any chance the python code can be changed to .net or is there a .net alternative?

              Comment


                #8
                The python script is written by someone else and too complex for me to translate into .net. I will check out ProcessStartInfo.RedirectStandardOutput and see what I can come up with.

                I'm also playing with the idea to send the output of the python script to a text file and then let the .net script read the file.

                Comment


                  #9
                  How about modifying the Python script to output JSON to control the device? Its relatively simple to format the JSON message. Here is an example of a Python web client:
                  https://docs.python.org/2.4/lib/httplib-examples.html

                  Comment


                    #10
                    Originally posted by zwolfpack View Post
                    How about modifying the Python script to output JSON to control the device? Its relatively simple to format the JSON message. Here is an example of a Python web client:
                    https://docs.python.org/2.4/lib/httplib-examples.html
                    Thank you. That's a good option.

                    Comment

                    Working...
                    X