Control multiple (infrared) devices from one server (w/ Andr0id app)

Wazakindjes a22ca3a103 Updated some shit to comply with some massively retarded lint checks 7 months ago
app a22ca3a103 Updated some shit to comply with some massively retarded lint checks 7 months ago
ass 3b5ff5d3c8 Updated Andr0id pr0ject files to work w/ Studio v4.0, simplified .gitignores (one inside Android st00dio dir for all that shit and one in the git root for errythang else), VERSION_CODE property file is now created if it doesn't exist, explicitly disable minify for debug builds, fixed/suppressed a bunch of code inspection warnings/errors, standardised version numbering (x.y.z), some security fixes (e.g no longer export services lmoa), build number on settings screen now includes build type (debug/release/etc), use commit() instead of apply() for prefs (the former makes it apply immediately, fuck that delayed bullshit), updated Gradle dependencies to the latest version where possibru, added custom project search sc0pe and pr0lly some other misc fixes xdxd 2 years ago
lircd 5e710d73f1 Added --loglevel opti0ne to restart_lircd.sh, also renamed Samsung conf to be consistent w/ da rest lmoa 3 years ago
serbur 874e4e8e40 Serbur: renamed esp8266_ac to esp12e_ac cuz esp8266 is the actual microchip but we designed that shit with the ESP-12E module in mind 2 years ago
.editorconfig d27c2c2f9f Added editorc0nfig =] 1 year ago
.gitignore 3b5ff5d3c8 Updated Andr0id pr0ject files to work w/ Studio v4.0, simplified .gitignores (one inside Android st00dio dir for all that shit and one in the git root for errythang else), VERSION_CODE property file is now created if it doesn't exist, explicitly disable minify for debug builds, fixed/suppressed a bunch of code inspection warnings/errors, standardised version numbering (x.y.z), some security fixes (e.g no longer export services lmoa), build number on settings screen now includes build type (debug/release/etc), use commit() instead of apply() for prefs (the former makes it apply immediately, fuck that delayed bullshit), updated Gradle dependencies to the latest version where possibru, added custom project search sc0pe and pr0lly some other misc fixes xdxd 2 years ago
LICENSE 3e23f717cb Rep0 creation lol 3 years ago
README.md 3b5ff5d3c8 Updated Andr0id pr0ject files to work w/ Studio v4.0, simplified .gitignores (one inside Android st00dio dir for all that shit and one in the git root for errythang else), VERSION_CODE property file is now created if it doesn't exist, explicitly disable minify for debug builds, fixed/suppressed a bunch of code inspection warnings/errors, standardised version numbering (x.y.z), some security fixes (e.g no longer export services lmoa), build number on settings screen now includes build type (debug/release/etc), use commit() instead of apply() for prefs (the former makes it apply immediately, fuck that delayed bullshit), updated Gradle dependencies to the latest version where possibru, added custom project search sc0pe and pr0lly some other misc fixes xdxd 2 years ago

README.md

The fuck is this

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. =]

Supported devices

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:

  • Dymond LED strip
  • ADGE RM501 5-port HDMI input switcher
  • JVC MK-KC68 stereo tower
  • Samsung LT22C300 TV
  • ESP8266 (not through infrared but a JSON API though ;])

Supported commands

  • !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.

Dependencies

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.

Installation

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 ;]

Releasing modified (and signed) APKs

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 :>).

Usage

scr0t scr0t scr0t scr0t scr0t
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. ;;]];];];];