Could not cast OFF to java.lang.Number

Hi,

I have a group calculating the average dimmer value for two lights (one switch one dimmer).

Group:Dimmer:AVG EG_WZ_WL_Licht "Durchschnittliche Helligkeit  Wandlampen  (nur Status)" (EG_LivingRoom, gLight)

Now I would like to use this “average” lumination to calculate a limit value for a rule:

val light_limit_lights = 200 + (EG_WZ_WL_Licht.state as DecimalType) * 2

However I get the error mentioned in the subject… I also tried “as Number” instead without success.

Any ideas?

Daniel

A Switch is ON/OFF, it’s not a dimmer and it’s not a number. ON isn’t a number. The average of a number and ON is meaningless.

In my case a light switched on is kind of like a dimmer on 100 and off like 0.
Would there be an easy way to integrate this logic into the average?

Yes, two proxy items change them to 0 when OFF and 100 when ON
Then a group of the proxies to get the average or calculate in a rule

1 Like

What makes you think your error originates in this line? Works fine for me with a Group:Dimmer:AVG Item, Switch type members and all.

I would use as Number though, it’s generally more useful in rules unless you have a need for some other specific type.