Docs

Rules

The Rules widget holds if-then logic. The server watches the pins and acts when a condition is met.

Use it for: turn the fan on above 28 degrees, send a notification when the tank drops below 20 per cent, close the valve if the flow meter stops.

SettingWhat it does
Rulesthe list of conditions and actions
Conditiona pin compared against a value
Actionwrite a pin, send a notification, send an email
Enabledswitch a rule off without deleting it

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

Why put logic here

The rule lives on the server, not in the sketch. Changing a threshold from 28 to 26 degrees takes a tap, with no recompiling and no cable.

Your board keeps doing one job: report readings and act on pins.

Writing a rule

A rule needs a pin to watch, a comparison, and something to do.

V2 > 28 then write V1 to 1 turns the fan on when the temperature passes 28 degrees. Add the opposite rule, V2 < 26 writes V1 to 0, and the fan switches off two degrees lower.

Those two degrees are the point. A single threshold makes the fan chatter on and off around 28.

What runs where

Rules need the pin values to reach the server, so they work on virtual pins your sketch writes with Plynx.virtualWrite().

Rules fire while your phone is closed. The app only edits them.

Troubleshooting

ProblemCheck
Rule never firesthe pin has no incoming values; check virtualWrite()
Output chatters on and offone threshold for both directions; use two rules with a gap
Rule fires but the board ignores itthe target pin has no handler in the sketch
Rule fires latethe value reaches the server on your interval, not instantly

Next