Seite 1 von 1

Problem mit Regel

Verfasst: 30. Dez 2022 16:17
von leupy
Hallo,
ich habe noch etliche alte Regeln von Version 2.3 mit Skript und habe angefangen die umzuschreiben.
Jetzt habe ich folgende Regel erstellt aber diese funktioniert einfach nicht.
Es soll der Heizung Mode beim Triggern umgestellt werden auf Status 1 aber nur wenn er vorher Status 2 hatte.
Beim auslösen der Regel wird immer Satus 1 gesetzt egal wie der Status vorher war ??? :shock:

Im Voraus danke schon mal für eure Hilfe. :idea:

Bild

Code: Alles auswählen

configuration: {}
triggers:
  - id: "1"
    configuration:
      cronExpression: 0 50 5 ? * MON-FRI
    type: timer.GenericCronTrigger
  - id: "2"
    configuration:
      cronExpression: 0 00 8 ? * SAT-SUN
    type: timer.GenericCronTrigger
conditions:
  - inputs: {}
    id: "6"
    configuration:
      itemName: HeizungMode
      state: "2"
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "4"
    configuration:
      itemName: HeizungMode
      state: "1"
    type: core.ItemStateUpdateAction

Re: Problem mit Regel

Verfasst: 30. Dez 2022 17:12
von udo1toni
Die Frage ist: Welchen Datentyp verwendet das Item?
Grundsätzlich wäre der Weg über einen Codeblock sinnvoller:

Code: Alles auswählen

configuration: {}
triggers:
  - id: "1"
    configuration:
      cronExpression: 0 50 5 ? * MON-FRI
    type: timer.GenericCronTrigger
  - id: "2"
    configuration:
      cronExpression: 0 00 8 ? * SAT-SUN
    type: timer.GenericCronTrigger
conditions: []
actions:
  - inputs: {}
    id: "3"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |-
        if(HeizungMode.state != 2)
            return; 
        HeizungMode.postUpdate(1)
    type: script.ScriptAction
By the way: Screenshots sind allgemein eher unpraktisch, der Code reicht vollkommen aus. Screenshots sind nur dann sinnvoll, wenn es um ein grafisches Dateil geht, welches sonst nur schwer identifiziert werden kann.

Re: Problem mit Regel

Verfasst: 30. Dez 2022 17:28
von leupy
Der Datentyp ist Number