Homey Community Forum

Why does this not work? (logic to calculate an average and save the result)

I am trying to calculate and save the average result of 3 sensor lux values into the logic database.

I have in my room 3 motion sensors which all suply LUX values, now i want to save the average result as logic a value so i created the following flow:

When: sensor value changes (i choose 1 sensor)
Then: calculate logic value.
I choose from list the name of the value to which to save (in my case binnenlux) and then the following as text:
I expected that it would calculate the average of these 3 sensors and save the result as value in binnenlux but nothing happens, the value is empty

[helderheid1] = sensor 1 helderheid etc, choosen from list, blue tag)
binnenlux is the logic name and is number value type

I also tried:

This is working but is NOT what i want, i want the average not the total:

Anyone an idea what i am doing wrong and how to get the average and save this?

The actual formula should use parentheses, not brackets:


Thx, tried it but still no result, the logic value is still empty

(see lowest cards)


both are empty (see lowest card)

To be clear, the full value of what you should enter in the flow card should be this:


Here’s an example that works for me:


Make sure you don’t have any additional spaces anywhere, those can cause issues.


I just noticed i now had not the double {{ and }}, added and now it is working!

thx for the help!

Is there a command for rounding up or down?
For example something like:


Logic cards support some (but not all) MathJS functions.

To round up:


To round down:


To round to two decimals: