Metoffice Observations in OpenHAB

The article explains how to access MetOffice Observations in OpenHAB via the JSON API they provide. In the UK the MetOffice offer free weather observations and forecasts via their DataPoint service. This could be used for a variety of rules relating to external weather conditions.

To obtain MetOffice observations in OpenHAB you’ll first neet to get an API key from the MetOffice datapoint service by registering with them.

Once you are registered and logged in grab you API key from the link on the right and you’ll now need to find your site location using a query (just enter it into your browser) such as

You’ll have to manually find your closest site from the list of 140 or so. My nearest site is Filton – so I will use ID 3628.

The MetOffice current supply the last 24 hours of data. To get the last 24 hours of observations we will use a URL such as (replacing 3628 from with your location)

Once you have working URLs you should get a load of JSON data ready to feed into OpenHAB.

First you’ll need to setup your transform. Create a new file in the configurations/transform directory. I called mine metofficeLatestObsTemp.js. Copy the following into it.

var metofficeData = JSON.parse(input)
metofficeData.SiteRep.DV.Location.Period[metofficeData.SiteRep.DV.Location.Period.length-1].Rep[metofficeData.SiteRep.DV.Location.Period[metofficeData.SiteRep.DV.Location.Period.length-1].Rep.length - 1].T

You can replace T with any of the data types listed in the metoffice documentation to get other information such as wind speed, direction, humidity, etc.

Next you’ll need to configure your OpenHAB item. I used the following line:
Number house_heating_externalTemp "External Temperature [%.1f °C]" (persist) { http="<[]"}

You can now add this to your sitemap and display it in the openhab interface.


Posted in Home Automation, Howto | Tagged , , , | Leave a comment

Home Automation: Integrating Salus RT500 RF in OpenHAB using a Jeelink

We recently had a new boiler fitted with the Salus RT500RF controller. I’ve been playing around with a lot of home automation recently involving LightwaveRF, RFXCom unit and OpenHAB. Having temperature monitoring in my lounge and bedroom I really wanted the option to be able to control the boiler allowing the OpenHAB control system to decide when to enable the boiler based on factors such as room temperature, time of day and outside temperature.

Continue reading

Posted in Home Automation | Tagged , , , , , , , , , , , , | 4 Comments

Accessing partitions within an image or LVM volume used as an iSCSI target

I recently reinstalled the software on my NAS (open media vault) and tidied up the host name etc. As part of this I changed the name of the iSCSI target. This meant that my media PC wouldn’t boot over the network (I set it up using XBMCbuntu using this guide – To solve this I managed to mount the partition on the NAS server itself and modify the necessary boot parameters.

To mount it I did the following:

  1. Install kpartx:
  2. sudo apt-get install kpartx

  3. Create a loopback device. This create /dev/mapper/loop0pX where X is the parition number
  4. sudo /sbin/losetup /dev/loop0 /dev/mapper/Target-LogicalVolume

  5. Mount the parition:
  6. sudo mount /dev/mapper/loop0p1 /tmp/iscsi-target-mnt

The reason I created the loopback device was because I kept receiving these errors:

$ sudo kpartx -a /dev/mapper/Target-LogicalVolume
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume1
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume2
device-mapper: reload ioctl failed: Invalid argument

Credit to for pointing me in the right direction.

Posted in Home Network, Howto, Server Admin | Tagged , , , , , , | Leave a comment

/dev/md0 can’t read superblock

Sometimes when my Stora NAS gets rebooted the array fails to mount and I get

/dev/md0 can't read superblock

To correct this I do the following:

  1. Try mount /dev/md0 (you probably tried this and got the above error)
  2. Do xfs_repair /dev/md0
  3. If that refuses to repair then do xfs_repair -L /dev/md0

No guarantees this won’t screw things up for you but it works for me.

Posted in Home Network, Howto | Tagged , , , , | Leave a comment

XBMC Frodo for Legacy AMD Graphics Cards (pre 5xxx)

Apparently AMD/ATI graphics cards less than 5xxx series have been left behind in the latest drivers. This is a bit of a pain for me as I have a 24xx series in my media PC. I tried the stock XBMCbuntu 12 ISO for AMD, but this left me with a non-working system. Going back the XBMCbuntu 11 and then doing a manual package upgrade seems to work:

sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc xbmc-bin
sudo apt-get upgrade

This upgrades everything, but keeps the base ubuntu install – so we get to keep the video drivers.

Posted in Home Network, Howto, Projects | Tagged , , , , , , , , , | 1 Comment

Carbohydrates, Glycogen and Weight

I saw in a forum post that glycogen stores can affect weight in quite a significant way. A quick search caused me to stumble across the article link below. It’s an interesting and enlightening read – and encouraging, especially after the festive season!

Understanding body weight and glycogen depletion

Posted in Interesting Articles | Tagged , , , , , | Leave a comment

MediaPC in a Xen Virtual Machine

The aim of this project was to get my MediaPC running as a VM host. This would allow me to run instances alongside my MediaPC, thus giving me a platform to experiment and develop things without having to setup separate machines etc.

I decided to use Xen on Ubuntu and found the Ubuntu Xen guide very useful.

Note: I never got this working – this is just documenting what I did and how it failed.

Continue reading

Posted in Howto, Projects, Virtualised Media PC | Tagged , , , , , | 1 Comment

Breaking the Ice on 50m Pools

The last week hasn’t been particularly exciting (except for today!). I have had the week off as I have had a cough – I stopped training as soon as my glands went up, it is my usual cue that something is about to go awry.

Today I was feeling better so I decided to head over to the new Hengrove pool this morning as it operates in its 50m configuration on Saturday mornings and I thought it would be a bit of a treat.

I haven’t done a solo swim for a while now as I have been just training once a week with BadTri – though I haven’t been the last two weeks due to illness / having stuff the evening before that meant I was back late.

Cycle computer showing -1.0 deg C

-1 deg… yeah I didn’t know it did negative!

After a very chilly cycle 25 min to Hengrove (my cycle computer is usually a bit optimistic with the temperature!) I entered the 50m pool.

It turns out 50m feels like a long way when you are used to 25m pools. There was definitely a psychological barrier about the thing – once I had warmed up and gotten used to the lap distance it I did a steady 1000m set and then did a gentle mixed warm down. It was tiring – I just felt I wasn’t generating power and was fatiguing quickly (maybe because I hadn’t had a good breakfast – only a banana), and it took me a while to get back used to the water. Seems two weeks is a long time to be out the water.

50m swimming pool with lanes

50m is a long way!

It was very quiet when I went, I don’t think there were more than three people (including me) in my lane at any point, and you very rarely meet them as the pool is so long! I quite enjoyed the 50m experience – I wonder what the transition back to 25m will be like.

The other exciting thing is that I have ordered my turbo trainer and ANT+ kit so I can get it running with TrainerRoad. I am really looking forward to thrashing out a few sessions over the coming months – hopefully getting my bike power up! Reviews to follow…

Posted in The Story, Week in Review | Tagged , , , | Leave a comment

First Triathlon: Tockington 2012

K2 Events Logo

After ~16 weeks of training – covering 765.8 kilometers over 49hrs 19mins 23seconds and consuming 46,718 calories I made it to the start line of the Tockington 2012 Triathlon – my first triathlon.
Continue reading

Posted in Races, The Story | Tagged , , , , , , , | Leave a comment

Indefero errors fatal: bad argument fatal: The remote end hung up unexpectedly

I was trying to commit something to my Indefero project management server today and was getting the following error:

fatal: bad argument
fatal: The remote end hung up unexpectedly

I puzzled around for a while and then tried manually logging into the git server using a console SSH and was greeted with this:

$ ssh
PTY allocation request failed on channel 0
PHP Deprecated: Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/mhash.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20090626+lfs/’ – /usr/lib/php5/20090626+lfs/ cannot open shared object file: No such file or directory in Unknown on line 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to closed.

Those PHP errors are probably throwing Git off course and making it unhappy. The solution was two step:

  1. Edit /etc/php5/cli/conf.d/ming.ini to ensure that comments are pre-ceded by ‘;’ and not ‘#’
  2. Move mhash.ini out of  /etc/php5/cli/conf.d/ as as it is no longer used in debian (see

Doing the above two steps resulted in a clean session opening up when ssh’ing into the git server:

$ ssh
PTY allocation request failed on channel 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to closed.

Now pushing to the Git server works – yay!


Posted in Howto, Server Admin | Tagged , , , , | Leave a comment