I want to be able to send commands to my air purifier via Flask, so I can use its functions with my home automation in webcore.
Here is the python snippet
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route('/status')
def my_command():
cmd = 'airctrl --ipaddr 192.168.99.55 --protocol coap --mode S'
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
out,err = p.communicate()
return out
if __name__ == "__main__" :
app.run(host="192.168.99.45", port=5000, debug=True)
What will always return
FileNotFoundError: [Errno 2] No such file or directory: 'airctrl --ipaddr 192.168.99.55 --protocol coap --mode S': 'airctrl --ipaddr 192.168.99.55 --protocol coap --mode S'
How can I tell flask, wehre to find "airctrl"?
I have tried
cmd = '/usr/local/bin/airctrl', 'airctrl --ipaddr 192.168.99.55 --protocol coap --mode S'
which will return nothing but also do nothing.
Reallay appreciate your help, as you can see I am a total beginner and have googled for solutions for hours now.
Thank you,
Thomas