Thursday, 7 January 2016

Rosie

Ok it's been a long time since I've posted, soz. Technology wise, its been a good 12 months as I moved house in the middle of 2015 and had to develop Rosie, who had been built specifically with my two bedroom apartment in mind, to work in a much bigger four bedroom house - it also suddenly had to have WAF (Wife Acceptance Factor) (or GAF) as I moved in with my girlfriend.

I re-wrote most of Rosie on a flight back from Dubai last year. I kept the basic foundation but decided to expand her in a few minor ways:

1. Lights to Devices
She would no longer be "Lights" focussed and would be more "Device" friendly as the system can switch any electrical device on and off as long as it plugs into a wall socket.

2. Two floors
I would categorise everything into Downstairs and Upstairs, mostly for a better UX.

3. Cleaner UI
I would clean up the UI, mostly for mobile devices as my girlfriend and I tend to use Rosie on our phones more than any other device, so I wanted to remove clutter and make her even easier to use.

4. Remote Rosie
I wanted to enable (or rather re-enable) the ability to control Rosie from outside the home. She can now be accessed from anywhere but if you try accessing from outisde our WIFI, you will be prompted for a pin number, just to deter people accessing my devices and network! I've implemented a simple http redirect for any requests to my IP which redirect to the Rosie RaspberryPi. I've used a friendly figurativelyone.com sub-domain so the whole thing is seamless and easy. It's great if we've forgotten to leave the lights on for the dogs or have left a light on.

5. Aerial
Rosie needed a much longer aerial to make sure that she could turn the lights on and off throughout the house

Then, I had an idea after talking to a fellow home automation enthusiast. He had mentioned that his system could be accessed via a tablet, mounted on his wall. He'd implemented a few cool tricks on the tablet such as it waking up when it detected somebody walking towards it and was locked to only show one specific webpage.

This got me thinking and I kept pondering whether or not it would be worth implementing the same thing in our house. I wasn't sure whether we would actually use it, as it's so easy to use on our phones.

However, as I kept thinking about it, I couldn't help but think that if Rosie was permanently displayed, she'd be rather dull. Several thoughts later and I had what I considered to be a great, if slightly unnecessary, idea for how to brighten up the UI.

The idea
I decided it would be cool to display a full-sized background image behind Rosie which would depict the day's weather.

A weather API
I needed a weather API. Previously I've used Google's weather API for other projects, but unfortunately Google have decomissioned this particular project. I started searching the net for a reliable and rich weather API. I thought this might be the end of my project, but I was very surprised to find out that the MET Office have their own API that you can use for free. Not only this but their documentation is very easy to use and whole API seems to be very well written. I was quickly able to register, get my API Key and put some sample code together.

The API offers a variety of different outputs including weather forecasts for today and up to 7 days in the future. I wrote my class to bring back a headline of today's weather. This updates throughout the day, so whenever Rosie loads on a particular device, the latest weather headline can be displayed.

Interpreting the weather
The next challenge, now that I had a sentence containing the weather for today, was to write some code to interpret what the sentence meant in terms of weather. I have decided to build this up over time and make it more intelligent as I find new sentences to interpret.

To start off with, I looked for key words such as rain, showers, wet, snow, ice, cold, sun, wind etc. I put them into a hierarchy (e.g. snow trumps rain as snow is so much rarer in the UK). I keep developing this as I find more keywords and will eventually add in a weighting algorithm to read the whole sentence and determine the overall weather. This will be necessary because sometimes there are sentences such as "Dry at first with showers developing in the afternoon".

The Imagery
The end result of the weather interpretation is that I end up with a type of weather, e.g. Rain. Each type of weather is associated with an image which can then be loaded as the background image for Rosie.

Examples

Desktop


Mobile


Control Panel - a device can be enabled or disabled at the touch of a button now. This is really handy for devices we don't always use, such a Programs to automate the Christmas lights!


Future planning
Rosie will continue to be developed and improved... the following ideas are in mind at the moment

  • More advanced scheduling
  • More advanced Control Panel
  • Keep thinking about the potential and usefulness of a wall mounted tablet
  • Automating our chicken coop door!