Control Panel and more!

As the weather is still terrible around here, I spent the weekend working on my home automation. A load of general maintenance such as replacing batteries and fixing broken things like the integration with the burglar alarm.

I also added a few new integrations:

  • DVLA Link – This lets me query details about our cars, and more specifically the due dates for MOT and insurance.
  • Waste Management – Link into the local government to know when and what type of refuse collection is coming up.

But, the most fun one was finally getting the 10 inch display and Raspberry Pi mounted on the wall as a custom control panel!

I’ve had it sat on my desk for about six months and decided it was actually time to get it done. I had to CAD up a box for wall mounting and hiding the electronics. Not the best design, and lots of things to improve, but its functional.

A quick couple of holes in the wall, and it was mounted.

Once I have the local voice assistant details finished, this will get that installed too. That will need a redesign of the case to support some speakers and volume controls. The actual dashboard needs a bit more work, and possibly an LCARS theme as an option.

But at least its off my desk and working now. Very handy for a quick glance at the calendar, weather, alarm status, and also to view the front door camera.

Move to wordpress

Well, I’ve been meaning to do it for a while. I’m a big fan of Drupal, but for this website something as fully featured as Drupal is a bit overkill. So, to simplify things a bit I’ve moved over to WordPress. I blame it on being sat in an apartment in washington with nothing better to do!

The install went really well. Straight forward, and after finding a handy website with some instructions for migrating from Drupal, I had all the old content moved over too. Start to finish took all of 30 minutes.

My Android G1

Well, I’ve had my Android G1 phone for a little over two months now and thought I’d write up my findings, and also put together a few tutorials on what I’ve done to my phone.

From day one, I’ve been impressed with my phone. I can’t comment on how different the cupcake (1.5) software is different from previous releases as mine came pre-upgraded, but from all accounts it was a major step forward. I have since rooted my phone and put some experimental builds of the operating system on it with fantastic results.

Once I’d uploaded my contacts to gmail, the phone automatically synced up with my account so all my contacts were available within a couple of minutes. I would’ve liked to stay using my own syncml server in egroupware, but google does make things a whole lot easier, as well as being a little more reliable than my home broadband! Also included in this sync was any calendar entries.

The general feel of the phone is quite nice, with the smooth touch screen interface working well. Not as slick as the iphones that I have seen, but then it is a lot cheaper. About the only criticism I have had with the phone is the abysmal battery life, this however has been fixed as I will mention below.

After using it for a few days, trying various applications from the market, and generally doing the usual new phone things, I decided it was time to break it! First on the agenda was rooting it. Underlying everything it is a Linux distribution, with all the geek fun that that entails. Rooting gives you access to the internal flash and allows you to do all sorts of fun things with your phone, most important to me was the ability to upload custom ROM images. A good guide to rooting your G1 (along with a lot of useful information) can be found at the xda developers forums.

After a bit of hunting around, I found what seemed to be one of the best ROM images to try buy a guy known as JesusFreke. Putting a custom ROM on your G1 once it has been rooted is a piece of cake. Simply drop the ROM image (update.zip) onto the root of an SD card, boot up the phone whilst pressing home and power which will drop you into a boot loader from which you can flash with the new ROM. Occasionally you will have to wipe all information from the phone, but that’s what backups are for!

Custom ROM images tend to have a few extra applications built in, and little tweaks here and there. Most importantly they do tend to improve the poor battery life. I ran with the JesusFreke ROM for a few weeks quite happily, until I came across another ROM image that seemed even more fun.

Whilst looking for info on the Android Donut release, I came across a guy called Cyanogen who had been back porting a lot of the new experimental Donut code, back into Cupcake. This included things like extra widgets, speed improvements, updated apps, and battery tweaks. I downloaded the latest experimental ROM and flashed my device with it. I’m glad I did. Battery life for me had started around the 5-6 hour mark when I was being conservative with phone usage and things being turned on. With JesusFreke that had extended to maybe 7-8 hours. Putting Cyanogen’s new ROM on has just about doubled the battery life. I’m easily getting a full days usage out of the phone without having to power save by turning wifi and bluetooth off constantly.

I’ve just put the latest version on (3.9.11.2) which now includes the global search function demoed at the Google IO conference earlier this year. One search bar will now search the internet, contacts, market and applications, with more applications tieing in as they are updated. Also included by default is apps2sd which installs apps to your SD card to save phone memory (if you partition your SD card correctly), linux swap on SD (again if your SD card is partitioned), compcache which greatly increases cached items performance, as well as so many performance increases you won’t believe the speed difference from the standard ROM.

All in all, the standard G1 is a great phone, just let down by poor battery life. A rooted/modded G1 using Cyanogen’s experimental ROM is probably the best phone I have ever had. If you have a G1 still running the stock ROM, all I can say is it is worth biting the bullet and getting a custom image put on it. Yes, there is a risk of turning your phone into a rather expensive plastic brick, but in my opinion it is worth it.

Hopefully I will write up a guide to how I’ve updated my phone incase anyone wants to do something similar. Also, I’ll probably have to do the obligatory list of apps that you should need!

Dell and Linux FAIL!

Well, my laptop is playing up and getting a bit old so I’m in the market for a new one. I only want to buy one with Linux pre-installed, not for any anti-Microsoft reasons as such but just so that it can be noted that there is a market out there for Linux computers. My current laptop was bought from Dell with Ubuntu installed on it, which has done me well for the last few years, so I decided to give them my repeat business. Checking their Linux website shows no current devices available, so I decided to try and contact them to see if there were any future plans.

First off, when trying to contact Dell for any reason, they don’t supply an email address! I find this most bizarre as I don’t necessarily want to phone, snail mail, or chat online with a sales person. I bit the bullet and went to the online chat to ask the question and here is the conversation:

 

13:46:21 Customer Darren Poulson Initial Question/Comment: Are you going to be offering any more linux (ubuntu) systems? I need a new laptop and would rather buy one linux installed
13:46:51 System System You are now being connected to an agent. Thank you for using Dell Chat
13:46:51 System System Connected with rayees_fatima
13:47:01 Agent rayees_fatima Thank you for contacting Dell Sales Chat. This is Rayees Fatima, your Sales Advisor. Please give me a moment while I review your query. In order to serve you better, may I have your telephone number&email address, just in case of disconnection I can either call you or email you back. My email address XXXXXXX@dell.com and direct dial number XXXXX Ext: XXXXX
13:47:06 Agent rayees_fatima no

So, a one word response from their sales team. I guess they must be very, very busy and don’t have the time to answer properly. Granted, they did actually answer my question, but a two letter answer is rather abrupt.

Needless to say, they won’t be getting any repeat business from me, and seeing as I generally get asked for advice on buying laptops and desktops they’re probably going to be loosing a bit more business too. Time to find somewhere else that sells linux laptops!

Sony E-Book Reader + Linux

Guess what, I’ve got another gadget! I decided to take the splash and get one of the new Sony ebook readers, the PRS-505. I’d heard a lot about the e-ink displays, but never seen one in real life.

Well, so far I’m impressed. The resolution is fantastic, very readable in just about any light, infact it is pretty much just like reading a real book. Even better, it plays very well with Linux due to the fact that the reader itself, along with any memory cards inserted, act as a simple usb mass storage device. Plugging the reader into my laptop simply opens up the drives in seperate windows meaning I can just drag and drop any supported document. Of course, some formats work better than others. TXT and RTF files are the simplest format and work well, tho there are no chapters or any other fancy information. PDFs are more or less usable, tho they usually need to be zoomed in which ruins the layout. The best format that I’ve found so far is LRF which is Sony’s binary format for the PRS-500 and PRS-505.

 

This is all well and good, but there is a better way to move the files over, and also convert different formats. Calibre is a free python program which acts as conversion software, ebook library, and will also copy the files to your reader. Installation under Ubuntu is extremely straight forward, just run the following:

 sudo apt-get install  python-setuptools python-imaging  libqt4-core libqt4-gui \
                      python-qt4 python-mechanize imagemagick \
                      xdg-utils python-dbus python-lxml python-beautifulsoup \
                      help2man
sudo easy_install -U calibre
sudo calibre_postinstall

Instructions for installing on other systems (including Windows and OS X) can be found on the Calibre download page.

The library functionality lets you add any ebooks that you have and search for cover images, the ISBN, publisher and sometimes a brief synopsis. The conversion software will allow you to convert any type of supported file into either EPUB or LFS, even automatically detecting chapters in TXT and RTF files. Finally, once you’ve added your books and converted them to your prefered format, simply plug your reader in and click the copy button. Once the files have been copied over you can unmount the filesystems and read the books on the reader!

Conversion settings that I recommend are to convert all files to LFS format with 8pt fonts and 2pt spacing which is fine for me, but can be zoomed in if you want bigger print. Also, I like to insert a blank line between each paragraph to make the text more presentable. Lastly, I make sure that the chapter detection inserts any chapters found into the table of contents. So far I’ve found that these settings work with just about all my files. I’ve still to mess around properly with PDF files to find the best results for these.

Before converting any files, make sure that you have filled in as much of the information as possible for the book as some of this information will be included in the converted output making organisation a lot easier on the reader, especially if you fill in the series information to group books together.

All in all I’m glad I bought the reader. I think it will come in very useful, tho’ there are a few things that I hope will be improved on in future versions. One of which is a larger screen. The reader is about the same size as a standard paperback, which is fine, but the screen doesn’t fill the whole device. Sony could easily do away with the big round buttons on the bottom edge and make the screen a fair bit bigger which would improve the reading of PDF files no end. I’d also like to see slightly better contrast on the screen to make it more book like. As it is the background is grey and the black isn’t exactly a deep black so it can look a little washed out. I may be nit picking, but isn’t that what the net is for?! Of course the benefits definitely outweigh these couple of problems. Battery life so far seems phenominal, with the battery meter not moving off full charge yet! Supposedly I should be able to do about 6800 page turnsper charge, seeing as the e-ink technology only uses power when actually changing the screen. So far I’ve read a couple of books on it and not really noticed that I was reading a screen rather than a standard book, only noticing when my hand slipped and the cover closed without losing my place!

Well, hopefully I’ll get PDF files playing happily soon and then it will be pretty much perfect. In the meantime, it came with 100 free books, and I’ve been scowering project Gutenberg to find some books to read. Should be enough to keep me going!

Darren

Migrating Serendipity to Drupal

I’ve just finished moving my blog from running on Serendipity to a Drupal installation. Drupal seems a lot more stable and more customisable. Serendipity was only really a blog, but Drupal is a full content management system so I thought it might be a better idea to learn how it works!

Of course the trouble is I have quite a few articles written in serendipity and I needed to be able to transfer them easily. After searching around on the net, the only reference I could find was a dead link to an SQL script. Oh well, guess I’d better write my own. Read on for the instructions.

The main assumption here is that both Drupal and Serendipity are on the same server, with the same database. Its not a big deal if they are on different databases, its just that mine were and that how I’ve done the script. The other assumption is that all the articles are by the same user, and that they are all going to be going under a single user on the Drupal installation (UID 1). If you have multiple users, then it is still possible, but it would add another layer of complication to the script. If anyone needs some help, just give me a shout. Lastly, there should be no stories already in the Drupal database (ie. a fresh install)

In this script the Serendipity tables are prefixed serendipity_, and the Drupal tables are prefixed drupal_. In Serendipity, all the content is stored in one table, entries, whilst in Drupal they are split across two tables, node and node_revisions. Below is the script that will take all entries from serendipity_entries and place the relevant information in the correct tables for Drupal. The commands can be either run via the mysql command line, or in phpMyAdmin.

INSERT INTO
   drupal_node(vid, type, title, uid, status, created, changed, comment, promote, moderate, sticky, tnid, translate)
   SELECT id, 'story', title, '1', '1', timestamp, timestamp, '2', '1', '0', '0', '0', '0' FROM serendipity_entries;

INSERT INTO
   drupal_node_revisions(vid, uid, title, body, teaser, timestamp, format)
   SELECT id, '1', title, extended, body, timestamp, '2' FROM serendipity_entries;

Thats all it takes. All these entries should now be published under UID 1 in Drupal as stories with the original timestamp, promoted to front page, and full HTML enabled. If you don’t want the entries on the front page, change the third ‘1’ to a ‘0’ on the first bit of SQL. Change the second ‘1’ to a ‘0’ if you don’t want them published automatically.

I hope this can help someone.

Thankyou

OpenID working with LDAP

Something I’ve been meaning to get round to for quite a while is setting up an openID server. I’ve finally done it! Even better, this server is linked into my ldap server which allows for consistent passwords for everything. Getting it working took quite a while. The openid-ldap software was fairly tricky to configure and the apache configuration was a nightmare for me of regular expressions, something that in all my geek years I’ve managed to stay away from in any depth. (I’ve learnt a fair bit through osmosis, but never sat down and looked at some regexp documentation). Read on for my instructions on setting this up.

Before we start

Before we begin, a few assumtions. This article assumes that you have:

  • A working permanent internet connection (DSL/Cable/Better)
  • An apache web server running and accessable from the internet over SSL, preferably with virtual hosting set up
  • A domain name that you want to tie your openid into and full control to add/change A/CNAME records
  • I did this on Debian, most distro’s should be similar but may use different directories
  • An LDAP server up and running (and working! – ie, tied into user logins, imap, etc)

Setup

My first step was to download the openid-ldap software and uncompress it into the root of your web server (eg. /var/www on Debian), then rename the directory to something easier to type.

cd /var/www
wget http://www.openid-ldap.org/releases/openid-ldap-0.8.7-noarc.tar.gz
tar xfzv openid-ldap-0.8.7-noarc.tar.gz
mv openid-ldap-0.8.7 openid
chmod a+r openid/ldap.php

You should be able to now access http://yourserver/openid to make sure it works. If you get any errors you’ll need to check your apache config. If everything is working then the next step is to get the ldap section working. In the openid directory open up the ldap.php and you will see a load of configuration parameters to edit. The important ones are:

$GLOBALS['ldap'] = array (
        # Connection settings
        'primary'               => 'yourldapserver',
        'fallback'              => 'yourbackupldapserver',
        'protocol'              => 3,
        'isad'                  => false, // are we connecting to Active Directory?
        'lookupcn'              => false, // should we extract CN after the search?
        'binddn'                => '',
        'password'              => '',
        'testdn'                => 'uid=%s,ou=People,dc=example,dc=net',
        'searchdn'              => 'ou=People,dc=example,dc=net',
        'filter'                => 'uid=%s',
        'nickname'              => 'uid',
        'email'                 => 'mail',
        'fullname'              => 'displayName',
        'country'               => 'c'
);

binddn and password shouldn’t be needed at all for most ldap servers to check if a user exists. If your server needs authentication, fill in these fields. You’ll also have to lock down the ldap.php file to restrict people seeing the plaintext password. testdn is the dn used to see if a uid exists. searchdn is the base under which to search for valid users.

To check that the ldap configuration is working, go to the url http://yourserver/openid/?user=at which you should see a welcome message. If not, go back and check your ldap configuration. There are some handy hints and tips in the openid-ldap README.

My next step was to set up some virtual hosting. This isn’t strictly nescessary, but it is the difference between an openid of http://www.example.net/openid/user and http://openid.example.net/user. Not much of a difference, but I wanted a challenge. For now, I will assume that we’ll just do a normal set up and I’ll leave the virtual hosting option up to the reader.

Because openid-ldap sends the username and password over basic authentication you should take it as a requirement to use your openid over SSL. I had a fun time getting this working along with the virtual hosting, but will leave this again up to the reader. There are countless helpful web pages out there to get ssl working on an apache web server.

Ok, once you have openid-ldap talking to your ldap server, SSL working, and possibly virtual hosting, it is time for the final bit of configuration. This part took me the longest to get working due to the mod_rewrite instructions that came with openid-ldap not working for me. For the openid to be kept simple and in the form url/user, rather than url/index.php?user=user, openid-ldap makes use of mod_rewrite in apache to (funnily enough) rewrite the url. To do this you need to edit the apache configuration for the directory under which openid sits to add:

RewriteEngine On

   RewriteCond %{REQUEST_URI}      !^/(.+)\.php(.*)$
   RewriteCond %{THE_REQUEST}      ^[A-Z][A-Z][A-Z]\ \/([A-Za-z0-9]+)\?(.*)\ HTTP/
   RewriteRule ^(.*)$        /openid/index.php?user=%1&%2

   RewriteCond %{REQUEST_URI}         !^/(.+)\.php(.*)$
   RewriteRule ^/([A-Za-z0-9]+)$  https://www.example.net/openid/index.php?user=$1

Restart apache and go to the url http://www.example.net/openid/. Hopefully you should see a welcome screen and a login button at the bottom. Click on the login button and a login box should appear. Type in your username and password, click ok, and you should be taken back to the login screen with a message that you are now logged in.

Thats it, you’ve got openid working. As mentioned, you can fine tune this to produce an easier url to type in, but this is a matter of preference. Hopefully someone may find this article useful. If you do, please drop me a mail or add a comment.

Thankyou.