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+
#2
Hi Kent, I thought to give your How-to a try with my Flirc (original) usb device. Pi 3 running MoOde 6.4, Kali and Piano Dac.

Errors when running ./Flirc-moode.py

Code:
./Flirc-moode.py
Traceback (most recent call last):
 File "/usr/lib/python3/dist-packages/evdev/device.py", line 125, in __init__
   fd = os.open(dev, os.O_RDWR | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "./Flirc-moode.py", line 10, in <module>
   flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd')
 File "/usr/lib/python3/dist-packages/evdev/device.py", line 127, in __init__
   fd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd'
 Script used as per your details but modded for HP remote..

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
#
#  HP button                 Flirc output     moOde function
# "Power button"                 -> "KEY_A"       => Shutdown
# "Play button"                  -> "KEY_B"       => Play
# "Pause button"                 -> "KEY_C"       => Pause
# "Previous button"              -> "KEY_D"       => Previous
# "Next button"                  -> "KEY_E"       => Next
# "Stop button"                  -> "KEY_F"       => Stop
# "1 button"                     -> "KEY_G"       => Radio 1
# "2 button"                     -> "KEY_H"       => Radio 2
# "3 button"                     -> "KEY_I"       => Radio 3
# "4 button"                     -> "KEY_J"       => Radio 4
### careful: flirc_util 3.22.4 says "k" is not a valid letter!!!
# "5 button"                     -> "KEY_L"       => Radio 5
# "6 button"                     -> "KEY_M"       => Radio 6
# "7 button"             -> "KEY_N"      => Radio 7
# "8 button"             -> "KEY_O"      => Radio 8
# "9 button"             -> "KEY_P"      => Radio 9
# "0 button"             -> "KEY_Q"      => Radio 0
# "Mute button"             -> "KEY_R"      => Mute/Unmute
# "Win button"             -> "KEY_S"      => Toggle Play/Pause
# "RedTV button"         -> "KEY_T"      => Favourites
    
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_A':
               subprocess.run(['mpc','shutdown'])
           elif attrib.keycode == 'KEY_B':
               subprocess.run(['mpc','play'])
           elif attrib.keycode == 'KEY_C':
               subprocess.run(['mpc','pause'])
           elif attrib.keycode == 'KEY_D':
               subprocess.run(['mpc','prev'])
           elif attrib.keycode == 'KEY_E':
               subprocess.run(['mpc','next'])
           elif attrib.keycode == 'KEY_F':
               subprocess.run(['mpc','stop'])
Code:
$ lsusb
Bus 001 Device 004: ID 20a0:0001 Clay Logic


Anything jump out there ?

Cheers,
BoB
----------
bob
Reply


Messages In This Thread
RE: Using the Flirc USB for remote control with mOde 5.4+ - by DRONE7 - 12-15-2019, 05:07 AM

Forum Jump: