Sunday, January 05, 2014

My Digital home - 2014

Several years ago back in 2008 I wrote about my digital home , and thought it would be interesting to write an update.

The house is wired with cat5 networking with gigabit switches. This supports the core data network as well as the 1-wire senor network and a couple of phone extensions.

Media

The hub of my home from a media perspective is still my Mythtv server, which has been running on various hardware platforms since may 2003, and has been progressively upgraded. You can see the stats below

The Mythtv backend now sits on a Raspberry Pi with a twin tuner freeview TV USB stick.

The main tool for watching recorded programmes and Live TV is now XBMC rather than the Mythtv frontend.

XBMC runs on the android phones and tablets around the home, and also on a Raspberry Pi connected to the main TV. Mythtv frontend is installed on my ubuntu powered laptop for the odd occasion I need that functionality. Setting and managing recordings is all done via the Mythweb client shown above. There is an event set to tweet when a recording is completed


I have had my music stored as MP3 in a library and accessible since the late 90s, and movies and TV shows since 2003. All are accessible though XBMC and the myth frontend as recordings above.

Music is also available from a web front end jukebox called Ampache.

This allows me to access and play anything from my music library from any Web browser. the music can be streamed or played locally on any of the Raspberry Pis in the house. I also just a music client called Justplayer on the Android devices for accessing the Ampache library.

Monitoring and Control

Energy Monitoring

I have a OpenEnergyMonitor system which consists of an arduino based  transmitter station constantly monitoring the electricity usage and sending to a receiver (Nanode) which then uploads into a Mysql database. The data is available via a web interface. All hardware and software is completely open source, so no nasty data lock in to corporations
The EmonCMS dashboard

The EmonCMS energy Explorer showing electricity usage
The power & temps showing for the house

Also hooked into this server is a network of small 1-wire sensors which are built into RJ45 plugs and plugged into the network in each room. The data from these is recorded by EmonCMS above and also by my home automation app

Home automation

The home automation app is described at some length by me here, and the only two major differences are that it now monitors the heating and triggers a device activation when a temperature threshold is reached. This allows me to record when my heating is on and off. The second is that the system now sends a tweet whenever a device is activated or deactivated
In addition, every hour the system tweets the days power usage and current temperatures in each room as well as outside.

Weather

I have a WH-8081 weather station (available from Clas Ohlson & Maplin etc) with a wireless display.
Data from this is harvested by a Raspberry Pi running Pywws, and uploaded to Wunderground and summary data available on my website.
Data is also tweeted hourly
along with a 12 hour forecast




Mythtv backend running on a Raspberry Pi


Disclaimer! the Mythtv devs have always frowned on the idea of low powered boxes like the Pi running the backend due to the load when rescheduling. In practice I have found it very useable on a dual tuner box only recording freeview which is about 30 or 40 channels. Any advice and guidance here is absolutely unofficial and neither me or the mythtv devs can be responsible for anything not working as advertised

Since my AMD64 based media centre which was used as a combined backend/frontend for Mythtv died suddenly I have rebuilt the system around a Raspberry Pi backend with recordings being viewed on either XBMC on Android tablets or a Raspberry Pi running RASPBMC. The power consumption has dropped from about 100w to about 5w so a large saving.

The Backend is on a RPi with a Kworld USB TV tuner stick, and a 1.5TB hard drive in an external case. The backend currently runs 0.26.

Movies, TV shows, and music are all stored in directories which are available across the network as either CIFS (windows) or NFS shares. These are accessible from Myth frontends and XBMC.

This blog is a run through of what I did to set up the backend on the Raspberry Pi

What you gonna need

  • A Raspberry PI 
  • A class 10 SD cards. My backend uses a 16GB and the frontend an 8GB
  • A Powered USB Hub. the new PiHub from Pimoroni will be about the best if you are after a new one.
  • 1 or more External hard disks for the backend storage.
  • A Usb TV tuner. The Kworld one from Maplin's in the UK works great for me and others. If you are going to use an alternative then research carefully. I had a Terratec from ebay and could not get it to work. Check the RPi compatibility list carefully
I also use a Microsoft MCE remote control, which worked out of the box with RaspBMC. Some TVs work with the CEC pass through which is great, although mine doesn't as it is a few years old now..

Installing the Backend

To install the Mythtv backend, first download and install raspbian onto the RPi.
Make sure you use a validated Class 10 SD card. I'm running  a 16GB card which is fine.

Before you install Mythtv, ensure that IPv6 is enabled on the Pi. Otherwise when the backend is installed and started it will immediately fail.

To start IPv6 enter the following command sudo modprobe ipv6
Add ipv6 as a new line to /etc/modules to ensure it is started automatically at boot.

Luckily Jalto on the Raspberry Pi forums has already built a set of packages for Mythtv and Raspbian.

In a nutshell, download and extract the package to the root of the filesystem

cd /
sudo wget http://dl.dropbox.com/u/4581144/mythtv-rpi_packages.tgz
sudo tar -zxvf mythtv-rpi_packages.tgz


Add the following line to /etc/apt/sources.list, using your favourite text editor. Note that you will need to sudo this (e.g. sudo nano /etc/apt/sources.list)

deb file:/mirrors local local

Update Apt

sudo apt-get update

Install the Mythtv backend.  We don't need the frontend or most of the plugins, so leaving them out saves some space, and saves on needing to install an X server.

sudo apt-get install mythtv-backend

All the other packages such as MySQL should be installed automatically as well.
Note that when MySQL does install you will need to provide a password for the root SQL account.  Make a note of it and keep it safe.

I found that everything installed happily except for Mythweb for some odd reason. No one else on the forums has mentioned it, so it may be an oddity for me.

Once installed you will need to set Mythtv up, which is done using the mythtv-setup app.  There are many good guides on how to do that, not least on the Mythtv wiki itself, so I'm not going to give much more than a quick overview.

Rather than do that locally, I ran it on my Ubuntu powered laptop via remote X using the following command, just as the user (use the correct Ip for the backend)

ssh -X pi@000.000.000.000 /usr/bin/mythtv-setup

It ain't very quick, but it does save on installing and starting X on the RPi itself, which is an advantage if the backend is just hidden in a corner.

There are 7 sections.

1: General
Here you will need to enter details such as the Ip address, Tv format (Pal in the UK). Most other settings can be left as default. I would disable transcoding and advert detection jobs as these can be cpu-heavy.

2: Capture cards
Here you will identify the capture cards used by Mythtv. Add a new capture card and set the type to "DVB Capture card". Myth should then detect the available cards of that type and allow you to choose.

3: Recording profiles
Leave these settings at the default.

4: Video sources
you will need to create a new video source. You can either use EIT, which is basically the over the air programme guide delivered as part of the freeview signal, or XMLTV. I use XMLTV configured to pull data from the Radio Times site in the UK. This gives me 14 days of programme data and is updated daily. Just select the grabber and then finish.

5: Input connections
Mythtv can have tuners for differing sources (freeview, freesat etc) and can also have different data sources. This section is where you marry up the tuners to the video sources. you can also set the starting channel number and scan for channels. on the second screen you can set tuner priority should you wish to.

6: Channel Editor
This (surprisingly) is where you can set the channels including the numbers and Ids etc.
For a first time setup, perform a full scan. there is information and some sample scripts on the Mythtv wiki to make this easier. I find it easier to do a full scan and then manually enter the XMLTV ids from the channel.ids file found in /usr/shared/xmltv/tv_grab_uk_rt/
You will also need to create a text file with the file name format freeview.xmltv in /home/user/.mythtv and enter each xmltv id on separate lines. It is this file that mythfilldatabase uses to determine which channels to grab data for. This process is a pain in the arse frankly, but only needs to be completed once. you will also want to run the icon grab, and possibly change the channel numbers to suit your own desires.

7: Storage directories
In this section you will need to enter the directories where the Mythtv will store and find the various files. Most are obvious apart from possibly default, which is where the directories for storing recordings are located. You can enter multiple directories per group.

8: System Events
This section can be ignored for now. It's for triggering custom actions based on events such as recording start or end

Once complete exit the Setup program, restart the backend and you should then be able to connect either via the Mythfrontend client,, XBMC, or the web client for managing Myth.