Skip to content

BLL Math Lodash

Arie J. Godschalk edited this page Nov 15, 2026 · 3 revisions

Math.js and Lodash in BLL expressions

Method reference · Examples · Custom functions

BLL makes Math.js available as math and Lodash as _ inside expressions. These are different from BLL's formatting functions and from the older Math.js Flow cards. Use the examples as bare expressions in Execute BLL-expression (as Tag); put {[ ... ]} around them in a supported text field.

Math.js

Expression Result Use
math.round(12.345, 2) 12.35 Round to two places.
math.floor(3.9) 3 Round down.
math.ceil(3.1) 4 Round up.
math.abs(-12) 12 Absolute magnitude.
math.min(18, 21, 19) 18 Find the lowest value.
math.max(18, 21, 19) 21 Find the highest value.
math.mean([18, 21, 21]) 20 Average a list.
math.sum([2, 4, 6]) 12 Add a list.
math.sqrt(144) 12 Square root.
math.pow(2, 3) 8 Raise to a power.

For example, Temperature: {[ number(math.mean([18, 21, 21]), 1) ]} calculates the average first and then formats it as text. Use a numeric result tag if a later card needs a number, and number for display.

Lodash

Expression Result Use
_.first(["hall", "kitchen", "garden"]) hall First item.
_.last(["hall", "kitchen", "garden"]) garden Last item, as in the community example.
_.sum([2, 4, 6]) 12 Sum numbers.
_.mean([2, 4, 6]) 4 Calculate the average.
_.uniq(["a", "b", "a"]).join(", ") a, b Remove duplicates and join the result.
_.sortBy([3, 1, 2]).join(", ") 1, 2, 3 Sort numbers.
_.get({room: {name: "Kitchen"}}, "room.name") Kitchen Read a nested property.
_.get({room: {}}, "room.name", "unknown") unknown Use a default when a property is missing.
_.filter([1, 2, 3, 4], n => n > 2).join(", ") 3, 4 Keep matching values.
_.map([1, 2, 3], n => n * 2).join(", ") 2, 4, 6 Transform a list.

For an object result, use JSON.stringify if the next card expects JSON text. For a list inside a message, use join to control the separator. See the community coding post, Math.js documentation and Lodash documentation. Supported versions depend on your BLL installation.

For forum-backed uses of _.sample, _.includes, _.takeRight and numeric list totals, see text examples and lists and JSON.

Not the legacy Math.js card

In a BLL JavaScript expression use math.round(3.14159, 2). The older Execute Math.js expression card has its own syntax and substitutes variable references such as $DoorCount$; do not assume that those references work in BLL JavaScript. See BLL coding.

Clone this wiki locally