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+
#23
(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.

Many thanks Bob,

Glad your power is back on - must have been quite spectacular when the 11kV lines went down.

I'll work through your code over the break and let you know progress.

The Boxing Day test should be interesting. Reports say N.Z. are watching old Walter Jardine body-line films! Smile

Should make for an interesting test.

All best for Christmas and New Year

Ahua pai,

Richard.
Reply


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

Forum Jump: