"Member of DimmerGroup update OFF" not working after Upgrade from OH 3.x to OH 4.3.4

Hi,
I am struggeling to understand s.th. in openhab.

I have a Dimmer-Item “Dimmer” and a Group “DimmerGroup” with that item.

In OpenHab 3.x the following rule was able to trigger, whenever the item when from Off to On, or the other way:

rule “LightControl-LightsOff”
when
Member of DimmerGroupreceived update OFF
then

This triggered correctly in OH 3.x.

In OpenHAB 4.3.4 this did not longer work, and I had to update the rule to

rule “LightControl-LightsOff”
when
Member of DimmerGroupreceived received update OFF or
Member of DimmerGroupreceived changed to 0 or
Member of DimmerGroupreceived changed to 0.0
then

to work again.

What am I missing, because this is not very usable?

Thanks for any insight!

A Dimmer Item (also true for a Group:Dimmer Item) will always represent its state as a Number (and under normal circumstances it should be an Integer). So either you did not use a Dimmer Item in OH3, or you used received command OFF instead of received update OFF.

Maybe you had a copy-paste issue and the Group Item is DimmerGroup instead of DimmerGroupreceived?

A more simple solution would be to use

when
    Member of DimmerGroup changed
then
    if(triggeringItem.getStateAs(OnOffType) != OFF)
        return;

    // your code goes here
   ...

So the rule is triggered for each changed event, but the first line of code checks whether the new state as OnOffType is not OFF and stops the rule if true.

Hi,
thanks.

I am using version control on my textual files (rules).
I am fairly certain that the previous version looked as described - which I have to admit feels intuitive for the “on/off” state of dimmer-items. In particular if there is still a “[[openhab.event.ItemStateEvent] - Item ‘Dimmer’ shall update to OFF.” event. There is an ON event, too.

But with your explanation I can fix the issue in a better way.

Thanks

No, it should never have updated to ON nor OFF, as the state of a Dimmer Item is always of Type Number.
You can get the state as OnOffType as shown above (.getStateAs() is a method for at least some Item types), but not as a trigger.
And of course a Dimmer Item has valid commands ON, OFF, INCREASE, DECREASE and the Numbers 0 to 100, so you can get these commands as received command.