Pause automations after manual input on the state

Hi all,

what I am trying to do is is automating my shutters depending on weather and light level.

What I also would like to do is to suspend the automation for 20 minutes, after the position of the shutter have been manually changed (manually here means either through home assistant or by using the physical switch next to th window).

For example: HASS closes the shutters to 80% due to the trigger light level. I open the shutters for some reason a bit later to 30%. Even if the trigger is true (light level above X for n minutes), the automation should wait for 20 minutes before executing again.

Is this possible? I don’t know even where to start with this.

Good day community!

I very much second this request. Is there anyway of doing this in YAML or say Node Red?

Cheers

Pretty easy, just have a condition in the automation to prevent it running if the last change in the shutters state was less than the desired value (in the above example, 20 mins).

1 Like

Ah yes, but how would I do this if the end point was a light switch/dimmer instead of a cover? In this case, there would be State and Numeric State changes to monitor in the Condition (I think). Here is my current automation without the “pause condition I am trying to implement”:

alias: Evening Office Lights
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.motion
    to: 'on'
condition:
  - condition: numeric_state
    entity_id: sensor.illuminance
    below: '60'
  - condition: and
    conditions:
      - condition: device
        device_id: xyz
        domain: device_tracker
        entity_id: device_tracker.iphone
        type: is_home
      - condition: time
        before: '05:59:00'
        after: '20:01:00'
action:
  - service: scene.turn_on
    target:
      entity_id: scene.office_astrological
    metadata: {}
mode: single

Appreciate any help here

On second thought. I’m not sure the Condition suggestion would work.

In my use case, manual user input will likely occur after the automation is triggered by motion.

Ok for a start conditions are AND logic by default so that and condition you have is superfluous and can be removed.

condition:
  - condition: numeric_state
    entity_id: sensor.illuminance
    below: '60'
  - condition: device
    device_id: xyz
    domain: device_tracker
    entity_id: device_tracker.iphone
    type: is_home
  - condition: time
    before: '05:59:00'
    after: '20:01:00'

When do you actually want the automation to be “paused”?

That’ll clean up the condition code, thank you.

To answer your question:

  1. Person walks into room → motion triggered → conditions met, action fires (lights on)
  2. Person decides lights not at ideal brightness or would rather keep lights off → manually adjusts lights at physical switch
  3. At this point, I would like the manual action to trigger a 1 hour pause on bullet point #1 trigger

This is important because I don’t want the automation to trigger after my motion sensor re-trigger time (30sec) expires and motion is again detected within that 1 hour timeframe.

Not sure it’s relevant to know, but I have a separate automation designed to turn off lights in this area when Lux > X.

OK, so if the light is manually adjusted, pause the automation.

This will depend on the context of the event. This is not trivial (even if you had the automation pause action).

The three objects you have to check (id, parent_id, and user_id) to determine what triggered the automation are shown in the truth table that taras posted here: Request for Generic Thermostat "heater" switch to act as a thermostat physical switch - #14 by 123

So you would have to have another automation triggered by any change of the switch or dimmer (state triggers with null to: ) and have these conditions:

condition:
  - "{{ trigger.to_state.context.id != none }}"
  - "{{ trigger.to_state.context.parent_id == none }}"
  - "{{ trigger.to_state.context.user_id == none }}"

If it passes these conditions then you know it was a physical action on the switch/dimmer. You could then do something like start a timer in the actions of this automation.

Then (finally) add a condition in your motion automation that the timer must be idle.

As I said, you would have to jump through these hoops even if you had your requested automation pause, just to work out what caused the change to the light.

You write a new automation.

I think I got it working. I created a ‘timer.start’ Helper with a value of 1 hour and used that as my Action in the following new automation. My use case is that I do not want the motion automation to trigger for 1 hour if the physical light switch is adjusted in any way.

Do I have the right understanding?

alias: Manual Light Adjustment Timer
description: ''
trigger:
  - platform: state
    entity_id: light.kitchen_main_lights
condition:
  - condition: template
    value_template: '{{ trigger.to_state.context.id != none }}'
  - condition: template
    value_template: '{{ trigger.to_state.context.parent_id == none }}'
  - condition: template
    value_template: '{{ trigger.to_state.context.user_id == none }}'
action:
  - service: timer.start
    data: {}
    target:
      entity_id: timer.manual_adjustment
mode: single

Yes. Now you just have to add a condition to your motion automation to prevent it running the actions if the timer is running.

Thank you for all your help. So far this is working well.

1 Like