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+
#24
(12-22-2019, 01:50 AM)DRONE7 Wrote: Some poor soul ran off our rural road, through a concrete power-pole, fence and hedge  at 6 am this morning.....took out the 230v household line and the 11,000v main feeder for several valleys hereabouts.

Consequently we've had no power for over 8 hours. Not a biggie as it's mild summer weather and the gas barbie is working.

However, this explains the delay in replying....

Here is Kent's script amended for Flirc V1 and my remote keys...

 I've added.....power-off commands, and mapped the remotes number buttons to favourite radio streams... as per yesterday it is saved as Flirc-moode.py 

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-if00')
# the following endpoint tracks "valid command" keys
flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-kbd')

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


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.call(['mpc', 'stop' ])
               subprocess.call(['sudo', 'poweroff' ])
           elif attrib.keycode == 'KEY_J':
               subprocess.run(['mpc','play'])
           elif attrib.keycode == 'KEY_L':
               subprocess.run(['mpc','pause'])
           elif attrib.keycode == 'KEY_E':
               subprocess.run(['mpc','prev'])
           elif attrib.keycode == 'KEY_F':
               subprocess.run(['mpc','next'])
           elif attrib.keycode == 'KEY_I':
               subprocess.call(['mpc','stop'])
           elif attrib.keycode == 'KEY_N':
               subprocess.call(['mpc','toggle'])
           elif attrib.keycode == 'KEY_1':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://streaming.radionomy.com/acidbarrett?lang=en-US%2cen%3bq%3d0.5' ])
               subprocess.call(['mpc','play' ])
           elif attrib.keycode == 'KEY_2':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://5.152.208.98:8058' ])
               subprocess.call(['mpc','play' ])
           elif attrib.keycode == 'KEY_3':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://rock70s.stream.ouifm.fr/ouifmseventies.mp3' ])
               subprocess.call(['mpc','play' ])
           elif attrib.keycode == 'KEY_4':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://rock60s.stream.ouifm.fr/ouifmsixties.mp3' ])
               subprocess.call(['mpc','play' ])
           elif attrib.keycode == 'KEY_5':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://streaming.radionomy.com/65-75OBLIVIONBOULEVARD?lang=en-US%2cen%3bq%3d0.5' ])
               subprocess.call(['mpc','play' ])
           elif attrib.keycode == 'KEY_6':
               subprocess.call(['mpc','clear' ])
               subprocess.call(['mpc','insert','http://streaming.radionomy.com/Peace-Radio?lang=en-US%2cen%3bq%3d0.5' ])
               subprocess.call(['mpc','play' ])

I then edited /etc/rc.local and added...
Code:
/home/pi/Flirc-moode.py

just before..
Code:
exit 0
So that it starts on boot...

Post back if any of that is unclear..... and post if it works too Smile 

Cheers,
Bob.

Hi Bob,

Small hitch when running script
Code:
pi@moode:~ $ ./Flirc-moode.py                                                                                          
-bash: ./Flirc-moode.py: /usr/bin/python3^M: bad interpreter: No such file or directory        

I've checked python3 is installed and also evdev. I'm using Moode 6.4. Should I work with an earlier version for testing?

Regards,
Richard.

**Edit:** Looks like having edited script in Windows the script did not have correct Unix format. Re-made in Linux for my Key mapping.
So-far looking good!!
Regards, Richard.
Reply


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

Forum Jump: