2 Home Assistant - Garbage Day Notification
jason edited this page 2024-04-19 16:29:07 +00:00
automations:
- id: '1709743425576'
  alias: Alert - Garbage
  description: Alert us if we need to take the garbage out, including setting the
    bindicator colour
  trigger:
  - platform: time
    at: '18:00:00'
  condition:
  - condition: not
    conditions:
    - condition: state
      entity_id: sensor.tomorrow_s_garbage_pickup
      state: None
    - condition: state
      entity_id: input_select.master_mode
      state: Vacation
  action:
  - if:
    - condition: template
      value_template: '{% if "and" in states.sensor.tomorrow_s_garbage_pickup.state
        %}true{% else %}false{% endif %}'
      alias: If two carts need to go out...
    then:
    - service: light.turn_on
      metadata: {}
      data:
        rgb_color:
        - 0
        - 255
        - 0
        effect: Pulsing
      target:
        entity_id: light.bindicator_bindicator_bottom
    - service: light.turn_on
      metadata: {}
      data:
        rgb_color:
        - 0
        - 255
        - 255
        effect: Pulsing
      target:
        entity_id: light.bindicator_bindicator_top
    else:
    - if:
      - condition: template
        value_template: '{% if "Blue" in states.sensor.tomorrow_s_garbage_pickup.state
          %}true{% else %}false{% endif %}'
        alias: If the blue cart needs to go out...
      then:
      - service: light.turn_on
        metadata: {}
        data:
          rgb_color:
          - 0
          - 255
          - 255
          effect: Pulsing
        target:
          entity_id: light.bindicator_bindicator
    - if:
      - alias: If the black cart needs to go out...
        condition: template
        value_template: '{% if "Black" in states.sensor.tomorrow_s_garbage_pickup.state
          %}true{% else %}false{% endif %}'
      then:
      - service: light.turn_on
        metadata: {}
        data:
          rgb_color:
          - 255
          - 255
          - 192
          effect: Pulsing
        target:
          entity_id: light.bindicator_bindicator
    alias: Turn on the bindicator to the correct colour
  - service: notify.mobile_app_jason_s_pixel_5
    data:
      message: Don't forget to put the {{ states('sensor.tomorrow_s_garbage_pickup')
        |     lower }} out this evening.
      title: It's garbage day!
      data:
        tag: garbageday
        sticky: true
        persistent: true
        actions:
        - action: garbagedone
          title: I've done it
  - service: notify.mobile_app_pixel_6
    data:
      message: Don't forget to put the {{ states('sensor.tomorrow_s_garbage_pickup')
        |     lower }} out this evening.
      title: It's garbage day!
      data:
        tag: garbageday
        sticky: true
        persistent: true
        actions:
        - action: garbagedone
          title: I've done it
    enabled: true
  - service: persistent_notification.create
    data:
      message: Don't forget to put the {{ states('sensor.tomorrow_s_garbage_pickup')
        |     lower }} out this evening.
      title: It's garbage day!
      notification_id: garbageday
  - wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: garbagedone
    - platform: persistent_notification
      update_type:
      - removed
      notification_id: garbageday
    timeout:
      hours: 4
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    metadata: {}
    data: {}
    target:
      device_id: b69edd668497dac53475478d5808ec3d
  - service: notify.mobile_app_jason_s_pixel_5
    data:
      message: clear_notification
      data:
        tag: garbageday
  - service: notify.mobile_app_pixel_6
    data:
      data:
        tag: garbageday
      message: clear_notification
  - service: persistent_notification.dismiss
    data:
      notification_id: garbageday
  mode: single