Category Archives: Ramblings

Upgrading The Thermostat Bot

The temperature bot a.k.a. the algorithm that controls the temperature in my house underwent a slight upgrade this week.


The old algorithm:

If (setTemperature > averageHouseTemperature) HEAT, otherwise COOL.

Simple right? Not so much.

Scenario 1:

Let’s say I set the temperature to 70, and it’s currently 71 in the house. According to the bot, the AC would go on, this would be fine if it was 80 degrees outside but not if it’s 55. I’d rather just open the windows, and furthermore, I want it to just stay off until I close the windows.

Scenario 2:

Let’s say I set the temperature to 72, and it’s currently 70 in the house. According to the Bot, the HEAT would go on, this would be fine if it was 55 degrees outside, but not if it’s 80. I’d rather just let it heat up naturally, then if it gets above 72, I want it the AC to come on.

Let’s look at these scenarios in more detail.

In Scenario 1, the set temp is LOWER than the average house temperature, rather than the AC turning on, I want to open the windows and I want the HEAT/AC to stay OFF.

In Scenario 2, the set temp is HIGHER than the average house temperature, rather than the HEAT turning on, I want the house to just heat up naturally but I want AC to kick on if it gets too HOT.

The new LOGIC.

return (outdoorTemp < 62 || outdoorTemp < 67 && setTemp > indoorTemp) 
   ? 'heat' : 'cool';

The final piece of the puzzle is I need to call this on an interval since the indoor and outdoor temperature will fluctuate throughout the day.

(Updated 4/18/2018)

Alexa / Voice / AI Chat

Screen Shot 2017-06-27 at 7.29.21 AM

What does user experience look like without a mouse & keyboard or easy to enter form fields? How do people talk to AI systems to solve problems? These systems can be through devices like Alexa or virtual systems like automated chatbots. Understanding psychology and human behavior become just as valuable as business knowledge when designing these systems. Because of this we will see new software architectures come into play that deal with these variations and have multiple and guided user flows.

There are two main components of developing an apps for Alexa, intent schemas and utterances.

  • Intents: An intent represents an action that fulfills a users spoken request.
  • Utterances: A likely set of spoken phrases that are mapped to intents.

Here’s a sample intent for a few commands I’ve used to control my house.

  "intents": [
      "slots": [
          "name": "Command",
          "type": "LIST_OF_COMMANDS"
          "name": "OnOff",
          "type": "LIST_OF_ONOFFS"
      "intent": "SendJarvisCommand"
      "intent": "AMAZON.HelpIntent"

Intents also have slots. For example:

LIST_OF_COMMANDS --> lights | porch | yard | backyard | frontroom | hallway | garage | basement | workbench | wemo | bedroom | tv room	
LIST_OF_ONOFFS --> on | off | dim

The list of utterances, or ways users can interact with this data might look like:

SendJarvisCommand turn the {Command} {OnOff}
SendJarvisCommand switch the {Command} {OnOff}
SendJarvisCommand {Command} {OnOff}

This text is then passed to a lambda function where it needs parsed and then returns a response.

So your traditional web form is converted like this.

  • Form Target – Becomes Intent (SendJarvisCommand) which is mapped to code.
  • Droplist & form fields – Becomes Slots
  • Utterances – not in traditional apps.

Because utterances don’t match up to anything in existing form fields most businesses and user experiences have holes that need filled. You can also chain intents to one another creating user flows that are out of order.

So whether it’s voice or AI chat you need architectures that deal with this dynamic workflow, getting some of the data at unexpected points during a conversation, then re-prompting the user in a dynamic way to solicit input required to complete the task.

Whether it’s retail for a shopping assistant or a chatbot to help you reset your password it’s really fun time because we need to invent something new!

Simple React Example

So I’ve been trying to find a simple React example, one that uses a flux implementation that works out of the box in a browser without any compilation or node stuff. I couldn’t find one so I built one. Here it is:

This requires, RefluxJS, ReactJS, React-Dom and a Browser. You can use node to run it if you want, but that’s not required. Enjoy! (Copy-Paste & ES5 Compatible)

    // the action, nothing special
    var myAction = Reflux.createAction();

    // the store, holds state and listens to action.
    var myStore = Reflux.createStore({
        times: 0,
        init: function () {
            this.listenTo(myAction, this.actionCallback);
        actionCallback: function () {

    // the react component, which subscribtes to the store and updates it's state via listen
    var CountBox = React.createClass({
        displayName: 'CountBox',
        getInitialState: function () {
            return {count: 0};
        componentDidMount: function () {
            var self = this;
            myStore.listen(function (data) {
                self.setState({count: data});
        render: function () {
            return (
                // the component in plain old JS no JSX
                    React.createElement('div', {className: "countBox"},
                            "Count Value =  " + this.state.count

            React.createElement(CountBox, {count: 0}),

    document.querySelector("#test").addEventListener("click", function() {

Created A Chevelle Blog

I decided to create a blog for my chevelle because there was so many things I was learning about it and thought I should help out some other folks working on their car.

I’ve researched a lot on YouTub and the internet as well as Chevelles.Com, but making a post there about what I learned just didn’t seem right.

To learn more visit:

Dead APC Back-Ups & Alternative Batteries

I recently had an UPS failure. My UPS and APC 650 ES, has a battery they call for is the RBC17. Which on Amazon.Com is $39.99. However when you peal the sticket off you get Vision UB1290. This battery (which is the same battery) cost around $15.00.

I imaging this happens a lot with companies looking to make a cheap buck. Hopefully this post catches someone search on “Alternative APC Battery” or something similar.

iPhone 5 Calendar Alerts

I’ve found out the different things you need to get your calendar alerts to work with Google Calendar.

  1. Go to Google Settings and Turn on Alerts
  2. Make sure the alert type is pop-up.
  3. Make sure it’s set to 5 minutes, then make sure your iPhone is also set to 5 minutes.
  4. Make sure you have a sound selected on your iPhone

That’s it. Happy alerting…

Cheers To The Un-Science!

I wrote this article 5 years ago, about the unscientific age we live in. We also love to correlate things and assume they are causal.

As I read some business books over the holidays it seems these items are also very selected correlated items. About how if you do A, B and C you will succeed in business. While many of these books leave out vital back-stabs or other non-flattering vital causal clues to the authors success. They don’t mention those of course because the book would not sell as well.

I was also reading about a new study on Warming of Antartica, and am reminded again about how this only works because people don’t understand science. I see the story and say, well, it looks like that hypothesis was wrong. I wouldn’t use a wrong hypothesis to support the same theory, but then again I’m not trying to sell newspapers or visits to a website.

The most popular story over the past few days was the End of The World. Which never happened, of course. At some point though something will happen and it will be “proven correct” because there’s always so many people claiming to know the future, and by chance one person will be correct.

But despite all the un-science out there in the world, the best un-science is the time I’m spending with my wife & daughter.

Updated Site

scottpreston.comI’ve decided to refresh the theme of my blog. You may notice it’s simple, and minimalist in style. You won’t find it changing too much in the coming weeks, except for a few more pages or widgets on the sidebar, and maybe a header image or two.

Correlation vs. Causation

What’s the difference between being linked and being caused? If I tell you that every time I dropped a water balloon on the ground it broke. You could say gravity caused the water balloon to break. But what if I didn’t tell you were always filling the balloons to their maximum capacity and they were dropped on rough, almost sharp concrete, would you make that same conclusion that gravity caused water balloons to break?

What if they were half full and landed on grass and none broke? Would you conclude that gravity does not cause water balloon breakage?

It seems today the public DEMANDs an explanation for everything, if A, then B. But in just about every case it’s never that simple.

The real explanation of why a water balloon breaks is when the pressure of the water inside the balloon exceeds the tensile strength of the rubber. Sharp objects exert more force per unit square meter than other items such as grass or perfectly flat surfaces. However this is too complicated for journalist catering to a public with poor and getting worse science understanding and desire to create sensation and get attention.

To truly know something is causal  (A implies B) is hard and takes time.

Don’t confuse correlation with causation. While these examples sound funny, you can read about them every day, especially with medical studies and social sciences.

100 Monkeys & Predicting The Future

The Story: You’ve got a 100 monkeys flipping coins. Eventually after 10 tries there’s a single monkey left that managed to flip it 10 times in a row heads…

Same Story: All 100 monkeys have a theory that use that use to predict coin flips. All but 1 monkey was successful 10 times and is 100% accurate.

Same Story: I can predict the future of the middle east, the economy or the weather because I’ve done so in the past with my theories.

If you look at this you realize how susceptible we all are to people that promise us they can predict the future. I suspect that science combined with clever statistics or even complicated mathematics is now the new bones, tarot cards, or crystal balls.

Isn’t it funny how we haven’t changed all that much?