diff --git a/scripts/fanController.py b/scripts/fanController.py index 96e3df8..9b247dd 100755 --- a/scripts/fanController.py +++ b/scripts/fanController.py @@ -40,7 +40,7 @@ def turnFanOFF(): if __name__ == '__main__': - arg = argv[1] + arg = argv[-1] if (arg == 'on'): print(turnFanON()) elif (arg == 'off'): @@ -48,4 +48,4 @@ if __name__ == '__main__': elif (arg == 'get'): print(getFanstate()) else: - print("Invalid input") \ No newline at end of file + print("Invalid input") diff --git a/scripts/fanState.db b/scripts/fanState.db index 7ec0dc0..cdc123b 100644 Binary files a/scripts/fanState.db and b/scripts/fanState.db differ diff --git a/server.js b/server.js index 40de953..51f3f9d 100755 --- a/server.js +++ b/server.js @@ -21,7 +21,6 @@ app.get('/state', function(req, res) { PythonShell.run('scripts/fanController.py', options, function (err, results) { if (err) throw err; - if (results[0] == true) res.send('on') else @@ -37,8 +36,8 @@ app.post('/on', function (req, res) { }; PythonShell.run('scripts/fanController.py', options, function (err, results) { - if (err) throw err; - + if (err) throw err; + if (results[0] == true) res.send('on') else