Send a notification when i enter a zone but only if my todo list has items

i have the following automation that when i enter a zone i get sent a notification of my to do list but i want the condition to be only send if the list has items. if empty dont send.

alias: Bens Woolies Shopping List
description: “”
trigger:

  • platform: zone
    entity_id: person.ben_cown
    zone: zone.wollies
    event: enter
    condition:
  • condition: numeric_state
    entity_id: todo.woolies_shopping_list
    above: 0
    action:
  • service: notify.mobile_app_iphone
    data:
    data:
    clickAction: /To-do_lists
    url: /todo?entity_id=todo.woolies_shopping_list
    message: Don’t forget these items!
    title: Woolworths Shopping List
    mode: single

when i test the condition and the list is empty the condition does not pass however the notification still gets sent.

when i check the logbook i get the following on the condition:
This step was not executed and so no further trace information is available.

any ideas on how to make this work?

I’m not very experienced but did notice:

in the first bullet. Should wollies be woolies?

no, it looks like I misspelled my zone when I set it up. I have renamed the zone woolies and updated the code. same result,

Please paste the code correctly.

There is a pinned post that tells how to do it.

sorry new here.Hope this is correct.

alias: Bens Woolies Shopping List
description: ""
trigger:
  - platform: zone
    entity_id: person.ben_chatain
    zone: zone.woolies
    event: enter
condition:
  - condition: state
    entity_id: todo.woolies_shopping_list
    state: ">0"
    attribute: supported_features
action:
  - service: notify.mobile_app_iphone
    data:
      data:
        clickAction: /To-do_lists
        url: /todo?entity_id=todo.woolies_shopping_list
      message: Don't forget these items!
      title: Woolworths Shopping List
mode: single

You are actually looking at the attribute called supported_features instead of the state.

Paste the following into Developer Tools | Template to see the difference.

{{ states.todo.woolies_shopping_list.attributes }}

{{ states.todo.woolies_shopping_list.attributes.supported_features }}
{{ states.todo.woolies_shopping_list.attributes.supported_features > 0 }}

{{ states.todo.woolies_shopping_list.state }}
{{ states.todo.woolies_shopping_list.state | int > 0 }}

thank you for the response. as mentioned i am new to this. would you be able to give advise on what i need to change on the code to make this work?

I think your first post should work using the numeric_state condition of above 0.

You say when you test it, the condition fails and the notification still happens. Do you mean you run the automation? If so, conditions are ignored when you do that.

You need to actually enter the zone for a test.

Or, set your zone to woolies in Developer Tools | State

thanks for your help. I tried it in the zone and it worked. I didn’t realise conditions are ignored when you run automations.