Thursday, April 6, 2017

Automagic: Flashlight-A global variable project

With my new phone, I've been automating some repetitive things I need it to do.  Future blog posts will talk about settings I've made for different times of the day.  And a post I've already done talks about using Automagic to get around an Android Auto bug (feature?).

My Google Pixel running Nougat has a nice flashlight feature. It can be turned on my pulling down the setting menu and touching a small icon. That's not always convenient.

I was surprised there was no widget.

I discovered one of the Actions in Automagic was turning on and off the flashlight.

But how to do that without having two of Automagic's widgets, one for on, and another for off?

Then I discovered one of Automagic's Triggers can be a change in a Global Variable. When ever the value of a Global Variable changes, a flow is begun.  And depending on the value of the variable, the path of the flow can be altered.

So I created the flow shown here. A Global Variable named global_flashlight, a binary variable, is the trigger to two other Actions: Flashlight On, and Flashlight Off.

On the main screen of my phone is an Automagic Toggle Widget. When pressed it toggles the value of global_flashlight, thus triggering the flow and turning the light on or off.

Global Variables can be found in the menu on the main screen under Manage.

Download Flow

No comments:

Post a Comment