Skip to content

Latest commit

 

History

History
87 lines (55 loc) · 2.57 KB

MIGRATE.md

File metadata and controls

87 lines (55 loc) · 2.57 KB

Migrate JRule to JRuleXXX

Triggers

Item changed to ON

@JRuleWhen(item = _MyTestSwitch.ITEM, trigger = _MyTestSwitch.TRIGGER_CHANGED_TO_ON)

->

@JRuleWhenItemChange(item = _MyTestSwitch.ITEM, to = JRuleSwitchItem.ON)

Item changed from OFF to ON

@JRuleWhen(item = _MyTestSwitch2.ITEM, trigger = _MyTestSwitch2.TRIGGER_CHANGED_FROM_OFF_TO_ON)

->

@JRuleWhenItemChange(item = _MyTestSwitch2.ITEM, from = JRuleSwitchItem.OFF, to = JRuleSwitchItem.ON)

Item received command

@JRuleWhen(item = __MyTestSwitch2.ITEM, trigger = __MyTestSwitch2.TRIGGER_RECEIVED_COMMAND)

->

@JRuleWhenItemReceivedCommand(item = _MyTestSwitch2.ITEM)

Item changed with conditional check

@JRuleWhen(item = _MyTemperatureSensor.ITEM, trigger = _MyTemperatureSensor.TRIGGER_RECEIVED_UPDATE, lte = 20)

->

@JRuleWhenItemChange(item = _MyTemperatureSensor.ITEM, condition = @JRuleCondition(lte = 20))

Channel changed

@JRuleWhen(channel = "binding:thing:buttonevent")

->

@JRuleWhenChannelTrigger(channel = "mqtt:topic:mqtt:generic:numberTrigger")

Cron

@JRuleWhen(cron = "4 * * * * *")

->

@JRuleWhenCronTrigger(cron = "*/5 * * * * *")

Time

@JRuleWhen(hours = 3)

->

@JRuleWhenTimeTrigger(hours=3)

Thing changed

@JRuleWhen(thing = "*", trigger = JRuleThingStatusTrigger.TRIGGER_CHANGED, from = "ONLINE")

->

@JRuleWhenThingTrigger(from = JRuleThingStatus.ONLINE)

Precondition

Item must be equal to

@JRulePrecondition(item=_MyTestDisturbanceSwitch.ITEM, eq = "ON")

->

@JRulePrecondition(item = _MyTestDisturbanceSwitch.ITEM, condition = @JRuleCondition(eq = "ON"))

JRuleEvent

JRuleEvent is now abstract with 4 concrete implementations

  • JRuleItemEvent
  • JRuleChannelEvent
  • JRuleTimerEvent
  • JRuleThingEvent Depending on the trigger that was fired, the respective event will be thrown. You can use the abstract JRuleEvent as method parameter or a concrete one, but take care to be sure that just this event can be thrown. Otherwise an exception will occur.

Examples

Correct

Trigger for an Item will inject an JRuleItemEvent as method parameter For the method you can use JRuleEvent (has to be cast to get the interesting information) or JRuleItemEvent

Incorrect

  • Trigger for a Thing and use JRuleItemEvent as method parameter -> Exception
  • Trigger for an Item and a Cron and use JRuleItemEvent -> Exception when the method will be trigger for cron