Help write an Expression to show average values from variable of devices

In some pistons I have a device variable that I have assigned multiple devices to.

While it is easy to use the log>physical devices to return the average value of a specific type(illumination, temperature, dimmer level) I want to also be able to log this as a piston state using an expression.

This could be something like "the average temperature or average dimmer levels are: xx" But I am having trouble writing this out as an expresion. What am I doing wrong?


Why not set a variable with the value then use that in your set piston state

Others may have another idea

is it possible you can use:

I use AP to maintain an average of temp and humidity for my dashboard and for use in rules:
image

Thanks for convincing me to go with the easy workaround. Hehe