Control multiple (infrared) devices from one server (w/ Andr0id app)
|
7 months ago | |
---|---|---|
app | 7 months ago | |
ass | 2 years ago | |
lircd | 3 years ago | |
serbur | 2 years ago | |
.editorconfig | 1 year ago | |
.gitignore | 2 years ago | |
LICENSE | 3 years ago | |
README.md | 2 years ago |
This shit is a dankass centralised remote control thanggGgGg for infrared devices. Hook up an IR blaster to like a Raspberry Pi and control that shit with y0 Android phone (rip iOS lmao).
The server side is a Perl skrip based on mein Meqqy code. Also, since the server only runs in SSL/TLS mode you'll need a certificate trusted by the clients used. It also has a built-in scheduler so you can turn on shit like LED strips before you come home. =]
The client side can be anything supporting a streaming (TCP) socket with TLS, but I'm using an Android app meinself (incl00ded in the app
directory lol). This app has a target SDK of 25 which corresponds to Android 7.1 (I'm using 25 cuz that gives me full-size app icons w/o that adaptive cancer). If you're using a self-signed cert, you should be able to import it into Settings
> Security
> Credentials
> Trusted CAs
or smt similar and it'll be accepted. Alternatively you can just disable the cert check inside the app's settings. =]
Since I wrote this shit for meinself, the Android app only supports devices I actually own. The server side should work with any device though, as long as you can control it through lircd
and modify the Perl skrip to parse a config section for it. I've included lircd config files for my own devices regardless:
!q[uit]
, !e[xit]
=> Attempt clean disconnect!led[cont | stop] <$button>
=> Send a button code to em LED strip, cont
is for sending signals continuously and stop
is for stopping that shit (in my case, lircd ends a START_SEND
after a bit over 1 minute)!hdmi[cont | stop] <$button>
=> Ditt0 for em HDMI switcheroo!stereo[cont | stop] <$button>
!tv[cont | stop] <$button>
The ESP8266 is quite different from the other devices, it also supports many more different commands so I'll listem separately:
!esp8266_ac read_temp
=> read the current temperature from an attached sensor (prolly een DS18B20)!esp8266_ac servo_rotate <$microseconds>
=> rotate an attached serv0 motor to an absolute position (referred to as microseconds, shit's more reliable than simply using degrees)!esp8266_ac servo_acbutton
=> press the power button on muh air conditioner (actual position is defined by the c0dd on the ESP ;])!esp8266_ac servo_reset
=> reset to neutral position (ditt0)!esp8266_ac led_onboard <on | off>
=> enable/disable on-board LED (usually bl00)!esp8266_ac led_flasher <on | off>
=> enable/disable flasher LED (in my case green, indicates an OTA flash is in br0gress)!esp8266_ac led_error <on | off>
=> enable/disable error LED (red obv)!esp8266_ac led_http <on | off>
=> enable/disable HTTP LED (yell0 lol, indicates an HTTP API request is in br0gress)!esp8266_ac reboot
=> reb00t the fuckin thang!esp8266_ac deepsleep
=> put em in deep sleep (how long once again depends on the c0dd on the ESP ;])For an example of an ESP8266 supporting all that shit, go here.
Just some good ol' Perl modules (many should already be available by default):
Config::IniFiles
Data::Dumper
DateTime
File::Basename
HTTP::Request::Common
IO::Handle
IO::Select
IO::Socket::INET
IO::Socket::SSL
JSON
LWP::UserAgent
Time::Local
You also need access to lircd and its irsend
command in order to actually control devices. It varies wildly how to enable this per RPI model and OS/kernel versions, so look that shit up.
Copy muhconf.ini.example
to muhconf.ini
and fire up een editor. All the options are explained in there so git to reading fam. The config file must be kept in the same dir as the skrip.
Then, to run it as a "daemon" you can just use a screen
session so you can still czech em output y0. My user's $HOME/.screenrc
fiel contains:
screen -t rem0t0 bash -c "while true; do echo '(Re)starting rem0t0'; kill -9 $(ps aux | grep [p]erl.*rem0t0.pl | awk '{print $2}') > /dev/null 2>&1 ; /home/hecks/rem0t0/serbur/rem0t0.pl; sleep 5; done"
And the user's crontab
has:
@reboot screen -dmS Hax
ez pz ;]
You'll need to make some adjustments if you want to release signed APKs lol. Refer to the section right here (only applies to Mac OS X, if you're on Windows then idk how to do something similar :>).
Deez nuts scr0ts should be p self-explanatory imo tbh. As you can see, you can specify labels for the HDMI switch's buttons (cuz I always forget which is which ;_;).
If you longpress on a button (i.e. hold it for 300ms) it will send a cont
command, then when you release em it will send a stop
command. This works for almost all remotes (non-IR shit like the ESP8266 excluded), but there's no real point for it in regards to the HDMI switch. ;;]];];];];