Blog entries from June, 2021

My setup using RemotePi and a Harmony remote

Sunday, June 27th, 2021 at 11:19 am

Recently I wrote about how the RemotePi Board was the key to my desired setup for using a Raspberry Pi running Kodi as a media player. After the initial setup I needed to tweek some things related to my universal remote and while I don’t expect the RemotePi website to disappear, this post is my documentation on how I set it up (and how it works).

Raspberry Pi hardware

When I ordered the RemotePi I also ordered their open case as it has a hole for the power button and I didn’t want to hack up the existing case I was using. Based on the provided parts you shouldn’t need the instructions, it is pretty obvious how it all goes together.

Raspberry Pi software

It was interesting adding the scripts and config as I learned how it hooked into the LibreElec Startup & Shutdown process.

/storage/.config/autostart.sh

Runs at boot, in this case used to launch irswitch.sh in the background

#!/bin/bash
(/storage/.config/irswitch.sh)&

/storage/.config/irswitch.sh

Running in the background monitoring GPIO pin 14 for a signal from the RemotePi. This is how pressing the power button on the remote results in a graceful shutdown of the Pi.

#!/bin/bash
# this is the GPIO pin receiving the shut-down signal
GPIOpin1=14
echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
while true; do
  sleep 1
  power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
  if [ $power != 0 ]; then
    echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction
    echo "1" > /sys/class/gpio/gpio$GPIOpin1/value
    sleep 3
    poweroff
  fi
done

/storage/.config/shutdown.sh

Runs when the Pi is shutting down this tells the RemotePi via GPIO pin 15 to also shutdown and kill power to the Pi.

#!/bin/bash
if [ "$1" != "reboot" ]; then
  GPIOpin=15
  GPIOpin1=14
  echo "$GPIOpin" > /sys/class/gpio/export
  # execute shutdown sequence on pin
  echo "out" > /sys/class/gpio/gpio$GPIOpin/direction
  echo "1" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 125000
  echo "0" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 200000
  echo "1" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 400000
  echo "0" > /sys/class/gpio/gpio$GPIOpin/value
  # set GPIO 14 high to feedback shutdown to RemotePi Board
  # because the irswitch.sh has already been terminated
  echo "$GPIOpin1" > /sys/class/gpio/export
  echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction
  echo "1" > /sys/class/gpio/gpio$GPIOpin1/value
  usleep 4000000
fi

Remote control

MSL Digital have provided instructions for two remotes, a generic DVD player remote (that they can also provide) or how to configure a Logitech Harmony remote.

I wanted to keep using my old Harmony 650 remote so that is the path I choose. I was a bit surprised that once I dug up the MyHarmony software and remembered how to login that the config for my remote was still there. It was reasonable straightforward to add a “Media Center PC” device and configure a new “Kodi” activity.

The tricky part of the config was that I found it best to go into the settings for the device and change the power settings from “I press the same button for on and for off” to “I press two different buttons for on and for off”. The MCE device has PowerOn, PowerOff and PowerToggle commands. Not using PowerToggle is a cleaner solution, eg if the Pi was off but the Harmony thought it was still on, pressing the all off button would actually turn the Pi back on. Using discrete on and off will avoid that.

Once I had my remote sending MCE commands I trained the RemotePi to know about PowerOn and PowerOff:

  1. hold down button on RemotePi for 10 seconds, until the LED flashes red/green
  2. On the Harmony press PowerOn (be in devices and not activity to get the list of all commands)
  3. The LED will flash, then press PowerOff
  4. The LED will flash twice

Telling LibreELEC/Kodi about the remote and its buttons was amazingly easy and involved putting the SD card in a reader (so not on the Pi) and adding one line:

config.txt

dtoverlay=gpio-ir,rc-map-name=rc-rc6-mce

The documentation does say that CEC has to be disabled for an IR remote to work, I wonder if there was some automatic detection going on as I found that CEC stopped working as soon as the RemotePi was installed, in the end it didn’t matter as I knew I would be disabling CEC anyway by going to:

  • System > Settings > System > Input Devices > Peripherals > CEC

Tagged with: ,

Musing again on a media player

Monday, June 21st, 2021 at 10:11 pm

A long time ago I wrote a couple of times about different methods of playing media on my television, it looks like I never posted about the solution, which ended up being to use PS3 Media Server (now known as Universal Media Server) with all transcoding turned off, not via writing a custom FUSE filesystem to alter file extensions, but by finding the right configuration option.

As well as working nicely for my television I also picked up a cheap Android tablet and used a UPnP/DNLA app and VLC to be able to play the media on that as well. That tablet started to show its age so I picked up a newer one, at which point I found the UPnP/DNLA app didn’t exist anymore, but fortunately the ability to browse is now built directly in to VLC for Android.

It also turned out that I don’t often watch things on my television, instead playing them on my second monitor in my study, so I wasn’t that concerned when I noticed that media using newer codecs wouldn’t play on my television. This is now an eleven year old television that hasn’t had a firmware update in a long time, so I started looking in to media players again, and not just for me, but also for my parents.

Chromecast

About two years ago I picked up a basic Chromecast to try. It was quite easy to set up and worked exactly as described. However after some hands on experience I found that it wasn’t suitable. If you want to stream from somewhere else it is great, but the lack of control while playing (my deal breaker for a WDTV Live) and that you can’t just use it to find something to start playing is a problem.

It did come in handy for the first few months of lockdown last year when a couple of podcasts livestreamed episodes each week. The player is browser based but supports casting so I could get it started from my PC and then go relax on the couch.

I did try using my phone to control the Chromecast, but I wanted to use a traditional remote control and look at the television screen, not at the touchscreen in my hand.

Kodi on a Raspberry Pi

I find it interesting that as much as things change they also stay the same as ten years ago one thing I was considering was XBMC, well these days it is called Kodi and late last year I loaded that (using LibreELEC onto an old Raspberry Pi. This worked astonishingly well with it getting commands from the television over HDMI-CEC and importantly it being able to play the newer codecs.

Unfortunately there was a glaring issue, the Model B+ that I was using was not powerful enough to smoothly play those newer codecs. As I had proven the concept I ordered a Pi 3 B+ (at the time the only place I could find with reasonable postage didn’t have stock of Pi 4 models) which resolved that issue.

After a few months of using it every so often I was finding it ok for my purposes as a UPnP/DNLA browser and player, but I was unhappy with:

  • The odd way that Kodi would browse the UPnP share, it would display them all with a year of 1969 (aka zero in unix epoch) and put everything in alphabetical order, not folders at the top like is typical.
  • No way to power off the Pi, you can shut it down but it can’t wake up, to do that you need to power cycle it. Not what I wanted for something I might use a couple of times a month where I wanted the convenience of everything through my existing universal remote control.
  • It took me a while to work out what the controls were, which wasn’t helped by being limited to the set of commands my television would send over HDMI-CEC, and it seemed a bit laggy.

Chromecast with Google TV

While the Pi with Kodi was working fine for my occasional needs, a bit over a month ago I cam across something talking about the newer Chromecast, not the one that I already had, but the “Chromecast with Google TV” which looked like quite a nice Android device for a very good price, so I picked one up.

Like my previous Chromecast (which I still have in the cupboard) it was quite easy to set this one up, the remote control was nice and responsive and it didn’t take me long to install VLC and browse my media. As I used it I started to dislike it more and more…

  • You can’t get rid of the ads. Even though I uninstalled the included apps and switched to the app only mode, the minimal I could get the home screen down to was three ads and the icon to start VLC
  • You can’t configure overscan. I understand that on newer televisions you can turn off overscan on HDMI inputs, but not on mine and the Chromecast doesn’t have any configuration (like there is with Kodi) so I was stuck with missing edges. Not that noticeable when watching a movie, but when the menus are chopped off…
  • Google Assistant. I’m not comfortable with a microphone under the control of Google, it should only activate when you press the button and I was pleased to find that app only mode should disable it, but I was still uneasy
  • Remote control. While the bluetooth remote is nice and responsive, it isn’t that comfortable to hold and I couldn’t get it to reliably turn off my television by HDMI-CEC or IR. Being bluetooth I couldn’t use my existing universal remote, and I don’t fancy spending $$$ on replacing that with a hub type remote.
  • Signed in to Google. Unfortunately this is expected these days, but you have to be signed in for it to work, it can’t operate as a standalone media player
  • Wifi. While the wifi is convenient, I have wired ethernet at my television, so it would be good to be able to use that. Yes I know you can buy an official wired adapter or go the USB-C dongle route…
  • VLC for Android needs more work. I understand that this version of VLC is still new, but it was too glitchy (eg would jump when scrolling through a list of files, or jump to an odd place when returning from playing a video) for me to use as an (almost) out of the box solution

Returning to Kodi on the Pi

The more I was using it the more I realised that I preferred running Kodi on the Pi as I didn’t need to be signed in, I could just plug it into the wired ethernet at my television. So made sure to return the Chromecast within 30 days for a change of mind refund. The one feature that I will not have with Kodi is the ability to cast a livestream, but I do still have the older Chromecast…

Once I had Kodi running again I started to look into the issues I had with browsing over UPnP. I quickly learned that the recommendation is to simply not use UPnP, to instead share over the network using HTTP, NFS or SMB… Ah, why was I fixated on UPnP? I am constantly accessing the storage on my Linux box from Windows via SMB, how did I not think of using that? And yes it is the right option, the ordering is what you expect, I get file sizes, it even gives preview thumbnails and video resolution/codec information.

So now my remaining issue was the convenience of powering the Pi on and off, there are lots of open source projects based around a Pi, surely someone has designed something I could build? I was also aware that I could add an IR receiver directly to the Pi, that might be better than relying on HDMI-CEC for control.

I was kicking myself again as it didn’t take me long to find the RemotePi Board, an infrared remote controlled power switch for the Raspberry Pi that will work with LibreELEC/Kodi and also give me an IR receiver to control Kodi.

At half the price of the Pi itself there are people I know that would consider this too expensive, but for a ready made solution it is perfect for me so I placed an order. As the pricing was in EUR I assumed it was coming from in Europe, instead they are based in Thailand (it does say this on the ordering/shipping page) and it took three weeks to get here, yay for inconsistencies of international shipping!

The good news is that the RemotePi arrived today and I wasted no time in installing it on the Pi, following the instructions to add the startup/shutdown scripts, telling it to enable the IR receiver for an MCE remote control and then reconfiguring my universal remote control to know about a MCE device.

It is already so much more convenient. I can pick up the remote and select the “Kodi” activity which will turn on the television and the Pi, It takes about 20 seconds to fully boot and I can then browse to a video to watch. Once I am done I can then hit the off button and the remote will turn off the television and tell the Pi to shutdown. Very nice!

but what about…

It would be remiss of me if I did not mention that during all of this there are other media players that I looked up. There are a bunch of cheap Android TV based devices, there are the Amazon Fire ones, there is the Nvidia Shield, there is the Apple TV, etc… Some of these are quite expensive, some are reported to be of poor quality and some are biased towards particular services. For me there is something that feels right about opting for an open source solution, not just that it does what I want for the least money…

My final note is that earlier I mentioned my parents who have a (newer than mine) Samsung TV with apps for ABC iView, SBS on Demand and some others. These apps have been painful in getting updates in the past, so I can imagine at some point I will recommend they they get the Chromecast with Google TV as that does seem to fit their use case quite well.

Tagged with: , ,