Creating an alert rule
A rule watches a reading and tells you when it goes outside the range you are happy with. This guide makes one from start to finish, in the order the screen asks for it.
On this page
- What a rule does
- Before you start
- Open the Rules page
- Step 1: Name the rule
- Step 2: Choose the devices
- Step 3: Say when it should alert
- Trigger value and reset value
- Using more than one condition
- Step 4: Choose who is told
- Check the summary, then create the rule
- What happens next
- Changing, pausing or removing a rule
- Things that catch people out
- Related links
A rule watches one reading from one or more of your sensors and tells you when it goes outside the range you are happy with.
Here is the example used all the way through this guide. A greenhouse must not get colder than 5 °C at night. A rule can watch the air sensor in that greenhouse and send a message the moment the temperature drops below 5 °C, so somebody can do something about it before the plants are damaged.
Until you create a rule, CropWatch records readings but never contacts you. Rules are the part that reaches out.
You need:
- A sensor that is already sending readings. If it is not, start with Installing a gateway.
- Your CropWatch sign-in.
- An answer to four questions: which sensor, which reading, at what number, and who should be told.
- Manager level or higher on every sensor the rule will watch. With a lower level you can open the form and fill it in, but saving answers with a red message: “You do not have permission to manage one or more selected devices”. The levels are explained in Sharing access and permission levels.
- For push notifications, push turned on on your own phone or computer first. See Push notifications on phones and computers.
Making a rule takes about five minutes. Nothing you do here can harm the sensor.
- Sign in to CropWatch.
- Go to Rules in the menu. You will see a list headed Rule Templates, with any rules you already have, grouped by location. The columns are “Name”, “Assigned Devices”, “Conditions”, “Actions” and the date the rule was made, under the heading “Updated At”. Type in the search box to find a rule.
- Press the + button above the list, on the right. The form opens under the heading “Create Rule Template”.
CropWatch calls a rule a “rule template” because one rule can watch several sensors at once. It is the same thing.
The first card is headed “1. Template”. Two boxes and a switch:
- Rule Name — what you want to read in a message at two in the morning. “Greenhouse too cold” tells you more than “Temp rule 3”. This name appears in the alert you receive.
- Description — optional. A note for whoever looks at this rule next, which might be you in six months.
- Active rule — leave this switched on. Switched off, the rule is kept but never checked. That is how you pause a rule without losing it.
The second card is headed “2. Device Assignments”. Open the “Device” box and tick the sensors this rule should watch. They are grouped by location, and you can type in the box to filter the list.
You can tick more than one. Each sensor is then watched on its own: if two greenhouses both get too cold, you are told about each of them separately.
The sensors you pick here also decide who can be chosen in step 4. The Push and LINE recipient lists show the people who can see these sensors, and they stay empty until at least one sensor is ticked.
If the card shows “No devices available. Please add a device first.” instead of the box, your account has no sensors yet.
The long code in brackets after each name is the sensor's serial number. It is there so you can tell apart two sensors with the same name.
The third card is headed “3. Alert Criteria”. Its first block, “Condition 1”, holds one data field and the limit for it:
- Data Field: the reading to watch, such as Temperature (°C), Humidity (%), CO₂ (ppm), Soil Moisture or Water Depth (cm). It starts on Temperature (°C). Pick one your sensor actually measures.
- Operator: how to compare, one of “Less than (<)”, “Less than or equal (<=)”, “Greater than (>)”, “Greater than or equal (>=)” or “Equals (=)”. A new rule starts on “Greater than (>)”.
- Trigger Value: the number that sets the alert off.
- Reset Value: the number the reading must come back to before the alert can happen again. The next section explains this one properly.
Above those boxes is a preview: a number line that draws your limit as a coloured line, together with the point where it resets, so you can see which side of the number sets the alert off. Two settings sit above the number line:
- Unit: °C, °F or °K. It decides how the numbers you type are read, and the boxes show it in brackets, as in “Trigger Value (C)”. For a temperature you can switch to °F and type Fahrenheit; CropWatch saves the °C equivalent. For every other data field leave it on °C, because CropWatch converts what you type as if it were a temperature.
- Center: where the number line is centred, and the value a new threshold starts with. It is not saved with the rule.
Each threshold also has a Name and a Highlight color. They only label the line on the preview. The rule does not keep them, so they are back to “Condition 1” and the first colour when you open the rule again.
For the cold greenhouse: Data Field “Temperature (°C)”, Operator “Less than (<)”, Trigger Value 5, Reset Value 7.
The “Range” choice in the Operator list cannot be saved. If you pick it, the boxes change to Minimum and Maximum, the form says “Unsupported operator.” and the save button stays greyed out. A band of values cannot be watched with two thresholds either; the section on using more than one condition explains why.
This is the part people find confusing, and it is worth two minutes because it decides whether you get one useful message or forty useless ones.
A sensor might send a reading every ten minutes. On a cold night the temperature could sit below 5 °C for six hours. You do not want thirty-six messages.
So CropWatch does this:
- The temperature drops below 5 °C. You get one message.
- It stays below 5 °C. Nothing more is sent. The rule is holding.
- It climbs back to 7 °C. The rule resets quietly: nothing is sent, but the time appears in the rule's history.
- If it drops below 5 °C again after that, you get a new message.
The reset value is what re-arms the rule. Put it on the safe side of the trigger, with a gap:
- Watching for too low (Less than 5), the reset must be higher — 7, say.
- Watching for too high (Greater than 30), the reset must be lower — 28, say.
Put the reset on the wrong side — Greater than 30 resetting at 35 — and the rule alerts and resets on every single reading. That is the flood of messages everyone wants to avoid.
How big a gap? Enough that normal wobble does not cross it. A degree or two for temperature is usually right.
The criteria card has two add buttons, and they do different things:
- Add another threshold for this data field sits on the preview inside a condition. It adds a second limit for the same reading, as a new card. The card starts on “Equals (=)” with the Center value filled in.
- Add a condition for another data field sits below the conditions. It adds “Condition 2”, with a Data Field of its own. Once there are two, each condition gets a Remove button.
Whichever you use, every threshold and every condition in one rule must be true at the same moment for the alert to happen, and every reset value must be reached at the same moment for it to reset. That gives three cases:
- Two readings at once: “CO₂ above 1000 and humidity above 80%” is one rule with two conditions, one per data field. It resets when both readings are back past their reset values.
- Either one or the other: “colder than 5 °C or hotter than 35 °C” cannot be one rule, because the two can never both be true. Make two rules.
- Two limits on one reading: a band such as “between 20 °C and 30 °C” does not work either. The alert can go off, but the two reset values can never both be reached, so the rule fires once and stays set. Keep to one threshold per data field, and make a second rule for a second limit.
When a condition has two thresholds, the preview can show “Overlaps with Condition 1.” under the Operator, or “Reset will never happen because every reset value is covered by another alert.” under the Reset Value. The form still lets you save. Take either warning as the sign to split the thresholds into separate rules.
The fourth card is headed “4. Alert Actions”. On a new rule, CropWatch has already added “Action 1”: a push notification with your own name in Push recipients. Change it, or press Add Action for more.
Open “Action Type” and pick one:
- Push: a notification on the phones and computers of the people you choose in Push recipients. The list fills in once you have chosen sensors in step 2, and shows everyone who can see at least one of them. People who have not turned push on are greyed out with “has not subscribed to push” after their name, and cannot be picked. How to turn it on: Push notifications on phones and computers.
- EMail: type one address in the “Recipient” box. For a second address, add a second action rather than typing two addresses in one box.
- LINE: pick people in LINE recipients. Anyone shown with “LINE not linked” after their name has not connected LINE to CropWatch yet and will not receive the message.
- LoRaWAN: switches a relay instead of telling a person: turn on a heater, open a vent. It is described at the end of this section. Ask us before using this one.
About your own name on a new rule: until you choose a sensor, the box only shows your name. Once sensors are chosen, if you have not turned push on yourself, a red message appears under the box: “(your name) has not subscribed to push. Choose someone who has.” The rule cannot be saved like that. Turn push on from your Profile first, pick someone else, or change the Action Type. With nobody picked, the message reads “Select at least one recipient who has subscribed to push.”
Editing an existing rule keeps everyone already in its Push recipients, including people who have no working phone or computer at the moment; they receive alerts again once they turn push back on. Someone who stops push on their last device is taken off every rule's Push recipients automatically. When the rule fires, only people who still have access to that sensor are told.
Switching a relay. A LoRaWAN action asks for three things:
- Device: the relay controller to switch. The list shows all your sensors, not only relay controllers, so choose carefully.
- Action: “Relay 1 ON for 5 seconds”, “Relay 2 ON for 5 seconds” or “Both relays ON for 5 seconds”, or one relay “permanently ON” or “permanently OFF”. The number of seconds follows the “On time in seconds” box, which appears for the timed choices and takes 1 to 86400 seconds (one day).
- Revert relay state when the rule resets: available only for the permanent choices, and ticked by default. When the rule resets, CropWatch sends the controller a command that switches both relays off, whichever relay the action changed.
More about relays is in the relays guide.
Use “Add Action” for as many as you need. A rule can email one person, push to another and switch a heater, all at once.
The last card is headed “4. Review & Create”. Once everything above is filled in, it shows “Rule Summary”: the name, the status (“Active” or “Inactive”), the assigned sensors and the conditions, written out as, for example, “Temperature (°C) Less than (<) 5 (Reset Value: 7)”. Press Show details to see the actions and who they go to as well. Read it once. It is written the way the rule will actually behave, which is the best chance to catch a slip.
If you see “Complete all required fields above to see a preview of your rule.” instead, something is still missing. It is almost always one of these:
- No name.
- No sensor ticked.
- A trigger or reset value left empty, or a condition whose thresholds have all been removed.
- An action with nobody to send to.
- A push action whose only recipient has not turned push on.
- The “Range” operator, which cannot be saved.
Then press “Create Rule”. A green message confirms it (“Rule template "Greenhouse too cold" created successfully.”) and you are taken back to the list, where your rule now appears.
If CropWatch refuses, a red message says why. “You do not have permission to manage one or more selected devices” means your level on at least one of the sensors is below Manager; see Before you start.
The rule starts working straight away, but nothing happens until a sensor sends a reading that crosses your limit. Readings from before you made the rule are not looked at.
When it does fire, everyone on the action list is told, with the rule's name and which sensor it was. When the reading comes back past the reset value, the rule resets without sending anything: no email, LINE message or push notification says it is back to normal. The only action that does something at a reset is a relay action with “Revert relay state when the rule resets” ticked. Every reset is listed in the rule's history.
A rule can only see readings that arrive. If a sensor stops reporting — flat battery, gateway offline — a “too cold” rule stays silent, because nothing is coming in to be too cold. Check the dashboard for sensors that have gone quiet.
Each row on the Rules page has three small buttons on the right:
- The pencil opens the rule so you can change it. It is the same form; the last card is headed “4. Review & Save” and its button says “Save Changes”.
- The clock opens “View History”: every time the rule fired, and when it reset. Each event is marked “Active” or “Resolved” and shows when it “Triggered”, the reading at that moment, and how long it lasted. A rule that watches several sensors has a filter, set to “All devices”, for looking at one sensor at a time.
- The bin deletes the rule. It asks first (“Are you sure you want to delete the rule "Greenhouse too cold"? This action cannot be undone.”) and goes ahead when you press “Delete”.
To stop a rule for a while without losing it — you are working in the greenhouse and the door is open — open it with the pencil and switch “Active rule” off. Switch it back on when you are done.
Changing, pausing and deleting a rule need the same level as creating one: Manager or higher on every sensor it watches.
- The reset value on the wrong side. The commonest mistake, and it produces a stream of messages. See Trigger value and reset value.
- Expecting “or”. Conditions in one rule must all be true together. Too cold or too hot needs two rules.
- A rule left switched off. If a rule never fires, check “Active rule” first.
- A mistyped email address. Nothing warns you. The message is simply sent into nowhere.
- Someone who has not linked LINE. They appear in the list, they can be selected, and they receive nothing.
- Too tight a limit. A limit set where the reading normally sits means constant messages, and messages people ignore are worse than none.
- Waiting for a “back to normal” message. None is sent. A rule resets quietly; its history shows when.
- Two thresholds for one reading. They must all be true at once, so the rule never fires or never resets. See Using more than one condition.
- Unit switched to °F for something that is not a temperature. The number is converted as if it were a temperature. Leave Unit on °C except for temperature.
- Your own push not turned on. A new rule whose only push recipient is you cannot be saved until you turn push on. See Push notifications on phones and computers.