Bluetooth remote control from Aliexpress
1. Orangepi zero
2. Bluetooth reciever Orico
3. Bluetooth remote button
for placement in the shower, the button was waterproofing with auto sealant.
files with updated code and service:
thanks to
installation:
Configuration file btremote.conf
my setup:
Behringer MS-40, usb dac, OrangePi Zero, LMS, Squeezelite, lan, livingroom
JBL Playlist black, wifi 5, Chromecast, bedroom
JBL Playlist white, wifi 5, Chromecast, veranda
GGMM E2, wifi 2,4, DLNA, bathroom
BBK BTA6000, DIY built-in OrangePi Zero, wifi 2,4, Squeeze lite, portable
controls: SqueezeCtrl, iPeng on tablets/phones, tvbox remote G7V, Bluetooth media button.
1. Orangepi zero
2. Bluetooth reciever Orico
3. Bluetooth remote button
for placement in the shower, the button was waterproofing with auto sealant.
files with updated code and service:
thanks to
Code:
from evdev import InputDevice, categorize, ecodes import requests import time SERVER = 'http://192.168.1.56:9000/jsonrpc.js' PLAYER = '2e:c5:a3:c9:da:f2' PLAY = {"method": "slim.request", "params":[PLAYER, ["pause"]]} VOLUP = {"method": "slim.request", "params":[ PLAYER , ["mixer", "volume", "+5" ]]} VOLDN = {"method": "slim.request", "params":[ PLAYER , ["mixer", "volume", "-5" ]]} NEXT = {"method": "slim.request", "params":[ PLAYER , ["playlist","index","+1"]]} PREV = {"method": "slim.request", "params":[ PLAYER , ["playlist","index","-1"]]} KEY_VOLUMEUP = 115 KEY_VOLUMEDN = 114 KEY_PLAYPAUSE = 164 KEY_NEXT = 163 KEY_PREV = 165 def getkey(): print('getkey started') remote = InputDevice('/dev/input/event2') print(remote) for event in remote.read_loop(): if event.type == ecodes.EV_KEY: if event.value == 1: print(categorize(event)) if event.code == KEY_VOLUMEUP: print('volup Pressed') r = requests.post(SERVER, json=VOLUP) if event.code == KEY_VOLUMEDN: print('voldn Pressed') r = requests.post(SERVER, json=VOLDN) if event.code == KEY_PLAYPAUSE: print('play Pressed') r = requests.post(SERVER, json=PLAY) if event.code == KEY_NEXT: print('next Pressed') r = requests.post(SERVER, json=NEXT) if event.code == KEY_PREV: print('prev Pressed') r = requests.post(SERVER, json=PREV) def main(): while True: print('start try') try: remote = InputDevice('/dev/input/event2') print(remote) print('start get key') getkey() except OSError as err: print("OS error: {0}".format(err)) print('no bt connect') time.sleep(5) main()
Code:
sudo apt-get update sudo apt-get install bluetooth bluetoothctl sudo apt install input-utils lsinput sudo apt-get install python3 sudo apt install python3-pip sudo pip3 install evdev (sudo apt install python3-dev) (sudo apt-get install libzbar-dev libzbar0)
Code:
{ "volstep": "5", "btdevice": "/dev/input/event2", "player": "bb:bb:6c:b8:26:52", "server": "http://192.168.1.56:9000/jsonrpc.js" }
Behringer MS-40, usb dac, OrangePi Zero, LMS, Squeezelite, lan, livingroom
JBL Playlist black, wifi 5, Chromecast, bedroom
JBL Playlist white, wifi 5, Chromecast, veranda
GGMM E2, wifi 2,4, DLNA, bathroom
BBK BTA6000, DIY built-in OrangePi Zero, wifi 2,4, Squeeze lite, portable
controls: SqueezeCtrl, iPeng on tablets/phones, tvbox remote G7V, Bluetooth media button.
Comment