Lumi Cue logo

Developing an Alexa Skill Using Timers and Smart Lights

Lumi Cue is an Alexa skill that adds a visual element to traditional timers. Invoke Lumi Cue, and your lights will bring calming colors into your space while you go about your tasks. Whether you’re setting a study timer, baking, or taking some time for meditation, Lumi Cue will transform your home for this moment.

As soon as your timer begins, your Lifx bulbs will turn on and begin to move between blue and purple at a calming pace. Once your timer ends, your lights will revert to their original states.

View on Github

About Lumi Cue

Our Team

Aleia DeVore

Carlos Esquivel:

Background

Unfortunately, when it came time to create a demo day project, we were on a tight schedule. Our team had two weeks to research and two weeks to build our project, which meant that we had to narrow our scope. No matter what, we knew that we wanted to keep some specific goals in mind:

  1. Our project needed to help people. Specifically, we wanted to create something that would be useful for people with executive dysfunction and time blindness.
  2. Our project needed to be doable. Neither of us had experience working with Amazon Web Services, the Alexa Development Console, or even node.js, so it had to have a simple objective with several stretch goals.
  3. It needed to be challenging. While we developed this for the end of our foundations curriculum, it would also mark the beginning of our specializations, and we wanted this project to help us research and think creatively outside of our school assignments.

After brainstorming with several peers, we narrowed our focus down to a visual and audible timer using node.js and the Alexa Developer Console.

The Timeline

Phase I: Research

First, we began researching what it would take to create an Alexa skill. We quickly came upon several tutorials that enabled us to get started with the Alexa developer console. After that, we just needed to think about our code itself.

We also researched smart lights that we could use. We decided to use the Lifx brand because it provides a public API and is one of the more affordable brands of smart bulbs. Since we wanted this project to help people, we wanted to keep the cost as low for the user as possible.

In the midst of this, we also researched what else was on the market. I’ve used IFTTT for automation in the past, and they have several smart light and Alexa recipes ready to go. However, we wanted to create something that was native to Alexa so that users wouldn’t have to download a third-party app. Plus, we wanted to see what goes on behind the scenes with services like IFTTT!

Finally, we researched the accessibility guidelines we needed to keep in mind. We were both surprised by how few resources there were specifically about smart speakers. While the landing pages for some smart speakers discussed their accessibility features, we couldn’t find a collection of best practices for developers to follow. We decided to focus our attention on thinking about how a blind or visually impaired person would use our skill as well as on how a deaf or hard of hearing person would use it. However, this barely touches the surface of accessibility, and it is something we will continue to research. For each of us, accessibility is the standard of well-written code that we intend to hold ourselves to.

Know something that we missed? Accessibility is always at the top of our list. Submit a GitHub ticket, comment below, or message us so that we can fix the problem!

Phase II: Alexa Developer Console

Initial algorithm, outlined during our first research day

As we began our initial code, we whiteboarded a basic algorithm. Alexa would prompt the user for the name and length of their timer, which would be stored in a JSON file. We would then access this information to create a setTimeout function which would wait for the length of the timer before setting off an Alexa alert and making an API call to the lights.

Fortunately, we discovered a tutorial from Dabble Lab early in our development process, which helped us to better understand how the Alexa timers API works. Based on this, we moved away from using a setTimeout for the Alexa alert and instead created an object with all the necessary components of the timer. We then used this object in a POST request to the Alexa timer endpoint.

Phase III: Oh no

While we quickly worked through the setInterval loop, we ran into problems while trying to sync the lights with the timer. We didn’t know at the time that serverless applications have a limited amount of time to run. With Amazon, our code could not run longer than five minutes.

Want a tutorial to build this skill? Comment below!

After researching, panicking, researching more, feeling brilliant, and repeating the cycle ten times, we managed to successfully move our skill over to AWS lambda. We would create several lambda functions that would call each other, powered by a cron job that routinely checked DynamoDb.

As we began to map out the algorithm, we created something that you would find in a conspiracy theorist’s basement. Yes, we could code it, but would it be worth it? Only a few days before our project deadline, we switched our way of looking at the problem. Instead of waiting until the timer timed out, why not change the lights at the beginning?

Phase IV: Breathe

We created a Lifx item, which included the following parameters:

  • Turn the lights on if they are not already.
  • Take ten seconds to complete one color cycle.
  • Start with the color blue and fade to the color purple.
  • Repeat X times.
  • Revert to the original state of the lights when complete.
const lifxItem = {
color: ‘blue’,
from_color: ‘purple’,
period: 10,
cycles: X,
persist: false,
power_on: true,
peak: 1
};

For the final parameter, we needed to do some math. Fortunately, earlier in our code, we determined how many hours, minutes, and seconds there were in the set timer. We multiplied these numbers accordingly to get a lightTime, the total number of seconds in the timer. Then, we divided that number by ten (the length of one cycle) to get the total number of cycles needed.

With that, our Minimum Viable Product (MVP) was complete.

Future Goals

To do this, we first plan on creating a settings intent. This would allow the user to choose what colors they want their lights to turn and how long to make one cycle.

We also plan on implementing some features that would empower people with executive dysfunction. These include repeat timers with a set time for daily or weekly tasks.

“Your brush teeth timer has been set for two minutes.”

Beyond this, we intend to create a feature that will allow users to ask Alexa how long it has been since they completed a certain task.

“Alexa, ask lumi cue how long it’s been since I brushed my teeth.”

“From lumi cue: Your brush teeth timer last went off at 7:30 am today.”

Finally, we plan on creating a way for Lumi Cue to store users’ Lifx tokens long-term so that users will not need to keep them in specific lists.

Software engineering student and lover of mountains.