Help with for: minutes 1 with condition

why is this not triggering

 alias: frootdoor_report_not_locked_for_x_mintes
  trigger:
  - platform: state
    entity_id: binary_sensor.ble_opening_frontdoor
    to: 'off'
    for:
      minutes: 1
  condition:
    - condition:  state
      entity_id: binary_sensor.lock_lift_handle_opening
      to: 'off'  
  action:
  - service: notify.mobile_app_bertybassett_iphone15_pro_max
    data:
      message: You forget to lift the frontdoor handle - Door not locked
  id: be3849f61b5441b091c0b74b0f9f6875

If i remove the condition it triggers

When do you want it to trigger?

Are we going to play 20-questions, or are you going to be more forthcoming with details, like what are the binary sensors presenting?

the code is pretty simple and self explanatory for someone who know what they are doing hence why no explanation was given.

I think the issue is you cannot use a for: minutes with a condition.

if you’re saying the state of binary_sensor.lock_lift_handle_opening must be off, then you need to do this:

alias: frootdoor_report_not_locked_for_x_mintes
  trigger:
  - platform: state
    entity_id: binary_sensor.ble_opening_frontdoor
    to: 'off'
    for:
      minutes: 1
  condition:
    - condition:  state
      entity_id: binary_sensor.lock_lift_handle_opening
      state: 'off'  
  action:
  - service: notify.mobile_app_bertybassett_iphone15_pro_max
    data:
      message: You forget to lift the frontdoor handle - Door not locked
  id: be3849f61b5441b091c0b74b0f9f6875

note that the indents on your original posted yaml is messed up and won’t work. i presume that was a copy error since you said it works if you nuke the condition?

i didn’t fix your indents… make sure you’ve got that fixed in your acual running code… just changed the one line in your condition block.

if you’re trying to run the actions when that sensor changes to ‘off’ then it shouldn’t be in the condition block, it should be in the trigger block.

1 Like

hmm… should be able to… the condition will be checked at the end of that time period, it won’t be checked for the duration.

1 Like

struggling to see the indent error

You can use for on a state condition, you cannot use for a numerical_state condition.

1 Like

The most important fix was that a state condition has no to:
@armedad fixed that by replacing it with state:

2 Likes

fixed state but still not working

Indenting is still wrong. trigger, condition action and id must have same level as alias, there may be more indenting errors, but they are hard to spot when if starts off wrong.

Try building it in the ui and learn from that when writing them manually. You can also test conditions there and examine traces.

- alias: frootdoor_report_not_locked_for_x_mintes
  trigger:
  - platform: state
    entity_id: binary_sensor.ble_opening_frontdoor
    to: 'off'
    for:
      minutes: 1  
  action:
  - service: notify.mobile_app_bertybassett_iphone15_pro_max
    data:
      message: You forget to lift the frontdoor handle - Door not locked

Are we saying this has indent error (despite it triggering)

- alias: frootdoor_report_not_locked_for_x_mintes
  trigger:
  - platform: state
    entity_id: binary_sensor.ble_opening_frontdoor
    to: 'off'
    for:
      minutes: 1
  condition:
  - condition:  state
    entity_id: binary_sensor.lock_lift_handle_opening
    state: 'off'       
  action:
  - service: notify.mobile_app_bertybassett_iphone15_pro_max
    data:
      message: You forget to lift the frontdoor handle - Door not locked

with the condition statement if fails

that looks right. the first post indent looks like it was off because of the first line. i think it was a copy/paste error.

That was a part of how you posted it before, I am not clearvoiant.

yeah correct the first post I missed off the “-” like armedad say but condition is still not working

there are two spaces after condition: but I do not know if that is a problem. What does the automation trace say?

alias: frootdoor_report_not_locked_for_x_mintes
id: be3849f61b5441b091c0b74b0f9f6875
trigger:
  - platform: state
    entity_id: binary_sensor.ble_opening_frontdoor
    to: 'off'
    for:
      minutes: 1
condition:
  - condition:  state
    entity_id: binary_sensor.lock_lift_handle_opening
    to: 'off'  
action:
  - service: notify.mobile_app_bertybassett_iphone15_pro_max
    data:
      message: You forget to lift the frontdoor handle - Door not locked

k. using your code w/ the condition in, go to the trace and see what it says.

the trace should tell you what went wrong and why

opps it should have been

 condition:
  - condition:  state
    entity_id: binary_sensor.lock_lift_handle_opening
    state: 'on'