Latest blog entries

Fifty-two weeks of food in boxes

Sunday, July 25th, 2021 at 5:08 pm

Almost a year ago I posted about getting meal ingredients delivered in boxes. That was after five weeks, so this is the fifty-two week update:

Fifty-two weeks of food in boxes

My position on it is pretty much the same as it was last year, it might not be the most economical way, but the variety I get for the convenience is worth it. I have found that I am much more selective with their menu, it is rare that I am happy with the automatic selection, I am going in to each week and adjusting the selection based on preferences and some failures.

One notable failure involved parmesan. You know how cheap parmesan smells like vomit? Well the parmesan provided is ok when you mix it into the dish at the end of cooking, however there was one meal where the parmesan was baked to make parmesan crisps. This was a mistake, it stunk out the entire kitchen, that went straight into the outside bin and I had the meal without the crisps.

Another failure of a sort is that I haven’t been happy with any of the Indian curry meals, they don’t seem to have enough flavour enough for me, it is as though they are not suited to a quick cooking time. There are other meals that have a spicy warning on them which I ignore, it is as if they are targeted at a broader audience.

Undercutting all this is the knowledge that this only works for me because I am working from home. Despite the convenience of working from home I still miss going into an office, if only for the random conversations we would have over lunch…

Tagged with:

RAVEn to MQTT over wifi

Saturday, July 10th, 2021 at 1:29 pm

I have written before about how I use a Zigbee dongle (the now discontinued RAVEn from Rainforest Automation) to get power consumption information from my smart meter. A bit over two years ago I also wrote about how it appeared that a failing power supply was interfering with the Zigbee connection and also confusing my UPS.

I think that my logic still holds for the UPS issues, but now I think I was wrong about it interfering with Zigbee…

Things improved when I rewrote my script to use a proper serial port library and then improved even more when I started to use that library correctly. However recently I noticed that there were still some gaps appearing in the power usage data, so I had another look.

My first action was to further cleanup my script so it both made more sense and to also report on more messages. I was only caring about InstantaneousDemand which is sent every 8 seconds, but it also often sends CurrentSummationDelivered and ConnectionStatus which I was ignoring.

Once I started logging ConnectionStatus I thought I might be seeing a pattern. At the times (for an hour or so every few days) that I stopped getting InstantaneousDemand messages, all that it was getting were ConnectionStatus messages, and the LinkStrength values were around 60 or 70, not the 100 it normally way.

So was something still interfering?

I couldn’t spot a regular pattern in the dropouts so I had no idea what possible interference there might be. The information about the RAVEn and other smart meter in-home displays mentions that placement of the device is important as Zigbee is low power. I had the RAVEn plugged into the back of my linux box which placed it about 10 metres from the smart meter with walls, furniture and the metal case in between. So what if I simply moved the RAVEn closer?

I had a long USB extension cable so it didn’t take long to relocate the RAVEn to be about 4 metres closer and not directly behind a metal box. After a week in this position I found that there was still the occasional reconnection, but nothing like the hours of no InstantaneousDemand messages that I was seeing before.

I could have just left the USB extension cable in place, but I didn’t like how it looked and didn’t want to add it to the mess of cables under the desk.

The RAVEn is a USB device that provides a USB serial port, on that port are XML messages. My script takes those XML messages and writes them to MQTT as JSON. Is there something else that I could plug the RAVEn into to do this, something that I can place close to the smart meter?

I’m a fan of using ESP8266 devices in the D1 mini form factor for my current home automation. Could I use one of these to build a RAVEn to MQTT bridge over wifi? Maybe, but with some caveats and possibly some effort and delay waiting for parts.

Other Arduino based options seemed just has hard so I turned to the old Raspberry Pi I had sitting around. I had previously used this to test out Kodi so I instead loaded up Raspberry Pi OS Lite and quickly found that I could transfer my existing perl script over, tweak it a little bit, and have it working.

The next hurdle with this as a solution was that it used wired ethernet and I don’t have wired ethernet in the room near the smart meter, I would need wifi if I wanted to have the RAVEn as close as possible.

What would it take to add wifi to this Pi? A USB wifi adapter can be used, but which one and how much would that cost? Would a cheap $8 adapter work, or would I have to get a $50 adapter? As well as not working, it might take a while for a cheap adapter to be delivered.

What about a newer Pi that included wifi? The Pi 3 B+ that I am using for Kodi has wifi even though I am using it on a wired connection, but that also costs towards the $60 mark, and seems to be out of stock.

Hold on, what about a Pi 3 model A+? This is smaller and cheaper than a B+, it also has wifi and the single USB port is fine for my single RAVEn. An online order and a few days later it arrived and was quick to get functional:

Rasperry Pi 3 model A+ in a Core Electronics Slim Case and a Rainforest RAVEn plugged in to the USB port

I needed a case for protection and liked the exposed look of the slim case from Core Electronics.

This has been running like this for about 36 hours now, taped the wall which puts it about 1 metre from the actual smart meter. Time will tell if this solves the reliabilty issues, but it is looking promising.

Of course this does seem like a bit of an overkill to use a whole Pi for this simple task. I might consider a Pi Zero, but I would need the W version (for wifi) and when you include the USB OTG cable the price is getting closer to that of the A+, and these are sold out everywhere I checked…

The final thing I want to mention today is that after I cleaned up my script I also wrote up some documentation and pushed it up to GitHub:

Just don’t yet look at my other repos as all you will see are two that were created seven years ago, only one of which has any code pushed to it. One of the items buried on my todo list is to clean up and push some of the other things I have written for my home automation setup…

Tagged with: , ,

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

Update: Force resolution

After working fine for many weeks, LibreELEC/Kodi started only running at 640×480, I tested with another Pi and something seems to have changed with my television and it wasn’t detecting the resolutions correctly, to get around this I force the Pi to boot up with 1920×1080 by adding the following:

config.txt

hdmi_group=1
hdmi_mode=16

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: , ,

Has it really been a year?

Tuesday, March 16th, 2021 at 10:34 pm

Today marks a full year from the first day that I started working from home. Like many others I have spoken to, my sense of time is broken. While I have definitely settled into a routine it still seems like it is only new and temporary, even the last six months don’t seem like they have existed.

Our office has reopened, but with reduced capacity, spaced out eating and no use of the meeting rooms or lunch area. A couple of people are going in once or twice a week, but most of us don’t see the point of the commute just to work by yourself.

The Comedy Festival starts next week and while I haven’t booked in as many shows as I would have in the past, I’ve got a lot booked. It will be strange to be working from home and then heading into the city most nights of the week…

Tagged with: ,