Docs

Automation

The Automation widget switches a pin at a time you set. The server runs the schedule, so it fires whether or not your phone is on.

Use it for: garden lights at sunset, a pump for ten minutes each morning, a heater before you wake up, an aquarium light cycle.

SettingWhat it does
Pinthe pin the schedule writes to
Start time, Stop timewhen to send the on and off values
Start value, Stop valuethe numbers sent at those times
Dayswhich days of the week it runs
Sunrise, sunsetoffsets from the sun instead of a clock time

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Example

On a virtual pin, the schedule calls your handler like any other widget.

automation.ino
#include <PlynxSimpleEsp32.h>

#define LIGHT_PIN 26

PLYNX_WRITE(V25)
{
  digitalWrite(LIGHT_PIN, param.asInt() ? HIGH : LOW);
}

void setup()
{
  Serial.begin(115200);
  pinMode(LIGHT_PIN, OUTPUT);

  // Auto setup: WiFi and the Plynx token are configured from the app.
  //
  // To provide them directly in the sketch instead, use:
  //   Plynx.begin(auth, ssid, pass);
  Plynx.begin();
}

void loop()
{
  Plynx.run();
}

On a digital pin you write no code at all. The server sets the pin directly.

The schedule needs the board online at the moment it fires. A board that reconnects at 09:05 never sees the 09:00 event, so ask for the current state on connect:

Catch up after a reconnect
PLYNX_CONNECTED()
{
  Plynx.syncVirtual(V25);
}

Setting the schedule

Configure has a switch for Start time and one for Stop time. Turn a switch on and a time wheel appears below it, with the value to send underneath.

Leave Stop off and the automation only turns things on. That suits a pump you stop from a Button, and a light that another rule turns off.

Each time can be a clock time, sunrise or sunset, with an offset in minutes. Sunset minus 15 lights the garden a quarter of an hour before dark, all year, without you touching it again.

Sunrise and sunset need a location, which comes from your phone. Grant location access when the app asks, or those options have nothing to compute from.

Troubleshooting

ProblemCheck
Nothing happens at the set timethe board was offline; add syncVirtual on connect
Fires an hour early or latethe project time zone in the settings
Sunset options greyed outlocation permission was denied
Runs on the wrong daysthe Days row in the widget settings

Next