Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


[Deprecated} Using the Flirc USB for remote control with mOde 5.4+
#19
(12-21-2019, 10:04 AM)DRONE7 Wrote: ok, I interpreted Kents post as...(and it worked Smile )  in a ssh session run...


Code:
sudo nano Flirc-moode.py
then copy and paste Kent's script....

Code:
#!/usr/bin/python3
import os, asyncio,evdev,subprocess,time

# Hackery by TheOldPresbyope
# - control some moOde playback functions from a Flirc USB

# the following endpoint tracks media keys:
#flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-if01')
# the following endpoint tracks "valid command" keys
flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd')

# make sure Raspbian doesn't consume the keyboard input before we do
flirc.grab()

# paired with my Roku remote to have the following outputs
# *** had to rework to use only "valid command" keys so could watch
# *** just one endpoint
#
#   Roku button                 Flirc output     moOde function
# "left arrow button"           -> "KEY_A"       => favorites
# "home button"                 -> "KEY_B"       => default playlist
# "up angle button"             -> "KEY_C"       => volume up
# "left-angle bracket button"   -> "KEY_D"       => previous
# "OK button"                   -> "KEY_E"       => mute/unmute
# "right angle bracket button"  -> "KEY_F"       => next
# "down angle button"           -> "KEY_G"       => volume down
# "redo button"                 -> "KEY_H"       => nothing yet
# "asterisk button"             -> "KEY_I"       => nothing yet
# "double-left diamond button"  -> "KEY_J"       => nothing yet
### careful: flirc_util 3.22.4 says "k" is not a valid letter!!!
# "play/pause button"           -> "KEY_L"       => play/pause
# "double-right diamond button" -> "KEY_M"       => nothing yet

for event in flirc.read_loop():
   if event.type == evdev.ecodes.EV_KEY:
       attrib = evdev.categorize(event)
       if attrib.keystate == 1:
           if attrib.keycode == 'KEY_F':
               subprocess.run(['mpc','next'])
           elif attrib.keycode == 'KEY_D':
               subprocess.run(['mpc','prev'])
           elif attrib.keycode == 'KEY_C':
               subprocess.run(['/var/www/vol.sh','-up','10'])
           elif attrib.keycode == 'KEY_G':
               subprocess.run(['/var/www/vol.sh','-dn','10'])
           elif attrib.keycode == 'KEY_L':
               subprocess.run(['mpc','toggle'])
           elif attrib.keycode == 'KEY_A':
               subprocess.run(['mpc','clear'])
               time.sleep(0.1)
               subprocess.run(['mpc','load','Favorites'])
           elif attrib.keycode == 'KEY_B':
               subprocess.run(['mpc','clear'])
               time.sleep(0.1)
               subprocess.run(['mpc','load','Default Playlist'])
           elif attrib.keycode == 'KEY_E':
               subprocess.run(['/var/www/vol.sh','-mute'])
and change to suit the V1 Flirc as per this post
http://moodeaudio.org/forum/showthread.p...3#pid15213

edit  to suit your remote and key codes and save....
If you need help here then let me know... Wink

I am away from my Pi and about to retire for the night but tomorrow will post the full working config and script I am using.

Cheers,
Bob

Many thanks for your help Bob.

Regards,
Richard.
Reply


Messages In This Thread
RE: Using the Flirc USB for remote control with mOde 5.4+ - by rh2018 - 12-21-2019, 11:24 AM

Forum Jump: