Rules not working after migration from 2.5 to 3.0

Hello,

after my migration from OH2.5 to OH3.0 two rules arent working anymore and i dont really know, whats the reason.

Rule 1:

Error message:

18:06:11.127 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'notifications_luftfeuchtigkeit-1' failed: Conversion = ')' in notifications_luftfeuchtigkeit

Rule:

rule "Luftfeuchtigkeit_Wohnzimmer_zu_hoch"
when
	Item HM_WZ_Heizung_Humidity changed
then
	if ((HM_WZ_Heizung_Humidity.state >= 60 && previousState <  60) && (Notification_High_Humidity.state == ON)) {
		val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot1_Alexander")
    	telegramAction.sendTelegram(1234567890,"Im Wohnzimmer ist die Luftfeuchtigkeit zu hoch ("+HM_WZ_Heizung_Humidity.state+"%).")
	}
end
rule "Luftfeuchtigkeit_Wohnzimmer_wieder_ok"
when
	Item HM_WZ_Heizung_Humidity changed
then
	if ((HM_WZ_Heizung_Humidity.state < 60 && previousState >=  60) && (Notification_High_Humidity.state == ON))  {
		val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot1_Alexander")
    	telegramAction.sendTelegram(1234567890,"Im Wohnzimmer ist die Luftfeuchtigkeit wieder ok ("+HM_WZ_Heizung_Humidity.state+"%).")
	}
end

Rule 2:
Error message:

18:47:51.558 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'heizung_calc_valvelevel-4' failed: cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.items.Item.getState() on null in heizung_calc_valvelevel

Rule:

rule "Umrechnung Ventilstellung HM_WZ_Heizkoerper_K_Level"
when
    Item HM_WZ_Heizkoerper_K_Level changed
then
    var valvelevel_wz_k = triggeringItem.state as Number
    HM_WZ_Heizkoerper_K_Valve.postUpdate(valvelevel_wz_k * 100)
end

Would be great, if someone could help me getting these rule running again.

Thanks, Alex

Implicit variable triggeringItem no longer works for non-Group style triggered DSL rules in OH3 (it only works with “Member of xxx” triggers)

A new implicit variable triggeringItemName is available instead, but you must then access the real Item from its name string if you need it.

For your one-Item triggered rule you might as easily just use the Item directly.

1 Like

Thank you! Now this rule is running fine, again.

Would be great, if someone has an idea for this, too. Looking forward for your help!
Thanks in advance!

Thanks for the hint. I guess this was one big change in OH3. Wouldn’t it be the best solution to use newState instead of triggeringItem.state, instead of looking up the item by its name string?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.