What are alert rules?¶
We want to give farmers the possibility to decide when they want to get notified about module-related data.
To achieve this goal, farmers can configure custom rules for data of any type, based on rule definitions that vendors provide in their module. Vendors define what data they allow to create rules for and how the rules can look.
Therefore, we need some kind of instruction set on what rules can happen and what data type, operators, and/or values are needed to create such rules. In general, rules are logical conditions between one or more operators. A classic example is a condition with an integer value that is true when it is greater than a certain value:
Example of an easy implementation. Please look at Alert Rules for a detailed description of rule definitions.
temperature is greater than 30 degrees Celsius
In this example, we have the following logic:
- left operand , the key/identifier "temperature"
- operator , greater than
- right operand , the value
To give the farmer the possibility to create rules like this, we need to provide information on what the left operand (aka key/identifier) is and what operators are possible (e.g., equal, not equal, greater/less than, etc.) to configure custom rules. The right operand would be a "value" in this case because it is a number and can be set by the user as they want the rule to execute.
To keep it as simple but also as dynamic as possible, rules are created from unlimited parts
or fields.
temperature:
# Display name of the attribute in different languages
displayName:
en: Temperature
es: Temperatura
de: Temperatur
# Description of the attribute in different languages
description:
en: Temperature of the device
es: Temperatura del dispositivo
de: Temperatur des Geräts
# Parts of the criteria (to build UI components for the rule builder)
parts:
operator:
# type of the part (select = dropdown)
field: select
# Display name of the part in different languages
title:
en: Operator
es: Operador
de: Operator
# Possible values for the part (in different languages - the key is the value that is used in the rule)
values:
eq:
en: Equals
es: Igual
de: Gleich
gt:
en: Greater than
es: Mayor que
de: Größer als
value:
# type of the part (text = input field)
field: text
# Display name of the part in different languages
title:
en: Value
es: Valor
de: Wert
# Type of the input field (number = number input, text = text input)
type: number
The left operand is defined by the key/identifier or also called criteria:
temperature:
# Display name of the attribute in different languages
displayName:
en: Temperature
es: Temperatura
de: Temperatur
# Description of the attribute in different languages
description:
en: Temperature of the device
es: Temperatura del dispositivo
de: Temperatur des Geräts
operator:
# type of the part (select = dropdown)
field: select
# Display name of the part in different languages
title:
en: Operator
es: Operador
de: Operator
# Possible values for the part (in different languages - the key is the value that is used in the rule)
values:
eq:
en: Equals
es: Igual
de: Gleich
gt:
en: Greater than
es: Mayor que
de: Größer als
value:
# type of the part (text = input field)
field: text
# Display name of the part in different languages
title:
en: Value
es: Valor
de: Wert
# Type of the input field (number = number input, text = text input)
type: number
HortiView will interpret the rule definitions file and create a rule definition for each combination possibility. After farmers create a rule via the alert management, the configured rules for your module can be received via an endpoint1. We will provide all the rule information, including the most important part, looking something like this:
- For a more detailed explanation, follow this detailed instruction: Rule Definition
- You can interpret the rules and raise notifications via: Raise Notifications
-
The endpoint isn't fully defined right now. ↩