I’ve done it! I’ve released my first PyPI package!
RCFC is a remote control for computers. The basic idea is that I want to be able to write some Python functions, and then have a UI that can call those functions. As I change the code, no UI changes required, it’s all generated dynamically.
My goal is to continue my Rasberry Pi automation project (the one I can control a projector with), and I wanted a UI (since I still can’t get my sound system to work correctly). I want to be able to control these things with a phone (and since I’m fickle, I want to change it often.)
So I had an idea, why can’t I just write a Android App that scans all servers in my house, and builds the GUI dynamically. As long as the servers can advertise which buttons they provide, I should be able to build it up on the fly.
So for first proof of concept, I figured I could just bundle a webserver with my python code. It’s not pretty, but it gives me a way in.
The code to create that wasn’t too bad either:
import subprocess import time from rcfc import button, server @button.simple("Projector On") def projector_on(): subprocess.Popen("irsend SEND_ONCE projector.conf KEY_POWER".split()) @button.simple("Projector Off") def projector_off(): subprocess.Popen("irsend SEND_ONCE projector.conf KEY_POWER2".split()) time.sleep(1) subprocess.Popen("irsend SEND_ONCE projector.conf KEY_POWER2".split()) server.start()
Just simple little decorators, and it built that webpage for me.
Behind the scenes, it is translating the decorator into a bottle.route call, which sets up my webpage routing. Then I built a stupidly simple JS/HTML/CSS home page to query all the buttons, display them, and set up click handling for them to execute the right post.
Code is all right here if you want it : RCFC on GitHub
Next up, I think I’ll learn some Kotlin and write the Android App. I’ve never done anything meaningful on Android before, so it should be interesting.