Automation - Zwei Bewegungsmelder für eine Lichtergruppe

SkyWalker2_D

Active member
Moin!

Ich habe noch was. Wie wird die Automation angelegt, wenn ich zwei Bewegungsmelder habe und das Licht nicht ausschalten soll wenn einer der beiden noch Bewegung registriert?

Ich arbeite mit Trigger IDs und habe aktuell das Problem, dass das Licht ausgeht sobald einer der Bewegungsmelder keine Bewegung mehr feststellt.
Ist die Action dann 'and' vor 'if-then', also beide Trigger müssen die Bedingung erfüllen?

Grüße
Sky
 
Hmmm...

Würde das (als Anfänger hier) mit 2 automaten machen...
Beide schalten das Licht ein bei motion...

Aber ist wohl eher Laienhaft... 🤔
 
Poste die Automation mal. Kommt nämlich bisschen drauf an, wie du die Trigger angelegt hast.

@Putarex dann lies mal fleißig hier und in den anderen Threads mit, hier gibt's ordentlich was zu lernen 😅
 
Da bin ich schon wieder 😅
Mal schnell aus dem Ärmel geschüttelt:

YAML:
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - Motion 1
      - Motion 2
    to:
      - "on"
      - "off"
condition: []
action:
  - if:
      - condition: template
        value_template: |
          {{
          trigger.to_state.state == 'on'
          }}
    then:
      - service: light.turn_on
        data: {}
        target:
          entity_id:
            - Licht
            - AnderesLicht
    else:
      - condition: and
        conditions:
          - condition: template
            value_template: |
              {{
              trigger.to_state.state == 'off'
              }}
          - condition: state
            entity_id: Motion A
            state: "off"
          - condition: state
            entity_id: Motion B
            state: "off"
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - Licht
            - AnderesLicht
 
Moin Ivory!

Heißer Scheiß ... vielen Dank für die erneute Hilfe!

So habe ich es aktuell! Da ist aber noch ein Bewegungsmelder "entity_id: binary_sensor.ewelink_ms01_iaszone" integriert, der zu vernachlässigen ist.

Sobald ich die Kellertreppe runter bin in den Kellerflur, meldet der Bewegungsmelder Kellertreppe nach 30 Sek. keine Bewegung mehr und schaltet das Licht aus. Egal wie sehr ich vor den Bewegungsmelder Kellerflur rumtanze.

YAML:
alias: Kellertreppe & Kellerflur - Bewegungsmelder
description: ""
trigger:
  - type: occupied
    platform: device
    device_id: 37ad0598d1152835f1798b654d093da5
    entity_id: binary_sensor.philips_sml001_occupancy
    domain: binary_sensor
    alias: Bewegung Kellerflur
    id: Bewegung Kellerflur
  - type: occupied
    platform: device
    device_id: 3b0ccd17973cd2d5282ba96945383300
    entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
    domain: binary_sensor
    alias: Bewegung Kellertreppe
    id: Bewegung Kellertreppe
  - type: motion
    platform: device
    device_id: 5e014bc823ae677399d7c203f6a42896
    entity_id: binary_sensor.ewelink_ms01_iaszone
    domain: binary_sensor
    alias: Kellerflur Regal - Bewegung
    id: Bewegung Regal
  - type: not_occupied
    platform: device
    device_id: 37ad0598d1152835f1798b654d093da5
    entity_id: binary_sensor.philips_sml001_occupancy
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
    alias: Keine Bewegung Kellerflur für 30 Sek.
    id: Keine Bewegung Kelleflur
  - type: not_occupied
    platform: device
    device_id: 3b0ccd17973cd2d5282ba96945383300
    entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
    id: Keine Bewegung Kellertreppe
    alias: Keine Bewegung Kellertreppe für 30 Sek.
condition: []
action:
  - if:
      - condition: trigger
        id: Bewegung Kellertreppe
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    alias: Bewegung Kellertreppe - Licht an
  - if:
      - condition: trigger
        id: Bewegung Kellerflur
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    alias: Bewegung Kellerflur - Licht an
  - if:
      - condition: trigger
        id: Keine Bewegung Kellertreppe
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellertreppe_2
    alias: Keine Bewegung Kellertreppe - Licht aus
    enabled: true
  - if:
      - condition: trigger
        id: Keine Bewegung Kelleflur
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellerflur_2
    alias: Keine Bewegung Kellerflur - Licht aus
    enabled: true
  - if:
      - condition: trigger
        id: Bewegung Regal
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id: light.lampe_regal_light
    alias: Bewegung Regal
  - if:
      - condition: or
        conditions:
          - condition: trigger
            id: Keine Bewegung Kelleflur
          - condition: trigger
            id: Keine Bewegung Kellertreppe
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id: light.kellerflur_und_treppe
    alias: Keine Bewegung - Licht aus
    enabled: true
mode: single
 
Ah, verstehe. Zwei Bewegungsmelder die je nach Ort der Bewegung verschiedene Lampen steuern.

Kriegst das selber umgebaut mit meinem Tip?
Da wäre dann eigentlich nur mein "else" interessant. Und statt dem template nimmst dann deine Trigger-ID als Bedingung.

Wenn du noch Hilfe brauchst sag Bescheid, ich bau dir das im Zweifel auch komplett um 😅

Nachtrag: das ganze kannst auch, wie in meinem Gedankenanstoß, auf einen, bzw in deinem Fall zwei Trigger reduzieren.
Einen für "an" mit allen Entities und einen für "off" mit allen Entities inkl "für 30 Sekunden".
In deinen if-then fragst du dann den Trigger (an oder aus) ab und setzt entsprechend die Bedingung, welcher BWM für was an oder aus sein muss.
 
Zuletzt bearbeitet:
Moin!

Ja, hat geklappt und funktioniert. Vielen Dank schon mal.

Auch wenn ich noch nicht ganz weiß was da genau passiert! 'Condition: template' ist mir unbekannt. Aber die Automation prüft ob die beiden BWM 'on' sind, korrekt? Wenn beide nicht 'on' sind dann kommt 'else' ins Spiel.

Wo kann ich denn 'Duration' mit einbauen? Über die GUI kann der Trigger nicht bearbeitet werden.

Grüße
Sky
 
Zuletzt bearbeitet:
Wenn eine Automation getriggert wird werden Variablen erstellst, die ausschließlich in dieser Automation verfügbar sind und nach Beendigung gelöscht werden. Unter anderem "this" (die Automation selbst) und "trigger" (liefert Infos zum ausgelösten Trigger).
Das Template guckt sich an, was in der Variable "trigger" steht.
"trigger.to_state.state" guckt sich also an, zu welchem Zustand die triggernde Entität gewechselt ist. Vereinfacht kann man sagen, dass ist in diesem Fall die umständliche Variante von dem, was man sonst mit Trigger ID macht.

Es geht aber wie gesagt auch einfacher:

YAML:
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - Motion 1
      - Motion 2
    to: "on"
    id: BWM an
  - platform: state
    entity_id:
      - Motion 1
      - Motion 2
    to: "off"
    id: BWM aus
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: []
action:
  - if:
      - condition: trigger
        id: BWM an
      - condition: state
        entity_id: Motion A
        state: "on"
    then:
      - service: light.turn_on
        data: {}
        target:
          entity_id:
            - Licht
    else: []
  - if:
      - condition: trigger
        id: BWM an
      - condition: state
        entity_id: Motion B
        state: "on"
    then:
      - service: light.turn_on
        data: {}
        target:
          entity_id:
            - AnderesLicht
    else:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - Licht
            - AnderesLicht
  - if:
      - condition: trigger
        id: BWM aus
      - condition: state
        entity_id: Motion A
        state: "off"
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - Licht
    else: []
  - if:
      - condition: trigger
        id: BWM aus
      - condition: state
        entity_id: Motion B
        state: "off"
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - AnderesLicht
    else: []
  - if:
      - condition: trigger
        id: BWM aus
      - condition: state
        entity_id: Motion B
        state: "off"
      - condition: state
        entity_id: Motion B
        state: "on"
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - AnderesLicht
    else: []

Ich denke die ersten 4 if-then sind selbsterklärend. Beim letzten kannst du sehen, wie du konfigurierst, dass ein BWM an und einer aus sein muss, um ein Licht zu schalten.
 
Zuletzt bearbeitet:
Die erste Automation mit Template läuft schon zum Test (erfolgreich). Die würde ich gerne so belassen weil doch übersichtlich.
Wo bekomme ich da denn die 'Duration' 30 Sek rein? Ich hatte gedacht unter 'Action' und in 'else'.
 
Das geht am einfachsten, wenn du den trigger in zwei aufteilst. Einer für an, einer für aus. Siehe mein vorheriger Post. Beim "aus-trigger" hab ich die 30 Sekunden schon eingebaut.

(Und mit zwei Triggern könntest du es dir auch wieder einfacher machen und statt Templates wieder mit "ausgelöst durch trigger id" arbeiten.)
 
Alles klar. Ich habe mal meine Entities übertragen.
Den letzten Abschnitt verstehe ich nicht. Das Licht (ist übrigens ein Helper für beide "Räume") schaltet nach 30 Sek. nicht aus. Liegt es am letzten Part:

YAML:
else: []
  - if:
      - condition: trigger
        id: BWM aus
      - condition: state
        entity_id: Motion B
        state: "off"
      - condition: state
        entity_id: Motion B
        state: "on"
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - AnderesLicht
    else: []
 
Sorry, Tippfehler. Muss natürlich heißen
YAML:
else: []
  - if:
      - condition: trigger
        id: BWM aus
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellertreppe_2

    else: []

So schaltet Kellertreppe nur aus, wenn beide BWM keine Bewegung mehr erkennen.
 
Hätte ich auch selber drauf kommen können :)
Aber es klappt trotzdem nicht. Das Licht geht nach 30 Sek. ohne Bewegung nicht aus.

Ich hatte es jetzt noch mal so versucht, aber auch ohne Erfolg:

YAML:
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: Bewegung aus
          - condition: state
            entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
            state: "off"
          - condition: state
            entity_id: binary_sensor.philips_sml001_occupancy
            state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellerflur_und_treppe

Trigger Aus UND Occupancy beider BWM aus = Licht aus.
 
Per 'Try & error' habe ich mal einige Actions disabled, auch ohne Erfolg!


YAML:
alias: Kellertreppe und -flur - Bewegung (Test)
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.philips_sml001_occupancy
      - binary_sensor.kellertreppe_philips_motionsensor_occupancy
    to: "on"
    id: Bewegung an
    alias: Bewegung Kellertreppe oder Kellerflur
  - platform: state
    entity_id:
      - binary_sensor.philips_sml001_occupancy
      - binary_sensor.kellertreppe_philips_motionsensor_occupancy
    to: "off"
    id: Bewegung aus
    for:
      hours: 0
      minutes: 0
      seconds: 30
    alias: Keine Bewegung Kellertreppe oder Kellerflur
condition: []
action:
  - if:
      - condition: trigger
        id: Bewegung an
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "on"
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Bewegung  Kellerflur - Licht an
  - if:
      - condition: trigger
        id: Bewegung an
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "on"
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else:
      - service: light.turn_off
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    alias: Bewegung  Kellertreppe - Licht an
  - if:
      - condition: trigger
        id: Bewegung aus
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Keine Bewegung  Kellerflur - Licht aus
    enabled: false
  - if:
      - condition: trigger
        id: Bewegung aus
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Keine Bewegung  Kellertreppe - Licht aus
    enabled: false
  - if:
      - condition: trigger
        id: Bewegung aus
        enabled: true
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellertreppe_2
    else: []
    enabled: false
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: Bewegung aus
          - condition: state
            entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
            state: "off"
          - condition: state
            entity_id: binary_sensor.philips_sml001_occupancy
            state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellerflur_und_treppe
mode: single
 
Hab dein letztes if-then mal bisschen umgeräumt und den Modus auf Parallel gestellt. Ich wusste sonst nicht, warum das nicht funktionieren sollte

YAML:
alias: Kellertreppe und -flur - Bewegung (Test)
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.philips_sml001_occupancy
      - binary_sensor.kellertreppe_philips_motionsensor_occupancy
    to: "on"
    id: Bewegung an
    alias: Bewegung Kellertreppe oder Kellerflur
  - platform: state
    entity_id:
      - binary_sensor.philips_sml001_occupancy
      - binary_sensor.kellertreppe_philips_motionsensor_occupancy
    to: "off"
    id: Bewegung aus
    for:
      hours: 0
      minutes: 0
      seconds: 30
    alias: Keine Bewegung Kellertreppe oder Kellerflur
condition: []
action:
  - if:
      - condition: trigger
        id: Bewegung an
        alias: "Trigger an? "
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "on"
        alias: "BWM Kellertreppe an? "
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Bewegung  Kellerflur - Licht an
  - if:
      - condition: trigger
        id: Bewegung an
        alias: "Trigger an? "
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "on"
        alias: "BWM Kellertreppe an? "
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 60
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Bewegung  Kellertreppe - Licht an
  - if:
      - condition: trigger
        id: Bewegung aus
        alias: "Trigger aus? "
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
        alias: "BWM Kellerflur aus? "
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Keine Bewegung  Kellerflur - Licht aus
    enabled: false
  - if:
      - condition: trigger
        id: Bewegung aus
        alias: "Trigger aus? "
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
        alias: "BWM Kellertreppe aus? "
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id:
            - light.kellerflur_und_treppe
    else: []
    alias: Keine Bewegung  Kellertreppe - Licht aus
    enabled: false
  - if:
      - condition: trigger
        id: Bewegung aus
        enabled: true
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellertreppe_2
    else: []
    enabled: false
  - if:
      - condition: trigger
        id: Bewegung aus
        alias: Trigger aus
      - condition: state
        entity_id: binary_sensor.kellertreppe_philips_motionsensor_occupancy
        state: "off"
        alias: "BWM Kellertreppe aus? "
      - condition: state
        entity_id: binary_sensor.philips_sml001_occupancy
        state: "off"
        alias: "BWM Kellerflur aus? "
    then:
      - service: light.turn_off
        data:
          transition: 1
        target:
          entity_id: light.kellerflur_und_treppe
    alias: "Keine Bewegung beide - Licht Treppe und Flur aus "
mode: parallel
max: 10
 
So, vielen Dank auf ein Neues Ivory. Jetzt klappt es und ich habe, so hoffe ich, wieder was gelernt.
Trigger können für mehrere Entities gleichzeitig abgebildet werden. Und die Bedingungen für die 'Action' werden untereinander abgebildet. ich hatte da mit 'and' bzw. 'or' versucht zu arbeiten.
 
Im Grunde kannst du fast alles in Automationen von oben nach unten lesen, was einem "und" gleich kommt. Daher kann man sich das logische "und" halt auch zugunsten der Übersicht meistens sparen.

State-Trigger können mit beliebig vielen Entitäten bestückt werden. Ich hab zb eine "offline-Erkennung" für Zigbee-Geräte, da sind 40 Entitäten in einem Trigger.
Voraussetzung dafür ist, dass immer der selbe Zustand (zb: on, off, unavailable) gewünscht ist.
 

Zurzeit aktive Besucher

Letzte Anleitungen

Statistik des Forums

Themen
4.378
Beiträge
45.210
Mitglieder
3.976
Neuestes Mitglied
calibra52
Zurück
Oben