home-assistant / iOS

:iphone: Home Assistant for Apple platforms
https://companion.home-assistant.io
Other
1.49k stars 285 forks source link

clear_notification does not work properly for notification groups #1822

Open svh1985 opened 2 years ago

svh1985 commented 2 years ago

I'm not sure if I should post this issue here or in the core repo, but as its specific to iOS I figured this would be a good place to start first.

iOS device model, version and app version

Model Name: iPhone 11p & iPhone XR Software Version: 15beta & 14.7.1 App version: 2021.7 (2021.202)

Home Assistant Core Version

core-2021.8.0

Describe the bug

  1. Created a notification group with our two iPhones (notify.all_iphones).
  2. Created an automation which sends a notification (including a tag)
  3. After x min timeout I want the notification to disappear on both iPhones using the clear_notification with tag

But for some reason the notification only disappears on one of the phones. The iPhone 11 Pro to be exact, the notification remains visible on the iPhone XR.

Notify group:

- platform: group
  name: all_iphones
  services:
    - service: mobile_app_iphone_xr
    - service: mobile_app_iphone_11_pro

Automation:

alias: Verwarming - Zet 's ochtends aan
description: ''
trigger:
  - platform: time
    at: '08:00:00'
condition:
  - condition: state
    entity_id: binary_sensor.someone_home
    state: 'on'
  - condition: template
    value_template: >-
      {{ not is_state_attr('climate.thermostaat', 'temperature',
      states('input_number.temperature_high')) }}
action:
  - service: script.set_high_temperature
  - alias: Set up variables for the actions
    variables:
      notification_tag: '{{ ''TAG_'' ~ context.id }}'
  - service: notify.all_iphones
    data:
      title: Verwarming
      message: >-
        Automatisch ingesteld op {{ state_attr('climate.thermostaat',
        'temperature') }}℃
      data:
        tag: '{{ notification_tag }}'
  - wait_template: ''
    continue_on_timeout: true
    timeout: '00:00:30'
  - service: notify.all_iphones
    data:
      message: clear_notification
      data:
        tag: '{{ notification_tag }}'
mode: single
zacwest commented 2 years ago

It's likely the clear command isn't waking the app on one of the devices. It looks like the app needs to be launched roughly weekly to keep this working, and Apple has denied our request for permission to make this reliable. We will needs to update the docs to point out this limitation, as it was guessed at but not known prior to the release of the feature.

svh1985 commented 2 years ago

Thanks for your quick response. So, do I understand correctly that this is an issue related to the clearing of the notifications itself, and has nothing to do with the notify.group? In this case, the HA app of the iPhone XS did not correctly respond to the clearing request?

Stooovie commented 2 years ago

Have you been able to clear ANY notification? I can't get any notification cleared, at all. iOS 15.2 on HA app v. 2021.12.1

wilfreddijksman commented 2 years ago

Since a few weeks I experience clearing notifications fails. I launch the companion app daily on the iOS device the issue occurs on.

An example of the service calls I use: Setting notification:

service: notify.all_cell_phones
data:
  title: Verwarming staat aan 🔥
  message: … terwijl er niemand thuis is.
  data:
    tag: heating_on_while_away
    actions:
      - action: SET_HEATING_LOWER
        title: Zet temperatuur 1,5 °C lager
        authenticationRequired: false
      - action: SET_HEATING_MODE_AWAY
        title: Zet afwezige modus aan
        authenticationRequired: false
        destructive: true

Clearing notification:

service: notify.all_cell_phones
data:
  message: clear_notification
  data:
    tag: heating_on_while_away

iOS Home Assistant Companion: 2022.2 (2022.343) Home Assistant: 2021.12.10 Installation type: Home Assistant OS