WattLoft

Alerts & automations

How to build your first Tesla automation

An automation is “when X, do Y”, evaluated on the server so it works with every app closed. Here is the builder, the safeguards around it, and three recipes to copy.

By the WattLoft team5 min read

The WattLoft automation builder with a value trigger held for a duration, conditions and a list of actions

Tesla’s own app can schedule charging and a departure time, and not much else. Anything shaped like “when this happens, do that” needs a rule engine: warm the car on weekday mornings if the sun is out, stop charging when the peak tariff starts, say something when the parked car will not go to sleep.

WattLoft has one. It runs on the server, so an automation works with every app closed and the phone switched off.

You need a WattLoft account with a car connected (connecting your Tesla). Automations that send commands also need the car’s virtual key. One that only sends a notification needs neither the key nor a waking car.

How an automation is put together

Every automation has the same three parts, and a cooldown.

  • When is one trigger: the thing that starts it.
  • Only if is a list of conditions that must hold at that moment. It can be empty.
  • Then do is one or more actions, run in the order you list them.

Create one

  1. Open the Automations tab and press New automation. Give it a name you will recognise in the Alerts list.
  2. Under When, choose one trigger.
  3. Under Only if, add conditions if you need them, joined with all of these are true or any of these is true.
  4. Under Then do, add the actions in the order they should run.
  5. Set Cooldown (minutes), from 1 to 1440. The default is 15.
  6. Save it. The automation becomes a card with a switch, Run now, Edit and Delete.

The triggers

TriggerExample
A value changesThe cabin is above 23 °C for 5 minutes
At a time of day07:30, Monday to Friday
Every N minutesEvery 30 minutes
Something happensCharge complete, Someone got in, Windows open and rain coming
The car arrives at or leaves a saved placeThe car leaves Home
Sunrise or sunset30 minutes before sunset

A value trigger takes any field the car reports, an operator (is above, is at least, is below, is at most, equals, is not, is on, is off), a value in your units and, optionally, how long it must hold.

“Something happens” reuses the notification rules, so anything in the alerts guide can start an automation. Places are geofences: Add a place gives one a name, a position and a radius, 150 m by default and 25 m at the least. Sunrise and sunset are worked out for where the car is.

Conditions and actions

Conditions test a value, where the car is (at or away from a place), the time of day (a window, which may cross midnight) or the day of the week. Value conditions are how you test the weather, the charger or the plug: RainSoon is on, DetailedChargeState equals Charging, ChargePortLatch equals Engaged.

Actions are every command the car supports, such as Climate on, Set temperature, Charge limit, Stop charging, Lock, Sentry mode and Vent / close windows, with their arguments typed in your units. The engine adds three of its own: Send a notification, Wake the car and Wait before the next action, up to 600 seconds.

A notification’s text can quote the car. {car} is at {battery}, {range} left becomes “Model S is at 39 %, 168 km left”. A row of chips under the message box inserts the placeholders, and a preview line shows the message with the live values filled in.

The safeguards

These actuate a real car, so the engine is careful.

  • Edge-triggering. A value automation fires on the change into its condition, not again and again while the condition holds.
  • Cooldown. The least time between two runs of the same automation.
  • Auto-wake. A sleeping car refuses most commands, so the engine wakes it before the first real command and waits for it to answer. A notification-only automation never wakes the car and never spends a Tesla call.
  • Already set. A command the car already satisfies, a limit that is already 80% or doors that are already locked, counts as done rather than as a failure.
  • A record. Every run lands in Alerts as “Automation: name — Triggered by …, Ran …”. A failed run is always reported.

Run now on a card runs the automation immediately. It ignores the trigger but respects the conditions, which makes it the easy way to test one.

Three recipes to copy

Precondition at 7:30 if it is sunny

When: At a time of day, 07:30, Monday to Friday. Only if: a value, Sunny is on; add OutsideTemp is below 10 if you only want it on cold mornings. Then do: Climate on, then Send a notification: Warming {car} — {weather}, {outside} outside, sun {sun}. The engine wakes the car first. What the warm-up costs is covered in Tesla range in winter.

Stop charging when the expensive tariff starts

WattLoft has no live electricity-price feed, so a price cap is expressed as the hours your tariff is expensive. When: At a time of day, 07:00, every day. Only if: a value, DetailedChargeState equals Charging. Then do: Stop charging, then Send a notification: Paused charging {car} at {battery} — peak rate until 23:00. A second automation at 23:00 with Start charging resumes it. Your home rate then prices the session correctly; see tracking what charging costs.

Tell me when something keeps the car awake

When: A value changes, IdleDrainW is above 300 for 15 min. Then do: Send a notification: {car} has drawn {drainawake} while awake today — {idledrain} right now. Cooldown: 120. The built-in rule Awake drain above does the same with a standard message; the background is in Tesla phantom drain.

More recipes, the full list of placeholders and every trigger are in the Automations chapter of the manual. One worth copying next closes the windows before rain: windows open and rain coming.

Frequently asked questions

Do WattLoft automations run when the app is closed?

Yes. Automations are evaluated on WattLoft’s server, so they run with every app closed and the phone off.

Will an automation wake my Tesla?

Only when it has a command to send. The engine wakes a sleeping car before the first command; an automation that only sends a notification never wakes the car and never spends a Tesla call.

What stops an automation from firing over and over?

Two things. Value triggers are edge-triggered, so they fire once on the change into the condition, and every automation has a cooldown, 15 minutes by default, that sets the least time between two runs.

Do I need the virtual key for automations?

For automations that send commands, yes: cars from about 2021 onwards only accept signed commands, and the car honours them once the virtual key is paired. Notification-only automations work without it.