Announcement

Collapse
No announcement yet.

Help running a python script via batch file

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

    Help running a python script via batch file

    I picked up a Ecovacs Deebot N79 and I managed to find a python script to start and stop the vac. I created a batch file to run the python script, which works just fine.

    I setup HS to run the batch file using 'run another program or process'
    After the vac completes, it returns to the charger, but the batch file (command prompt) remains open.

    Surely there's a more elegant way to do this, or maybe a simple plugin. I'm guessing there's an easier way to run this script other than using a batch file.

    The script I used I snagged from the smartthings forum, and the python script is hosted on Github.

    https://community.smartthings.com/t/...t-n79/93410/47

    https://github.com/wpietri/sucks

    Thanks!
    Last edited by ; November 29, 2017, 01:22 PM. Reason: typo

    #2
    See this post for example of how I launch a perl script. python should be similar.

    Comment


      #3
      Awesome, will give it shot when I get back home

      Comment


        #4
        Can you update the forum with results? How is this working for you?

        Comment


          #5
          I have a python script the 'reads' my alarm and sends MQTT messages. On the same PC as HS I run the python script as a a service. Works perfectly.

          Comment


            #6
            I do this with wyze vacuums. This is the batch file lines:

            Code:
            @echo off
            "C:\Python310\python.exe" "c:\Wyze_Vac\Vac1.py"​

            The batch file runs the python script with out any problems. The batch file must be in the HS4 scripts directory. The cmd window opens then closes. As Ianireand indicated if you run it as a service you wont see the cmd window

            Comment


              #7
              In Windows you can also call python from a vb script, which is one way to get values from HS to Python. It may be cleaner to use JSON in python to get any HS info you want, but for some reason I went down the road of mixing vb and python. I have HS run a vb script like below:

              Running a vb script from HS:
              Code:
              Public Sub Main(ByVal X)
              Dim Y as Integer = hs.devicevalueex(1234)
              Dim app as String = """C:\Python39\python.exe"""
              Dim pth_file as String = """C:\Program Files (x86)\HomeSeer HS4\scripts\python_script.py"""
              Shell(app & " " & pth_file & " " & X & " " & Y)
              End Sub
              ​
              Then in python_script you just use sys to ingest the command line values:
              Code:
              import sys
              X = int(sys.argv[1])
              Y = int(sys.argv[2])​

              Comment


                #8
                I'm running on Linux but the info above has steered me in the right direction. I have an Ecovacs robot vacuum like the original poster, so I'm curious what he/anyone has accomplished with Ecovacs integration. (Perhaps I should start a new thread for that)

                Comment


                  #9
                  Yeah, I use this for a Wyze vacuum so that it cleans when no one is home, cycling between rooms based on how recently each was cleaned. It forces us to make sure we don't leave cords on the floor whenever we leave. Let me know if you can figure out a solution for that!

                  Comment

                  Working...
                  X