Thank you for your donation!


[Deprecated} Using the Flirc USB for remote control with mOde 5.4+
#21
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.

Reply
#22
(12-21-2019, 01:00 PM)TheOldPresbyope Wrote: @rh2018

Hi, Richard.

Yes, I suppose I should have changed my specific hostname to the generic hostname moode but my original post was a work in progress and, like I warned, it assumed moderate Linux literacy. Glad to hear you got things straightened out with Bob's able assistance.

I must say I'm puzzled that V.1 FLIRCs seem to be in such abundance, but after this week's crush of holiday visitors and activities I expect to fix up the script to accommodate both V.1 and V.2 automagically. As well, there's the undone business about making the code a proper service.

All the best in this holiday season.

Regards,
Kent

Hi Kent,

Many thanks for your reply. Yes, V.1 FLIRCS are available locally here but V.2 has been out of stock for some time.

I will try Bob's V.1 script over the break and look forward to following your further work on this.

Have a great Christmas and New Year,

Regards,
Richard.
Reply
#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
#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
#25
If you have saved as
Code:
Flirc-moode.py

and are already ssh into moode as user pi then running
Code:
Flirc-moode.py

should be all that's needed...

check that the script is saved correctly...

Code:
ls
should return a list of items in pi's home directory including your saved python script...

6.4 is what I'm using..

Reply
#26
(12-23-2019, 09:11 AM)DRONE7 Wrote: If you have saved as
Code:
Flirc-moode.py

and are already ssh into moode as user pi then running
Code:
Flirc-moode.py

should be all that's needed...

check  that the script is saved correctly...

Code:
ls
should return a list of items in pi's home directory including your saved  python script...

6.4 is what I'm using..

Hi Bob,

All good! I edited Flirc-moode.py in Notepad++ (Windows) and although NP++ displays the file in Python syntax it does not automatically save Unix/Linux format line ends.

Once converted the script runs without errors - tricky!

Thanks and regards,
Richard
Reply
#27
Hello Kent and Bob,


Just a note to thank you both for introducing and refining the Flirc USB Remote Control.

After the issues with Lirc and Kernel 4.19.xx I developed an Arduino IR remote solution with momentary relay closures to interface with Moode's GPIO button handler for a limited number of commands.

In comparison, your Flirc solution is more elegant, extensible and at slightly less cost.

And works a treat!! Smile

Thanks again and best regards,
Richard.
Reply
#28
Glad to hear it's working for you.

Now, back to that Boxing Day Test. Who's betting on whom?  Smile  

Regards,
Kent
Reply
#29
(12-26-2019, 07:38 PM)TheOldPresbyope Wrote: Glad to hear it's working for you.

Now, back to that Boxing Day Test. Who's betting on whom?  Smile  

Regards,
Kent

I think our Kiwi friends from across the ditch have quite a task ahead at 2-44 at stumps following our 467 first innings.

Could turn out to be even betting (said diplomatically)  Wink

Regards,
Richard.
Reply
#30
What is this strange game named after an insect to which you refer...? Wink

Reply


Forum Jump: