Question for a special automation rule with Motion Sensor

Hi,

I have a roof window with a shutter which I close if it is sunny (sensor.solrad)and warm outside (sensor.pws_temp_c). This automation works fine.

- id: '1525074202648'
  alias: Beschattung Dachflächenfenster ein
  trigger:
  - entity_id: sensor.solrad
    for:
      minutes: 10
    platform: state
    to: 'True'
  - above: '16.0'
    entity_id: sensor.pws_temp_c
    platform: numeric_state
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: sensor.solrad
      for:
        minutes: 10
      state: 'True'
    - above: '16.0'
      condition: numeric_state
      entity_id: sensor.pws_temp_c
    - before: '18:00:00'
      condition: time
    - condition: state
      entity_id: input_boolean.beschattung
      state: 'off'
  action:
  - data:
      message: Es scheint die Sonne!
      title: Beschattung Dachflächenfenster ein
    service: notify.pushover_johannes
  - data:
      entity_id: scene.ostfensterzu
    service: scene.turn_on
  - data:
      entity_id: scene.westfensterzu
    service: scene.turn_on
  - data:
      entity_id: scene.beschattungein
    service: scene.turn_on
  - data:
      entity_id: input_boolean.beschattung
    service: input_boolean.turn_on

Now to the complicated part: I have also have a Fibaro MultiSensor in the Room and I want to disable this automation, when someone is in the room (sensor.arbeitszimmer_dach_motion_sensor_burglar = 8 for 5 minutes).

When 5 minutes no motion was detected the automation should be enabled and triggered (becasue it could be that the conditions went true during the time, where the automation was deactivated).

Can someone give me some hints on what the best approach would be?

Br,
Johannes

I think the best approach would be to use input booleans for the conditions and have another automation trigger based on those. This way you can disable and enable the automation without loosing track of the conditions.

I agree with @sjee. It’s some additional work to create the input booleans but in the end they work. Another option could be the use of templates such as this one:

- condition: template
  value_template: "{{ relative_time(states.binary_sensor.fibaro_system_fgms001zw5_motion_sensor_sensor.last_updated) > '5 minutes' }}"

Attention, there are some pitfalls when using time objects in value templates, see Sensor state based on time of day