Multiple case in switch statement

I am already using a switch in my Rules:

rule "HK_Pumpe_Status an/aus berechnen"
when
	System started or
	Item PU_HK_Heizkreispumpe received update
then
	val String status = PU_HK_Heizkreispumpe.state.toString

	switch status
	{
		case "Ein": PU_HK_Pumpe_Status.postUpdate(ON)

		case "Aus": PU_HK_Pumpe_Status.postUpdate(OFF)

		case "Aus Übertemperatur":
		{
			PU_HK_Pumpe_Status.postUpdate(OFF)
			logWarn ("my.rules", "PU: HK-Pumpe wegen Übertemperatur ausgeschaltet!")
		}

		case "Undefined": { }
		case "Uninitialized": { }

		default:
		{
			logWarn ("my.rules", "PU: Bug: HK-Pumpe-Status '"+status+"' nicht Ein oder Aus!")
		}
	}
end

But I am wondering, is there a way to have multiple case-statements in the same line, like:

		case "Undefined", "Uninitialized": { }

or (for Number items)

		case 1..2: // do something

Sorry, if the “multiple case” has been discussed here already, but I wasn’t able to find it when searching for it.

JavaDoc also mentions something like:

		case "Undefined": case "Uninitialized": { }

but this doen’t work. I am always getting:

2019-03-04 16:31:44.043 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Test': Ambiguous methods

Stefano

    case "Undefined",
    case "Uninitialized": { }
1 Like

Hi Rich,
thanks, but it still logs an error:

2019-03-04 18:09:19.419 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Test': Ambiguous methods [protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAssignment(org.eclipse.xtext.xbase.XAssignment,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object [...] org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateWhileExpression(org.eclipse.xtext.xbase.XWhileExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator)] for params [null, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@2a273aa4, org.eclipse.xtext.util.CancelIndicator$1@7509eeaf]

Maybe, I forgot to say, I am running openHAB 1.8.2 :grimacing:
Stefan

I’m not going to be much help to you then. There has been like three years of changes since 1.8. I can barely keep up with changes from one version to the next.

The ambiguous methods error is not related to the Switch statement or even coming from this Rule. Something in a Rule named “Test” is ambiguous to the Rules Engine. For example if you try to sendCommand a DecimalType to a Number Item you will have this error because DecimalType is also of type Number and there is a sendCommand(DecimalType) and a sendCommand(Number) on NumberItem and the Rules Engine doesn’t know which one you mean.

Hi Rich,
I think multiple cases just don’t work.

The following code works for h = 23, 11, 12, 17, and 22, so for lines that have a command, but it does not for h = 5:

rule "Test"
when
	Time cron "*/30 * * * * ?" or
	System started
then
	logInfo ("Test", "0")

	val int h = 5

	switch h
	{
		case 0,
		case 1,
		case 2,
		case 3,
		case 4,
		case 5,
		case 23: logInfo ("Test", "night")

		case 6,
		case 7,
		case 8,
		case 9,
		case 10,
		case 11: logInfo ("Test", "morning")

		case 12: logInfo ("Test", "noon")

		case 13,
		case 14,
		case 15,
		case 16,
		case 17: logInfo ("Test", "afternoon")

		case 18,
		case 19,
		case 20,
		case 21,
		case 22: logInfo ("Test", "evening")
	}
end

And this is, what is logged:

2019-03-06 10:11:43.877 [INFO ] [o.model.script.openHAB started] - System started
2019-03-06 10:12:10.330 [INFO ] [org.openhab.model.script.Test ] - 0
2019-03-06 10:12:10.373 [ERROR] [m.r.internal.engine.RuleEngine] - Error during the execution of startup rule 'Test': Ambiguous methods [protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAssignment(org.eclipse.xtext.xbase.XAssignment,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(org.eclipse.xtext.xbase.XBlockExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateCastedExpression(org.eclipse.xtext.xbase.XCastedExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateClosure(org.eclipse.xtext.xbase.XClosure,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateConstructorCall(org.eclipse.xtext.xbase.XConstructorCall,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected org.eclipse.xtext.xbase.interpreter.IEvaluationResult org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateDoWhileExpression(org.eclipse.xtext.xbase.XDoWhileExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateForLoopExpression(org.eclipse.xtext.xbase.XForLoopExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateIfExpression(org.eclipse.xtext.xbase.XIfExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateInstanceOf(org.eclipse.xtext.xbase.XInstanceOfExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateNullLiteral(org.eclipse.xtext.xbase.XNullLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateReturnExpression(org.eclipse.xtext.xbase.XReturnExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateStringLiteral(org.eclipse.xtext.xbase.XStringLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateSwitchExpression(org.eclipse.xtext.xbase.XSwitchExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateThrowExpression(org.eclipse.xtext.xbase.XThrowExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateTryCatchFinallyExpression(org.eclipse.xtext.xbase.XTryCatchFinallyExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateTypeLiteral(org.eclipse.xtext.xbase.XTypeLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateWhileExpression(org.eclipse.xtext.xbase.XWhileExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator)] for params [null, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@347130cd, org.eclipse.xtext.util.CancelIndicator$1@42bc36f]
2019-03-06 10:12:22.373 [INFO ] [org.openhab.model.script.Test ] - 0
2019-03-06 10:12:22.378 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Test
java.lang.IllegalStateException: Ambiguous methods [protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAssignment(org.eclipse.xtext.xbase.XAssignment,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(org.eclipse.xtext.xbase.XBlockExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateCastedExpression(org.eclipse.xtext.xbase.XCastedExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateClosure(org.eclipse.xtext.xbase.XClosure,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateConstructorCall(org.eclipse.xtext.xbase.XConstructorCall,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected org.eclipse.xtext.xbase.interpreter.IEvaluationResult org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateDoWhileExpression(org.eclipse.xtext.xbase.XDoWhileExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateForLoopExpression(org.eclipse.xtext.xbase.XForLoopExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateIfExpression(org.eclipse.xtext.xbase.XIfExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateInstanceOf(org.eclipse.xtext.xbase.XInstanceOfExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateNullLiteral(org.eclipse.xtext.xbase.XNullLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateReturnExpression(org.eclipse.xtext.xbase.XReturnExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateStringLiteral(org.eclipse.xtext.xbase.XStringLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateSwitchExpression(org.eclipse.xtext.xbase.XSwitchExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateThrowExpression(org.eclipse.xtext.xbase.XThrowExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateTryCatchFinallyExpression(org.eclipse.xtext.xbase.XTryCatchFinallyExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateTypeLiteral(org.eclipse.xtext.xbase.XTypeLiteral,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateWhileExpression(org.eclipse.xtext.xbase.XWhileExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator)] for params [null, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@28504489, org.eclipse.xtext.util.CancelIndicator$1@42bc36f]
	at org.eclipse.xtext.util.PolymorphicDispatcher.handleAmbigousMethods(PolymorphicDispatcher.java:308) ~[na:na]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:283) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateSwitchExpression(XbaseInterpreter.java:360) ~[na:na]
	at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
	at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
	at org.openhab.model.script.internal.engine.ScriptImpl.execute(ScriptImpl.java:59) ~[na:na]
	at org.openhab.model.rule.internal.engine.ExecuteRuleJob.execute(ExecuteRuleJob.java:55) ~[na:na]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz-all-2.1.7.jar:na]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-all-2.1.7.jar:na]
2019-03-06 10:12:32.719 [INFO ] [org.openhab.model.script.Test ] - 0

Best regards,
Stefano

I just copied your code in my config and it is working.

But I’ll bet you are not OH 1.8. Useful to know, though.

@rossko57: I am running openHAB 1.8.2

@HomeAutomation: Which OH version?

I’m running OH 2.4. Could be the case.

I suspect case statements like this was added after OH 1.8 then.

Is it still not possible (when you’re on the latest OH3.X stable version) to use a range of numbers in one case statement?

Because I have a rollershutter that I also like to add to HomeKit, but in that case HomeKit wil send a number where the rollershutter position should go. 100 is open and 0 closed but if you want it half closed, it will send 50 for example.
So if I want to implement this to a rule I should get 100 lines of cases…

Now the rule is quite simple (and I like to keep it that way):

rule "Rollershutter back"
when
    Item shutterBack received command
then
val mqttActions = getActions("mqtt","mqtt:broker:mosquitto")
    switch (receivedCommand) {
        case UP :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutteropen")
        case STOP :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutterstop")
        case DOWN :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutterclose")
    }
end

If I could add something like:

case 1-100 :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/ShutterPosition1")

Could that work?

default?

Some ideas in this thread

Thanks for the quick answer, are there some documentations how to use this default option? Don’t get it quite yet by reading this thread, also a search on the web on “openhanded default rule” didn’t gave me the results I’m looking for.

Rules DSL is based on the Xtend language. There is a link to the Xtend docs in the Rules DSL docs. The reference for switch is here: Xtend - Expressions

You will see that you can use a full boolean expression for the case so the following should work:

case receivedCommand >= 1  && receivedCommand <= 100 :

The last part of that section discusses fall through which is a standard behavior with switch statements in all programming languages. default is the clause if no other case matches.

Thanks, that looks great, I now see how the thread could have helped me :slight_smile: so I first adjusted the rule to this:

rule "Rollershutter back"
when
    Item shutterBack received command
then
val mqttActions = getActions("mqtt","mqtt:broker:mosquitto")
    switch (receivedCommand) {
        case UP :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutteropen")
        case STOP :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutterstop")
        case DOWN :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/Backlog", "shutterclose")
        case receivedCommand => 0  && receivedCommand <= 100 :
            mqttActions.publishMQTT("cmnd/Shelly25RollerShutter_Back/ShutterPosition1", "50")
    }
end

First with a fixed output command over MQTT to see if it works, but it keeps giving me this error:

2022-12-07 19:01:47.394 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'shutterBack' received command 0
2022-12-07 19:01:47.404 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'shutterBack' changed from 100 to 0
==> /var/log/openhab/openhab.log <==
2022-12-07 19:01:47.404 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'rollershutterCommand-1' failed: An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(T,org.eclipse.xtext.xbase.lib.Procedures$Procedure1) on instance: null in rollershutterCommand

I don’t get where the null should come from, because you can see that it receives a number value…
Any thoughts?

null comes in any time you Xtend can’t figure out what to do based on the current context.

=> is a completely different operator (called a double arrow and I can’t imagine you will ever encounter this operator while writing rules) from >= (greater or equal than). They do different things and are not interchangeable.

When you want to make a comparison, the > or < always goes first.

I’m not sure that is possible; receivedCommand is a command type object, not a numeric variable. Try
receivedCommand as Number <= 100

Unfortunately that results in the following error when I try to save the rule:
2022-12-08 00:05:16.124 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'rollershutterCommand.rules' has errors, therefore ignoring it: [13,76]: no viable alternative at input '100'

Line 13 is this one in the rule:
case receivedCommand => 0 && receivedCommand <= 100 :
And character 76 is the “<” symbol.

Yoou don’t seem to have acted on either of the suggestions?

1 Like