Create automation trigger on domain level

I am using the following custom HACS component: https://github.com/glance-/dhl. This adds 2 services you can call: dhl.register and dhl.unregister.

I have made the following card on my dashboard where I can copy the tracking code into the input text after which it will call the service dhl.register and appear in the list using auto-entities:

image

type: custom:stack-in-card
cards:
  - type: picture-entity
    entity: weather.home
    image: /local/headers/HeaderDHL.png
    show_state: false
    show_name: false
    tap_action:
      action: none
    hold_action:
      action: none
  - type: entities
    entities:
      - entity: input_text.input_dhl_tracking
        type: custom:text-input-row
  - type: custom:auto-entities
    card:
      type: entities
    filter:
      include:
        - domain: dhl
          options:
            type: custom:multiple-entity-row
            primary:
              attribute: status
              name: Status

Now I’d like to create an automation that checks all entities with the dhl domain and if the status of an entity is set to delivered for 7 days, then call the service dhl.unregister with the tracking code of that entity.

I cannot create a group or create a group dynamically (as far as I know) and I’ve not seen a way to check entities on a domain level either. Is there any way to accomplish what I want here? Thanks!

A template trigger can check all entities filtered by domain.

Do these entities have a delivered timestamp or are you wanting HA to keep track of them all?

Can you post an example of an entity showing its state and attributes?

1 Like

Thanks for your reply, I appreciate the help :slight_smile:

Once a package is registered using the dhl.register service an entity will is created and looks like the following:

The entities do not have a delivered timestamp attribute, however you could see the moment the state changes from transit to delivered as a timestamp for delivery.

I guess this means I’d need HA to keep track of all dhl domains and set the trigger of the automation to when delivered for 7 days then etc.etc.