Examples of LCL
Due to the complexity of the real world, we cannot offer to you examples of everything, but, here are some examples of how to use LCL in real-case scenarios.
Want to contribute?
Multiple tank level totalizer
For this example, we assume that your device sends the level of the tanks in tank.level.0
, tank.level.1
, tank.level.2
, and tank.level.3
. We want to calculate the total level of the tanks and send it to tank.level
.
SUM(
GET_PARAM(
CONCAT(
PRIMARY_DEVICE(),
".tank.level.0"
),
),
GET_PARAM(
CONCAT(
PRIMARY_DEVICE(),
".tank.level.1"
),
),
GET_PARAM(
CONCAT(
PRIMARY_DEVICE(),
".tank.level.2"
),
),
GET_PARAM(
CONCAT(
PRIMARY_DEVICE(),
".tank.level.3"
),
)
)
Let's look at the code above. We are using the SUM
function to calculate the total level of the tanks. We are using the GET_PARAM
function to get the level of each tank. We are using the CONCAT
function to concatenate the device ident with the tank level.
Alert when the temperature is too high
For this example, we assume that your device has a sensor with param engine.temperature
, and your tolerance of the temperature is 100 degrees
. We want to send an alert when the temperature is higher than 100 degrees
.
Important
GREATER_THAN(
GET_SENSOR("engine.temperature", CONSTANT(0)),
CONSTANT(100)
)
Generate an alert when Layrz Link sends a SOS
Layrz Link is our app to convert your smartphone into a GPS tracker. For this example, we will convert the SOS signal sent from the app into an alert.
Want to know more about Layrz Link?
COMPARE(
GET_PARAM(
CONCAT(
PRIMARY_DEVICE(),
".alarm.event"
),
),
CONSTANT(1)
)