Showing posts with label apple. Show all posts
Showing posts with label apple. Show all posts

iPad & X10: The Ultimate Home Automation Controller?

Since Startrek TNG I've been eagerly awaiting delivery of my PADD. Disappointed for years and whilst not perfect, my newly acquired iPad is prettty damn cool. A little on the heavy side and terrible in sunlight, but otherwise fantastic.

When I blogged about X10 in February I mentioned that I thought iPad would make a "stunning HA remote control".

Other than general reliability, since starting with X10 in 2007 I've been most disappointed by the terrible remote controls. I've 2 Logitech Harmony remotes which whilst marginally better than the 6 official remote types I've tried, still fall far short of my ideal.

X10 Commander, the iPhone app which has gotten coverage including prime time TV ads is, for me, not a lot better. Certainly not something I'd pay for, especially as if using a mac you have to pay for the serverside portion as well.

So, for a while now I've been planning on writing an iPad web app interface. I'm going to share with you how and what I've achieved so far.

Shion + Mac Mini + CM15Pro

A couple of weeks back I started looking at what free software there was available for Mac OSX for interfacing with my CM15Pro (aka CM15a). At first I found nothing, only trial software which claimed to be fully functional but turned out not to be.

Eventually I found Shion about a week ago, which whilst basic does seem to do what I need. It's currently free if you email for a license.

All you need to do is set up an X10 device for each that you have. I've currently 17 physical devices and many macros over 2 house codes.

Annoyingly and after much hair pulling I discovered that only Shion 2.0 is compatible with CM15Pro - whilst 2.1 detects the controller it doesn't work as it should.

One massively annoying thing I should mention - my mac mini absorbs X10. It's the only device in the house that does. I'm going to have to buy a filter for it shortly, which are overpriced at £30.

Apache + PHP + AppleScript

I was rather hoping to find software with a web interface, but Shion has the next best thing - the ability to interface with it by AppleScript. I'd not come across AppleScript previously (I've only been using a mac for a couple of months), but it's super simple and easy to pick up.

OSX comes with Apache and PHP preinstalled, it's just a case of enabling them. I had to edit the httpd.conf to run apache as a standard user, as otherwise it wouldn't be able to call exec() and run applescript. This isn't generally adviseable for use on the Internet, but on a secure home network it's fine.

I set about designing an iPad interface and whilst am writing it with re-usability in mind it's not ready for any sort of public release. The good part is that the actual code you need to interface PHP -> X10 is 1 line:

exec("osascript -e 'tell application \"Shion\"' -e 'activate device named \"$device\"' -e 'end tell'");

For example:

if($action == "on") {
    exec("osascript -e 'tell application \"Shion\"' -e 'activate device named \"$device\"' -e 'end tell'");
}
elseif($action == "off") {
    exec("osascript -e 'tell application \"Shion\"' -e 'deactivate device named \"$device\"' -e 'end tell'");
}


Simple huh?

Interface Design

The best part about being able to write your own PHP is that you can make an interface that ideally suits your house and how you naturally want a remote to look.

I thought at first about making an iPad version of Domia's 10" PictureTouch using photographs and imagemaps, but I decided to make it a bit more advanced than this.

I wanted it to look vaguely like a native iPad app and whilst I thought about using a framework (if I had several weeks to kill I'd reverse engineer AdLib) I decided it'd be quicker to make up my own interface with images and text.

I designed it on Firefox a couple of days before getting my iPad, then did some final tweaking when it arrived. I wanted an interface that would fill the entire browser but not require scrolling.

I wrote the initial interface for landscape mode, which I plan to be in most of the time whilst using the device. Annoyingly Apple decided not to make the screen 16:9, but I came up with a way of fitting everything on.

Inspired by other apps I choose to display a list of rooms down the right hand side of the screen, along with some information about each. Clicking on a room's picture changes the left hand side of the screen, showing a photograph then controls bellow.

I found that I had space for 12 devices / macros, divided into 3 tables each with a header. It suits my house to have a table for lighting, one for appliances and one for macros. I created images to place around the table, giving it a rounded corners look. Finally I created some buttons in Gimp - big enough to be pressable but not so big as to take over the display.


Where to from here?

What I have so far represents only a few hours work.

Next step is to have the interface change when the screen is turned through 90 degrees, to show all available devices / macros.

I believe in Open Source, so if I've time and effort available I'll create a reusable package for others to play with. In the meantime hopefully what I've described here will give anyone with a basic understanding of PHP enough to get going with.

Being HTML it can be used on our PCs, but I plan to make both an iPhone version and 10 foot version for use on TV.

Finally I plan to make the icon on my home screen point not to the web interface, but a public IP that redirects either to the internal address if I'm at home or a passworded public interface (connected via a tunnel) when I'm out and about.

Any thoughts are appreciated :)

Apple & Quince Tart with Cardamom Cream

Suffering from a bad case of man-flu; compounded by 9 hours at work, I decided on Monday evening to cheer myself up with some dessert. I can't remember the last time I made an apple tart, but it was certainly a while ago.

I've been aware of the existence of quinces since an excellent meal at The Quince & Medlar in 2008. Ever since I've been wondering what they taste like (there were no quinces in the meal). It's not a fruit that I've ever seen in shops before; apparently you either grow them yourself or find someone who does.

I read a few months ago that quince jelly/jam goes very well with apples, so decided to incorporate it into a tart. Having previously only seen the jelly sold at an astronomical price in a deli I tracked some down at the reasonablish price of £2.09 in Waitrose (stocked with chutneys as opposed to jams). Quinces are (so I'm told) pear like fruit with sour flesh that once cooked becomes reddish and sweet. The jelly is reddish, sweet, slightly grainy and tastes somewhere between apple and strawberry. It's certainly not unpleasant.

As you can see from the picture, this is a shortcrust pastry tart with a layer of fruit purée, topped with apple slices, then glazed and baked. Normally you'd use just apples in the purée and glaze with apricot jam (which you can do if you can't find quince jelly), but I added 75g jelly to the purée and glazed the top with 50g. As I've not had quinces before I can't tell whether the tart tastes quincy or not, but the red colour comes through and I'm pretty pleased with it.

Ideally you'd use dessert pastry instead of standard, however I've not seen ready made vegan dessert pastry in shops (almost all standard shortcrust that is sold is). If I were less lazy I'd make my own, but it doesn't make an awful lot of difference. As an alternative you can roll out a disc of puff pastry and top it instead, making a more tart tartin style thing.

Next time I need to use a dish with slightly shorter sides, so there's less exposed pastry. Using a loose bottomed tin allows you to transfer it to a serving dish, however as the pastry shrinks away from the sides during cooking it's easy to get the first slice out of the dish you cook it in.

Ingredients (8 servings):
  • 1 Sheet Shortcrust Pastry
  • 2 Bramley Apples
  • 5 Cox's Apples
  • 1/2 tsp Cinnamon
  • 75+50g Quince Jelly
  • 25ml Water
  • Sugar
  • Margarine
  • 150g Soya Whipping Cream
  • 3 Cardamom Pods
As you can see; it's a relatively simple dessert to make. Most of the prep time is taken up peeling and chopping apples.

Start by peeling and dicing the bramley apples. If you don't have bramleys in your country then use whatever is sold as a cooking apple (generally larger, green and not overly sweet). You want to dice them into fairly small chunks, as this will make the cooking time shorter.

Heat a knob of margarine in a pan and add the diced apples. Cook over a low-medium heat for 10-20 minutes (dependant on the size of the dice), stirring occasionally until you can easily squish them under the back of a spoon.

Add the cinnamon and sugar to taste, stirring until you get a purée. Add the 75g quince jelly and stir until combined. Set aside and leave to cool.

Meanwhile, preheat your oven to 200oc (180oc fan) and roll out the pastry on a floured surface, so it's a little larger than your dish. Wrap the pastry around a rolling pin and unroll over a greased dish, such that it comfortably sits within it and doesn't need to be stretched. Press the pastry against the sides with your fingers and cut off excess with a sharp knife.

Described as pointless by Delia; I quite like my ceramic baking beans. Prick the base, cover with baking paper and weigh down with whatever it is you use instead (rice supposedly works, but I've always thought this is somewhat of a waste). Cook in the oven for 10 minutes then remove and take the paper away.

Place 50g quince jelly in a small pan with 25ml water and leave to warm through over a low heat, stirring occasionally. Don't let it boil - it just needs to combine into a syrup.

Peal and chop the apples into slices. Having a bowl of cold water to put the slices in as you cut them will shop them from oxidising and turning brown.

Spread the purée out over the pastry and top with the apple slices in a pattern of your choice.

Pour over the quince syrup, using a pastry brush to ensure that all surfaces are covered. If you've not got a silicone brush yet then now's the time - they're easier to clean and unlike non-synthetic brushes they aren't made from big bristle.

Cook the tart in your oven for around 35 minutes, checking it every so often to make sure it's not burning.

Crack the cardamom pods and grind the contents to a fine powder (discard the shell). Whisk in with the cream and chill until required.

When the tart comes out of the oven allow it to cool slightly before serving. As well ensuring that you don't burn your mouth this allows the purée to firm up slightly, making cutting easier.

Use a large sharp knife to cut and extract slices. As the pastry shrinks away from the dish during cutting you should have no problems getting it out. It can be served warm or cold.