Text-based JavaScript rule with item change from any state (optional) to a specific state

  • Platform information:
    • Hardware: Raspberry Pi 4
    • OS: CENTOS 9
    • Java Runtime Environment: OpenJDK version “21.0.10” 2026-01-20 LTS
    • openHAB version: 5.1.3
  • Issue of the topic: I want to create a text-based rule that gets triggered when an item (or group of items) changes from any value (e.g., UNDEF, OFF, null) to a specific value (e.g., ON).

As an example, I’m using the GroupStateChangeTrigger, for which the documentation says that the oldState is optional.

However, this seems a bit misleading. If I write the rule as follows, OH takes it as “when the group_Override_Automated_Scenes changes from ON to anything”:

triggers: [triggers.GroupStateChangeTrigger('group_Override_Automated_Scenes','ON')],

If I write the rule with an additional comma without parameters in between, there is an error:

triggers: [triggers.GroupStateChangeTrigger('group_Override_Automated_Scenes', ,'ON')],

How could I achieve this without writing multiple rules for each “old state”?

Try it with

triggers: [triggers.GroupStateChangeTrigger('group_Override_Automated_Scenes', undefined,'ON')]

This should be “from any state to ON”

Thanks, @Darkem.

You’re right. I had forgotten it.