Automation for custom entity state?

Hi, i’m trying to create a notification based automation to remind me when recycling is due the day before it is picked up.

I am currently using the integration Waste Collection Schedule from HACS which reports the entity state in

“recycling in x days”, X bring the number of days until recycling is due.

How can I integrate this into an automation to only trigger when recycling is due in 1 day, and send the notification at say 6pm at night.

This is what I have tried.

Thank you!

alias: Recycling Notification
description: ""
trigger:
  - platform: time
    at: "18:00:00"
  - platform: state
    entity_id:
      - sensor.recycle
    to: recycling in 1 days
condition: []
action:
  - service: notify.mobile_app_deans_iphone
    data:
      message: Recycling
      title: Recycling
mode: single

The first thing to note is both the recycle sensor AND the 6pm time are triggers right now, so the automation will trigger at EITHER 6pm or when sensor.recycle changes to your desired state. If you only want it to fire at 6pm (regardless of when the recycle sensor changes) then you should put the sensor as a condition rather than a trigger.

Can you elaborate on what is happening with the current automation that is undesirable? Please also grab a trace of one of the times the automation ran, that will tell you what went wrong.

This ^^.

Thank you, this is exactly what I was looking for! I wanted the And IF seems I completely overlooked that.

Thank you so much its working now.

1 Like