Thursday, November 28, 2013

MacroDroid Variables

Having recently introduced MacroDroid variables I get a lot of requests for more information on what they are and how they can be used. This blog post will explore how you can use MacroDroid variables to enhance your existing Macro set.


What is a variable?

In simple terms a variable is just an identifier that can hold some kind of value. MacroDroid currently support three different types of variable as follows:
  • boolean - A simple true or false value (effectively on/off)
  • integer - A numerical value (whole number)
  • string - A literal sequence of characters.


What can I do with them?

There are a few different uses for variables as highlighted below
  • Add a constraint so that a macro will only fire if a variable has a certain value. In this way variables can be used like MacroDroid modes, without effecting the single global state.
  • Output the value of a variable into an SMS/email, pop up message etc.
  • Trigger another macro when a variable is set to a certain value.
  • Create simple counters so you can count how many times an event happens and then trigger another macro at a certain count.


Concrete examples

The best way to understand how to use MacroDroid variables is with some simple examples.

1) Log how many SMS have been received in a day

Macro 1: Count SMS
- Trigger: Incoming SMS (Any)
- Action: Set Variable sms_count + 1

Macro 2: Log SMS Count
- Trigger: Day Time Trigger 23:59
- Actions: Calendar - Log Event (value of sms_count)
              Set Variable sms_count = 0

At the end of each day the number of incoming sms will be written to the calendar and reset to zero, ready to count the incoming SMS for the next day.

2) Block/Unblock a macro from firing via SMS. The example macro to block is one that makes the phone buzz every 1 minute (for example if you want a regular buzz when running or similar).

Macro1: Block Buzz
- Trigger: Swipe screen (left to right)
- Actions: Set variable block_macro to true
              Pop up message "Macro Blocked"

Macro2: Enable Buzz
- Trigger: Swipe screen (right to left)
- Actions: Set variable block_macro to false
              Pop up message "Macro Enabled"

Macro3: Regular Buzz
- Trigger: Regular interval (1 minute)
- Actions: Vibrate
- Constraint: Variable (block_macro = false)

Sunday, November 3, 2013

Introducing the MacroDroid Blog

Welcome to the MacroDroid blog! Content coming soon....