OH3: newState not working in switch statement (DSL rule engine)

Running the latest 3.1 snapshot and I’m fighting with the following problem:
This rule here…

var String results = ""
logInfo("pyduofern_az_spielplatz","Empfangener newState=" + newState)
switch (newState) 
{
  case UP:    
    { 
      results = executeCommandLine(Duration.ofSeconds(5),"sudo", "python3", "/home/openhabian/.local/bin/duofern_cli.py", "--up", "495dbd", "--configfile", "/etc/openhab/_duofern/.duofern.json")
      logInfo("pyduofern_az_spielplatz","Command: UP, RC=" + results)
    }
  case DOWN:  
    {
      results = executeCommandLine(Duration.ofSeconds(5),"sudo", "python3", "/home/openhabian/.local/bin/duofern_cli.py", "--down", "495dbd", "--configfile", "/etc/openhab/_duofern/.duofern.json")
      logInfo("pyduofern_az_spielplatz","Command: DOWN, RC=" + results)
    }
  default:
      logInfo("pyduofern_az_spielplatz","Unknown state: " + newState)
}  

…always ends up in the “default” part of the switch statement.

Logfile:

2021-01-10 19:42:32.717 [INFO ] [model.script.pyduofern_az_spielplatz] - Empfangener newState=ON
2021-01-10 19:42:32.727 [INFO ] [model.script.pyduofern_az_spielplatz] - Unknown state: ON

Any ideas what I could do to make the switch statement based on “newState” work?

Without knowing which item-type is triggering the rule we can’t help.
Reading the docs would show: “implicitly available in every rule that has at least one status update or status change event trigger.”
You are expecting states of UP and DOWN , however you do receive ON , there must be something wrong.

1 Like

It’s a simple switch:


(I’m using a switch instead of rollershutter because the underlying script doesn’t support a STOP command - so I use “ON” for moving up and “OFF” for moving down)

Although the received value says ON or OFF in the first logInfo line, the switch-statement doesn’t fire and always end up in the default branch of the switch statement.

What makes you think your rule checking for UP or DOWN would trigger on ON or OFF ?

1 Like

:joy::joy::joy: You‘re right. Sometimes is hard to see the problem right in front of you :+1: