Home Automation

A traffic service that answers “which way should I go?”

Which way should I go?  Traffic

Most traffic reports (on the radio or in text message alerts) are fairly useless. Like weather reports they contain lots of irrelevant information that could be eliminated with just a bit of extra context. In fact, most of the information they deliver is completely irrelevant to you as an individual located in one spot and hoping to get to another spot. Furthermore they aren’t actionable – telling me the traffic is slow on SR-520 and on I-90 isn’t interesting unless you can tell me which is the best way to go given where I am now and where I want to be.

So this weekend I added a new feature to the home automation that uses the WSDOT’s excellent traffic feed API to calculate a traffic report just for me. Recently I’ve started driving from the north end of Bellevue to the south end of Sammamish during rush hour. There are two very different paths I can take: SR-520 or I-405 to I-90. If either route has a problem I should take the other. So now I get an XMPP (chat) message from 4PM to 6PM whenever the optimal path changes from one route to the other. It’s the absolute minimum information I need and it’s 100% actionable.

For the moment the calculation is fairly simple, I simply maintain a list of the FlowDataID values along each route and then calculate a total ‘slowness’ factor based on the sum of those segments. If one way is much better than the other it generates an alert. If it goes back to being roughly equal the alert is cleared.

Since the calculation is purely relative (route A vs route B) it’s also fairly immune to day-of-week / school-holidays and other factors that have a significant impact on traffic but no impact on the only actionable decision I need to consider.

One other interesting point from the graph is just how spiked the traffic is on SR-520 compared to I-90.

Programming a smart home with a fluent, domain-specific language

In response to a question I received recently, here is an example of the fluent extensions to C# that my home automation system uses to define how it should behave. In effect this is a domain specific language for modeling home automation behavior as a finite state machine. Note how you can use either a purely declarative sequence or you can use procedural code within a Do() block.

            Living.FloorSensor
                .Then(Entrance.HallBeam, 30)
                .Provided(Time.Bedtime)
                .ProvidedNot(Home.DinnerGuests)
                .PulseStretch(10 * 60)      // don't announce it too often - every 10 minutes
                .Do("Garage doors warning", () =>
            {
                if (Garage.GarageDoors.AreAnyOpen)
                {
                    FirstFloor.Kitchen.AllMediaZones.AnnounceString("Excuse me, I think you may want to close the garage doors.");
                }
            });

In many ways this is similar to the Reactive Framework from Microsoft except my work on this predates the availability of Reactive Framework and unlike the Reactive Framework my ‘sequential logic blocks’ include persistence logic so the entire state can be saved to disk (as it is every second). This is important because some transitions in the state machine might be several hours or even days long and you need to be able to restart the system and carry on exactly where you left off.

One key benefit of the declarative approach over the procedural approach is that the declarative approach can explain itself. So, the log entry for a light going on can show that the light was turned on because ‘it was dark’ and ‘we had visitors’ and ‘someone came into the room’. Compared to traditional home automation systems where you either have no logging at all or you have a log of what happened, this kind of logging is invaluable for figuring out what went wrong when the logic gets complicated. So in this example I should have moved the test for Garage.GarageDoors.AreAnyOpen out to a Provided clause which would allow it to be part of the reverse-chain logic explanation.

Partial results can be captured at any point in these logic chains and then reused in other chains because each partial result is itself a Sensor device that implements the full fluent interface.

Ultimately I plan to hook the logging for what happened back up to the NLP engine which will allow users to ask the home ‘Why did you put the driveway light on last night around 9pm?’ and ultimately I plan to allow the logic itself to be defined using natural language.

Home power meters revisited

In an earlier post I discussed the utility (or otherwise) of the 24 hour power consumption graph and questioned why Google and Microsoft were both investing in this approach to home energy efficiency. Since then both Google and Microsoft have stopped their efforts in this area.


Interestingly, in Europe I’m seeing more and more homes with devices like the one shown here that provide real-time power consumption information. One of the more interesting uses for devices like these is as a check that everything has been turned off when a homeowner is about to leave the house. A quick glance at the meter can reveal if a heater has been left on in a bedroom. Of course the main water heater has the largest impact on the reading but homeowners learn what numbers represent ‘normal’ and can see at a glance when something else has been left on. Clearly a true smart home that can turn devices off when they are no longer in use is still a better long-term solution for this scenario but it’s interesting to see how a fairly simple device can at least provide an indication that everything is off without a significant investment in replacing light switches and device controllers. What would be nicer however would be if the meter included some kind of machine learning so it could show at a glance if the home is in a minimal power state or not.

Home Automation Calendar Integration

Calendar Home Automation Integration One feature of my home automation system is Google Calendar integration. What this enables is two things: (i) the house can record what happened on the calendar so I can see at a glance what’s been going on back home and (ii) the ability to put events on the calendar for the house to do certain things.

For example, we recently bought some new baby chicks and they need to be kept warm at light. An infra-red lamp in the chicken house is connected to an X-10 controlled outlet (behind a GFCI, of course since this is outdoors). The device that controls that outlet is called “Chicken lights” but also has several shorter aliases (e.g. “Chickens”). Using the home’s natural language engine that outlet can be controlled remotely by the chat interface, by the email interface, by the voice interface or by the calendar interface.

In this case, a simple recurring event on the calendar to turn the light on every night for 9 hours is sufficient and I can set the recurring event to stop after a few weeks because by then the chicks will no longer need it.

This complete integration of Calendar and Natural Language Engine functionality certainly makes for a very easy way to control and monitor a smart home!

Net result … happy chicks:

Smart home tracks network devices by mac address

Smart home tracks network devices

One surprisingly useful component of my home automation system is its ability to track every device that ever connects to the router at home by mac address.

Every few minutes my smart home scans the local subnet looking for connected devices. It does this by pinging each IP address in the local address range and whenever it finds a device it gets its mac address and compares it to a list of known mac addresses. Once it’s found a device it pings it more frequently to check that it’s still connected to the network.

Whenever it finds a new device (for example, a friend visiting with a cell phone or laptop that connect to Wifi) it can ask for that device to be identified (using the chat interface) and can track its comings and goings from then on. If you happen to enter the house with a smart phone with Wifi turned on you have just become an unwitting part of my experiment and your phone’s mac address will be tracked from here on out.

Many consumer electronic devices now connect to the internet and each is thus tracked by the home automation system to determine how long it has been on for each day. This is used to calculate the instantaneous power consumption of the home along with the lights and other devices that the home automation can control or monitor.

Aside from estimating power consumption and tracking visitors to the house, one of the most useful aspects of this feature is that it’s great for finding lost devices. Did your child lose their iPod touch at home or is it at a friend’s house? A quick look at the log shows when it was last seen in the house confirming that it’s still inside somewhere. Ultimately it might be able to cross-reference which rooms were occupied with when the device was last seen and thus give you an idea which couch or bedroom to go search (future feature), but for now, at least you know you aren’t searching in vain. Ideally I’d have three access points with firmware that can track the signal strength of each device in the home so I can locate it more precisely but I haven’t found a router offering that capability yet. My laptop can track and report how far away from the router it is but that’s not as useful as being able to track individual devices from the router.

Another possible use for this is tracking screen time – how many hours did your kids spend watching TV or playing on the XBox when they were in fact meant to be working on their homework? etc. etc. Of course at some point this may all become a bit too Orwellian but as I’ve mentioned before, part of the experiment I’ve been conducting with my home automation is ‘technical’ but the larger portion is ‘social’ – which features are genuinely useful and which are just too much.

Smart home energy savings – update for 2010

Smart home energy savings 2010

Here’s an updated graph showing the ongoing reduction in energy for our smart home. Driven mainly by continual improvement in the algorithms that control the heating, air conditioning and lighting the overall consumption of gas and electricity has continued to decline throughout 2010. It appears however that I am approaching the limit as to what is possible as the trend lines are beginning to flatten out. Going forward I’ll continue to try to improve the algorithms but I’ll also be on the lookout for any parasitic power-consuming devices and I’ll be dealing with them using techniques like the smart power strip I mentioned here.

A smart power strip

Smart power strips to save energy

Recently I added a smart power strip to the TV/Amplifier setup in the living room. My main aim was convenience – to make it easier to turn everything off all at once. But I also wanted to see how much power I could save by eliminating the parasitic power drain that a TV, amplifier and two DVD players have when in the ‘off’ state.

The power strip I bought is the one featured to the right here and to date I’m pretty happy with how it’s working. The power strip has one ‘blue’ outlet that senses when a single device goes on or off and then several ‘green’ outlets that switch accordingly. Initially I plugged the amplifier into the sensing output and everything else into the green outlets. That worked great and when the amplifier goes off so does the TV, the DVD player and the DVD changer. Since the amplifier is a Denon -CI model I can also control it remotely and since everything else switches on and off with it I can remotely shut down the whole stack from my home automation software.

The only problem with that approach is that in the ‘off’ mode the Denon -CI still consumes about 5W whereas the TV consumes 0W when off. The TV is one of the earliest HD TVs, a Panasonic Tau CRT TV so it’s fairly power hungry when on but it has a ‘real’ on/off switch so when it’s off there is no power draw at all. [Until recently the picture on that CRT beat nearly every flat panel TV on the market, but with recent LED LCD TVs I think I may finally be willing to part with it. It's old technology, but still an awesome HD picture.] So now I have to chose between remote power-off control and a 5W constant draw or no remote control and 0W consumption.

When I purchased the smart power strip I was concerned that it might itself have a phantom power drain equivalent to one of the other devices but it appears to be relatively harmless consuming hardly any current for itself.

The one adjustment you need to make on the smart power strip is to set the sensitivity so it can turn on and off at the right point.

Overall, definitely a recommended buy on this one.

Holiday Season (Christmas) in our Smart Home

Smart Home lighting for the Christmas Tree

So what does a smart home do at Christmas time?

Well, obviously it controls the Christmas lights, both the ones on the exterior and the ones on the Christmas tree and around the house. The indoor lights come on automatically at dusk and stay on provided the room they are in is occupied. Leave the house and they go off automatically. Walk back in and a strain-gauge under the living room floor detects your arrival and the tree lights and rope lights come right back on. Why waste energy lighting your Christmas tree if nobody can see it and why press light switches if you don’t need to?

The exterior lights come on at dusk and go off around 9PM. During holiday seasons the permanent Christmas lights along the eaves of the house come on automatically too. But the house also understands whether it has visitors. This isn’t something you need to tell it, it just figures it out by counting cars arriving and people coming in through the front door. If the house thinks it has visitors it will leave all the outside and Christmas lights on until the visitors have left. Again, there’s nothing you need to tell it, this is a ‘smart’ home not a ‘dumb’ home, and this is real ‘home automation’ not ‘home control’.

Another change that happens automatically during the holiday season is that the alert for a car coming down the drive changes to a subtle jingle bells sound. Normally the sound is the distant tweeting of birds and it’s played quietly so that visitors don’t even notice it. The residents of course know that there isn’t some bird tweeting outside but that a car is approaching the house. The dogs know the sound too and go running to the door barking. With the change to jingle bells sound the dogs quickly figure that one out too. The only problem is that now, when jingle bells are heard on TV they both run off barking to the front door! If only home automation systems were as easy to train as dogs! The driveway sensor by the way is one of those magnetic detectors buried about 120′ away to the side of the drive. It gives sufficient warning to prepare for a visitor before they even get to the front door.

One final change that happens automatically at this time of year concerns the music system in our house. My home automation software includes multi-channel audio playback through a zoned-audio switch. This allows any one of three sound cards to be connected to any set of speakers in the home. This means you can have exactly the same music playing across a whole floor, or indeed throughout the house, without any lag between rooms. In effect this is a poor man’s Sonos as the cost of each additional source is about $7.50 for a USB sound card plus about $150 for a single zone amplifier. You instruct the music system to play back music either by chatting to it on Instant Messenger (it has its own XMPP address), by emailing it, or by putting an entry on the house’s own Google calendar telling it when to start playback. For example, ‘play songs added this week in office’ would begin playback of any new music added to the system this week. And, the change that happens at this time of year is that the music playback subsystem allows Christmas music to play. That’s right, for the rest of the year, no matter what random selection of music you ask it to play (e.g. every song with the word ‘Bing’ in the title, artist or album) you will not hear any Christmas music. This is one feature iTunes and every other music player should adopt!

What does a Smart House do at Halloween?

Pumpkins_2010-7
Creative Commons License photo credit: madmarv00

At Halloween our home automation system has a few additional and changed behaviors.  Here are some of them …

1. When a visiting car comes down the drive the usual alert in the house is replaced with a spooky noise.  (Normally the driveway alarm is the gentle tweeting of birds — something that could easily be mistaken for an ambient noise if you didn’t live here and know what it means.)

2. When you approach the front door there’s an alarming shuffling and scratching sound from the bushes in front of the garage.

3. When you open the front door to visitors it plays another Halloween clip “Hello Children … ” in a spooky voice.

4. The media player automatically allows any Halloween-appropriate songs to play when on random play.  Normally such songs are skipped automatically.  So you just might hear the Monster Mash, for example, mixed into the normal random rotation.

If your house could talk to you, what would it say?

IMG_5300.jpg
Creative Commons License photo credit: tompagenet

Suppose for a minute that your house could talk.  What would you want it to tell you?

That’s a question I’ve been considering over the past few years because unlike most of you, my house can talk!  There are ceiling speakers in many rooms, the house knows which rooms are occupied, and it talks to you when it has information it needs to communicate.

I’ve experimented with many different announcements over the years, some of which turned out to be useless, some which just became annoying after too many repetitions, and a few that withstood the test of time and daily usage to become fixtures in my smart home.

Here’s a list of some of the current announcements my house makes:-

1. It announces who is calling.  “Talking Caller ID” if you will, except this one has a database behind it and whenever it sees a number it doesn’t recognize it will ask you who it is so it knows how to speak their name next time.  (The asking is done over instant messenger or email, a separate topic I’ll write about soon.)

2. It announces that you have missed phone calls.  It does this when the house has been unoccupied for a while and you walk back in.  It doesn’t do it right away because you are probably carrying stuff and banging doors.  Instead, it waits a moment and then when it detects you moving again in the house it announces all the calls you missed while you were away.

3. It announces the weather for the day in the morning when you get up and head into the bathroom.

4. It announces the weather for tomorrow if it’s already afternoon time today and you turn on any media zone.  But, of course, only if it hasn’t announced it for a while (repetition gets boring fast!).

5. It can announce the artist and title of each song as it is playing.  A simple chat command ‘dj on’ enables this feature.  At the start of every song it ‘ducks’ the music, announces the song, and then brings the volume back up, just like a professional voice-over announcement.

6. It tells you if the traffic is bad on the way into Bellevue this morning, where ‘bad’ is defined as more than seven minutes above the average for this day of the week.  Knowing that it’s bad on Monday morning isn’t useful.  Knowing that it’s much worse than normal is.

7. It announces the time every 10 minutes in the bathroom in the morning rush helping everyone stay on track.

8. It announces when it’s time to wake up using a schedule defined on Google calendar.  This means you can adjust the alarm clock as easily as you can change an appointment, no fiddly black on black buttons under an alarm clock to push.  It also means that the alarm can handle weekdays vs weekends and holidays.

9. It announces if there has been fresh snow overnight at the local ski resort: time to go skiing!  But it also warns you if the pass is closed as it sometimes is in winter after a heavy snowfall overnight.

10. It announces that it’s garbage collection day if it thinks you haven’t taken the trash out.

11. It warns you that the garage doors are open if you try to go upstairs in the evening leaving them open.  That’s a bit like HAL controlling the pod bar doors but in reverse: it tells you to close them!

12. It complains that the fish are hungry if nobody has opened the door to their tank for 24 hours.  Each 6 hours after that the announcements become more urgent, culminating in a “mine mine mine” audio clip from Finding Nemo.  (All our other pets do a fine job at indicating their hunger but the fish lacked this ability until now).

13. It says “good night” when you turn the lights off at the end of the day :)

14. You can also ask it to remind you of anything with a verbal reminder, e.g. the command ‘remind me in 15 minutes say “Turn oven on” in study’ does exactly what it says.

15. It tells us if anyone goes into our barn unexpectedly.

16. It can also scare intruders when it detects unusual motion that doesn’t fit the normal pattern – nobody expects a house to talk to them when they are burglarizing it!  Fortunately I’ve never had to test this feature.

Crucially it does very few of these announcements when it detects that we have visitors.  Party music should not be interrupted by home automation announcements!  It also learned early on that any announcement in a bedroom when the owners were asleep was a very, very bad idea punishable by instant termination and recompilation!

If you have any questions about these or other features of what I believe is the “World’s Smartest House” please feel free to comment below or on the relevant page.