A traffic service that answers "which way should I go?"
A traffic service that answers "which way should I go?"
Which way should I go?
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.
I've been working on home automation for over 15 years and I'm close to achieving my goal which is a house that understands where everyone is at all times, can predict where you are going next and can control lighting, heating and other systems without you having to do or say anything. That's a true "smart home".
An overview of the many sensors I've experimented with for home automation including my favorite under-floor strain gauge, through all the usual PIR, beam and contact sensors to some more esoteric devices like an 8x8 thermal camera.
One way to reduce the volume of sensor data is to remove redundant points. In a system with timestamped data recorded on an irregular interval we can achieve this by removing co-linear points.
Home automation systems need to respond to events in the real world. Sometimes it's an analog value, sometimes it's binary, rarely is it clean and not susceptible to problems. Let's discuss some of the ways to convert these inputs into actions.
Another super useful function for handling sensor data and converting to probabilities is the logistic function 1/(1+e^-x). Using this you can easily map values onto a 0.0-1.0 probability range.
In a home automation system we often want to convert a measurement into a probability. The ATAN curve is one of my favorite curves for this as it's easy to map overything onto a 0.0-1.0 range.
An if-this-then-that style rules machine is insufficient for lighting control. This state machine accomplishes 90% of the correct behavior for a light that is controlled automatically and manually in a home automation system.