Clear notification

Hey guys,

I’ve been reading the notification documentation and noticed the function called clear_notification (Introduction | Home Assistant Companion Docs) which should allow you to remove a notification from the notifications on your phone (if I understand it correctly) by giving a notification a tag when it is sent out and then giving that tag name in the clear_notification service call.

I tried this with an automation where I sent out a notification to put the garbage at the street for emptying, and the idea was that I either push the done button on the notification, scan a nfc tag or wait until it is 19:00 in the evening to clear the led light and push the automation further and when the NFC tag is scanned or when the time is 19:00 first, it should clear the notification before continuing with the rest.

Sadly somehow the tag works and time works, but the notification is not removed…

Can somebody help me out with this?

      - conditions:
          - condition: state
            entity_id: sensor.hvc_hvc_afval_kalender_morgen
            state: gft
        sequence:
          - wait_for_trigger:
              - platform: time
                at: "05:00:00"
          - service: notify.mobile_app_moto_g200_5g
            data:
              message: HVC GFT wordt morgen opgehaald
              title: HVC Afvalkalender
              data:
                actions:
                  - action: TURNOFF_LAMP
                    title: Gedaan
                    tag: hvc_notification
          - service: light.turn_on
            data:
              rgb_color:
                - 13
                - 255
                - 0
              brightness: 255
            target:
              device_id: 7a1c483a5726b0f927d8275f9ce7582f
          - wait_for_trigger:
              - platform: time
                at: "19:00:00"
              - platform: event
                event_type: mobile_app_notification_action
                event_data:
                  action: TURNOFF_LAMP
              - platform: tag
                tag_id: b1f67dea-7c4f-42f2-aea0-fa384138defe
          - if:
              - condition: numeric_state
                entity_id: sensor.sensenode_lux
                below: 25
            then:
              - service: light.turn_on
                data:
                  rgb_color:
                    - 255
                    - 204
                    - 0
                  brightness: 75
                target:
                  device_id: 7a1c483a5726b0f927d8275f9ce7582f
              - service: notify.mobile_app_moto_g200_5g
                data:
                  message: clear_notification
                  data:
                    tag: hvc_notification
            else:
              - service: light.turn_off
                data: {}
                target:
                  device_id: 7a1c483a5726b0f927d8275f9ce7582f
              - service: notify.mobile_app_moto_g200_5g
                data:
                  message: clear_notification
                  data:
                    tag: hvc_notification

The tag is not part of the action check the docs again for proper usage. You have the correct location of tag when you attempt to clear the notification but not when you create the notification with the action buttons.

          - service: notify.mobile_app_moto_g200_5g
            data:
              message: HVC GFT wordt morgen opgehaald
              title: HVC Afvalkalender
              data:
                tag: hvc_notification
                actions:
                  - action: TURNOFF_LAMP
                    title: Gedaan
3 Likes

Wow, how could i have missed that! It works like a charm now :slight_smile: thx a lot!