Community showcase: automated home setup to stay in flow
Tags: productivity, showdev, vscode
Published: 2021-05-20 13:09:44

[Code Time](https://www.software.com/code-time), Software’s extension for code editors and IDEs, helps you protect valuable code time with **Flow Mode**—a set of automations that makes it easy to eliminate distractions, mute notifications, and stay focused when you’re in flow. 

Once connected to a Slack workspace, Flow Mode enables Slack’s Do Not Disturb mode, sets a custom status message, and adds a purple icon to your status. In some editors and IDEs, like Visual Studio Code, you can also choose to enable Zen mode or enter fullscreen with Flow Mode. Flow Mode can be triggered manually, via a button in the sidebar or status bar, or automatically, based on your coding activity. 

[Shane Lawrence](https://www.twitch.tv/tehshane), a member of the Software community and senior software developer, saw an opportunity to make Flow Mode even more powerful. 

He extended Flow Mode to automate his entire workspace setup:

* Change ambient lighting in his workspace to purple
* Silence notifications on his phone
* Set a custom Do Not Disturb status on his home system

Here’s a short demo of Shane’s custom Flow Mode in action:

{% youtube CpvgArVhCF4 %}

## Overview of the flow automation stack 
Shane’s setup uses a few different automation tools and APIs: 

* [Code Time](https://www.software.com/code-time) to detect when he’s in flow and update his Slack status
* [Slack Events API](https://api.slack.com/events) to monitor his status and trigger his home automations
* [Home Assistant](https://www.home-assistant.io/) for connecting and controlling his devices
* [Philips Hue bulb](https://www.philips-hue.com/en-us/products/smart-lightbulbs) for his desk light, [Hue lightstrips](https://www.philips-hue.com/en-us/products/smart-lightstrips) and [Nanoleaf Aurora](https://nanoleaf.me) for accent lighting on the wall 
* [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en&gl=us) and the [AutoRemote plugin](https://joaoapps.com/autoremote/) to set his Android phone to Do Not Disturb

Shane wrote a small watcher script in Node.js that checks for changes to his Slack status using the Slack Events API ([@slack/events-api](https://www.npmjs.com/package/@slack/events-api)). If a new status includes Flow Mode’s purple emoji, 🟣, Shane’s bot sends a custom ‘begin_flow’ or ‘end_flow’ event to his Home Assistant, a popular open source home automation hub. 

Home Assistant then sets a custom Do Not Disturb mode for his home automation system,  triggers his workspace lighting, and sends a notification to his phone. 

Home Assistant comes with powerful connections out-of-the-box. It integrates directly with [Philips smart bulbs](https://www.home-assistant.io/integrations/hue/) and [Nanoleaf lights](https://www.home-assistant.io/integrations/nanoleaf/), as well as more than [1,500 other smart devices](https://www.home-assistant.io/integrations/). To control his phone, Shane uses AutoRemote to listen for notifications from Home Assistant. Tasker then changes his phone’s settings. 

In his next iteration, Shane is considering how he might trigger [Digital Wellbeing](https://www.android.com/digital-wellbeing/)’s Focus Mode to disable all distracting apps on his Android phone. He is also exploring how he could integrate with Spotify to start playing newly recommended songs from [Music Time](https://www.software.com/music-time) when he’s in flow. 

## Why defending flow matters 
Developers constantly battle meetings, interrupts, and inertia—the ‘enemies’ of developer flow—that interfere with valuable code time. Impromptu Zoom calls and relentless Slack messages make work feel disjointed and chaotic.

Protecting flow helps us silence these distractions and make the most of each workday. From Shane: 

> “As someone who’s deeply passionate about the work I do, being in flow is the part of my day where I’m immersed and energized in what I really love most: working on challenging problems and helping online communities be a safer place for everyone to connect.
> 
> While I’m fortunate to have been able to keep my job through the pandemic, working from home has introduced its own set of challenges, such as staying focused on days when other distractions want to drag my attention away from important tasks, making it difficult to always sink my teeth into a solid coding session.
> 
> Code Time’s flow feature combined with my smart home integration helps me quickly tune out all of the distractions at once, helping me focus faster and reduce the chatter of apps and chat messages all competing for my attention.”

If you’re interested in automation tech, you can [find Shane on Twitch](https://twitch.tv/tehshane), where he’s currently building a bot service that helps streamers let their viewers redeem channel points to change their smart light colors. He streams Wednesdays at 6pm PT and Saturdays at 7pm PT. Shane’s streams are open to all, coders and non-coders alike.