How To Call It
Automation is a global table: call its functions with a dot (Automation.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
Checks current device state against a condition tree and returns two booleans, matched and known. The first is true only when the verified condition is met.
Documented for app version 1.0.64Updated:
Automation is a global table: call its functions with a dot (Automation.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
Checks current device state against a condition tree and returns two booleans, matched and known. The first is true only when the verified condition is met.
Accepts a table or JSON tree. Leaf: kind="leaf", leafType and condition fields. Group: kind="group", operator="and"/"or", children. negate=true negates a node. An unknown result returns false, false and does not grant permission under tree-level NOT; decisive AND/OR branches may return known=true. For a negative Lua check use known and not matched. Malformed trees raise an error. The battery above threshold is inclusive: >=. New leaves: airplane_mode, nfc_enabled, location_enabled, music_active; battery_temperature {temperatureCelsius=30, comparisonMode="above"|"below"} (-50–150 °C, inclusive); weekdays {weekdays={1,2,3,4,5}} (ISO Monday=1, Sunday=7; unique and nonempty); day_of_month {dayStart=28,dayEnd=3} (inclusive 1–31, wrapping across the month boundary when start exceeds end); charging_source {chargingSource="ac"|"usb"|"wireless"|"dock"}; month_of_year {months={1,6,12}} (unique nonempty 1–12; default all months); time_since_boot {durationMs=60000,comparisonMode="above"|"below"} (0–315360000000 whole ms, default 0; inclusive >=/<=); auto_brightness (no parameters); brightness_level {levelPercent=50,comparisonMode="above"|"below"} (finite 0–100, default 50; inclusive >=/<=). New fields are additive; irrelevant nondefault values are rejected.
Device Conditions mode in the Compare block performs the same check. Location reads only the device location switch, not GPS coordinates. NFC does not read tags; music checks overall music activity without selecting an app. Battery temperature is not CPU temperature. Month uses the current local calendar; elapsed boot time uses SystemClock.elapsedRealtime including sleep, independent of the wall clock. Brightness is the configured Android 0–255 setting percentage, not physical nits or an app override. Automatic brightness requires a known mode; use known and not matched to check manual mode. This call does not register listeners or wait for an event; use Trigger.run/watch for that.
The snippet below is a starter pattern that can be applied directly in runtime flow.
if Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
endFrom foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
if Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
endlocal stepOk = true
if Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
end
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
if Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
end
end)
if not ok then
print("API step failed: Automation.check: " .. tostring(err))
requestStop()
end-- Automation.check(constraintTree)
local function run_check_step()
if Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
end
end
local ok, err = pcall(run_check_step)
if not ok then
toast("Step failed")
print(err)
endif Automation.check({kind="leaf", leafType="battery", batteryMode="above", batteryPercent=20}) then
Automation.action("toast", {text="Battery condition passed"})
end