Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule condition with DSL script results in error. #1946

Closed
gnlpfjh opened this issue Dec 16, 2020 · 1 comment · Fixed by #1952
Closed

Rule condition with DSL script results in error. #1946

gnlpfjh opened this issue Dec 16, 2020 · 1 comment · Fixed by #1952
Labels
automation bug An unexpected problem or unintended behavior of the Core

Comments

@gnlpfjh
Copy link

gnlpfjh commented Dec 16, 2020

I get the folowing error if I use a DSL script as condition ("But only if") in a rule.

16:10:52.358 [ERROR] [re.automation.internal.RuleEngineImpl] - Failed to execute rule 'eba3ad4b4b': null
16:10:52.359 [DEBUG] [re.automation.internal.RuleEngineImpl] -
java.lang.NullPointerException: null
        at org.openhab.core.automation.module.script.internal.handler.ScriptConditionHandler.isSatisfied(ScriptConditionHandler.java:58) ~[?:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.calculateConditions(RuleEngineImpl.java:1147) ~[bundleFile:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:983) [bundleFile:?]
        at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
1

Test case (tested with Build 2050 and 2081):
I've created two Switch Items TestItem1 and TestItem2 to trigger the folowing rule.

triggers:
  - id: "1"
    configuration:
      itemName: TestItem1
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: "true"
    type: script.ScriptCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: TestItem1
      command: ON
    type: core.ItemCommandAction

I've tried it with different scripts: 'true', 'return true'... I can log some message but at the end it always results in the same error.

I briefly looked in the source code and found that the eval method in DSLScriptEngine.java always returns null. I'm not sure but it looks to me like that is the problem.

@cweitkamp
Copy link
Contributor

I have to admit that I do not know how the script should look like. But I submitted #1948 to prevent the NPE.

@cweitkamp cweitkamp added bug An unexpected problem or unintended behavior of the Core automation labels Dec 16, 2020
cweitkamp pushed a commit that referenced this issue Dec 16, 2020
Fixes #1946

Signed-off-by: Kai Kreuzer <kai@openhab.org>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 11, 2023
Fixes openhab#1946

Signed-off-by: Kai Kreuzer <kai@openhab.org>
GitOrigin-RevId: 4059ea2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants