Help needet: Question about Shelly via physical switch or BWM control/switch

Hi everyone,

I’d like to set it up so that when I press the switch, it stays on until I press the switch again to turn it off.
This should not be turned off by the motion sensor (BWM).
However, if the light is turned on by the motion sensor, it should turn off automatically after 3 minutes, controlled by the motion sensor.

How can I add this kind of helper to my existing automation?

This is my actual configuration:

alias: Automatisierung Eingang
  description: ''
  triggers:
  - entity_id:
    - binary_sensor.hue_bwm_eingangsbereich_belegung
    from: 'off'
    to: 'on'
    id: Bewegung ausgelöst
    trigger: state
  - entity_id:
    - binary_sensor.hue_bwm_eingangsbereich_belegung
    from: 'on'
    to: 'off'
    for:
      hours: 0
      minutes: 3
      seconds: 0
    id: Bewegungsmelder zurückgesetzt
    trigger: state
  conditions:
  - condition: time
    after: '16:30:00'
    before: 08:00:00
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    - sat
    - sun
  actions:
  - if:
    - condition: trigger
      id:
      - Bewegung ausgelöst
    then:
    - target:
        entity_id: light.shellyplus1_1c6920081f18_switch_0
      data: {}
      action: light.turn_on
  - if:
    - condition: trigger
      id:
      - Bewegungsmelder zurückgesetzt
    then:
    - target:
        entity_id: light.shellyplus1_1c6920081f18_switch_0
      data: {}
      action: light.turn_off
  mode: single
```

@harold07douglas

thanks for your answer.
Can you give me some help with the helper, where does it have to be coded? I’m still a little new to HA. What should it look like and where does it go, that would be great, thank you

That was a spam bot.

oh, sad…

anyone can help me?

You can use context. Have a read of this: State.context to UI automation - #24 by mbuscher

Good morning everyone,

now there is just one error. The motion detector doesn’t switch off after 3 minutes, maybe I overlooked something in my configs. Thank you

alias: Licht ausschalten nach 3 Minuten ohne Bewegung
description: >-
  Licht ausschalten, wenn keine Bewegung erkannt wird und der Schalter nicht
  aktiv ist.
triggers:
  - entity_id: binary_sensor.hue_bwm_eingangsbereich_belegung
    from: "on"
    to: "off"
    for:
      minutes: 3
    trigger: state
conditions:
  - condition: state
    entity_id: input_boolean.licht_schalter_aktiv
    state: "off"
  - condition: time
    after: "16:30:00"
    before: "08:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
actions:
  - target:
      entity_id: light.shellyplus1_1c6920081f18_switch_0
    action: light.turn_off
    data: {}
mode: single


alias: Licht einschalten bei Bewegung
description: Licht einschalten, wenn Bewegung erkannt wird, und Schalter nicht aktiv ist.
triggers:
  - entity_id: binary_sensor.hue_bwm_eingangsbereich_belegung
    from: "off"
    to: "on"
    trigger: state
conditions:
  - condition: state
    entity_id: input_boolean.licht_schalter_aktiv
    state: "off"
  - condition: time
    after: "16:30:00"
    before: "08:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
actions:
  - target:
      entity_id: light.shellyplus1_1c6920081f18_switch_0
    action: light.turn_on
    data: {}
mode: single
alias: Licht einschalten bei Bewegung
description: Licht einschalten, wenn Bewegung erkannt wird, und Schalter nicht aktiv ist.
triggers:
  - entity_id: binary_sensor.hue_bwm_eingangsbereich_belegung
    from: "off"
    to: "on"
    trigger: state
conditions:
  - condition: state
    entity_id: input_boolean.licht_schalter_aktiv
    state: "off"
  - condition: time
    after: "16:30:00"
    before: "08:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
actions:
  - target:
      entity_id: light.shellyplus1_1c6920081f18_switch_0
    action: light.turn_on
    data: {}
mode: single
alias: Schalter zurücksetzen
description: Setze den Helper zurück, wenn der physische Schalter ausgeschaltet wird.
triggers:
  - entity_id: light.shellyplus1_1c6920081f18_switch_0
    to: "off"
    trigger: state
actions:
  - target:
      entity_id: input_boolean.licht_schalter_aktiv
    action: input_boolean.turn_off
    data: {}
mode: single

alias: Schalterstatus überwachen
description: Setze den Helper auf true, wenn der physische Schalter betätigt wird.
triggers:
  - entity_id: light.shellyplus1_1c6920081f18_switch_0
    to: "on"
    trigger: state
actions:
  - target:
      entity_id: input_boolean.licht_schalter_aktiv
    action: input_boolean.turn_on
    data: {}
mode: single

input_boolean:
licht_schalter_aktiv:
name: Licht Schalter Aktiv
initial: off
icon: mdi:lightbulb

Maybe one of you will find the error why the motion detector doesn’t turn off the light after 3 minutes

Big THX