Skip to content
Advertisement

Pi RGB controler with Python over the web using PHP and SSH. It is good idea?

Iam made Python script that can control my BLE RGB strip, also I made web page with php that connect to Pi via ssh and run Python script. My question is, is there a better way ?

I will mark my favorite answer in few days. I hope someone will see this and get same inspiration like me.

Thanks for all comments.

My PHP code.

JavaScript

Advertisement

Answer

I would use Python/Flask to run this web page. And I would run it directly on Pi so I wouldn’t need to use login/password

This is (more or less) PHP converted to Flask to run directly on PI (without SSH)

I used port 8080 because standard port 80 would need root privileges.

JavaScript

Eventually I would create separated URLs for every command

JavaScript

And later I would use Python to build desktop GUI (tkinter, PyQt, PyGTK, wxPython) or mobile App (Kivy).


JavaScript

I use subprocess to run your on.py, off.py, color.py but I would rather use import on, import off, import color and execute function from imported modules but it would need to put code in function in on.py, off.py, color.py (which probably you didn’t)


BTW: this way you would build something similar to Home Assistant which also use Python code

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement