Ios: Sounds settings ignored when using `data_template`

Created on 3 Dec 2019  路  8Comments  路  Source: home-assistant/iOS

I have a notification that is not passing the critical event sound or icon but is passing the title, message & badge correctly:

  action:
  - service: notify.mobile_app_vic_iphone
    data_template:
      title: "Water Sensor Alert"
      message: "Water detected from {{ trigger.to_state.attributes.friendly_name }}"
      data:
        push:
          badge: 1
          sound:
            name: default
            critical: 1
            volume: 1.0

The following works as expected:

  action:
  - service: notify.mobile_app_vic_iphone
    data:
      title: "Water Sensor Alert"
      message: "Water detected from TESTING STATIC DATA"
      data:
        push:
          badge: 1
          sound:
            name: default
            critical: 1
            volume: 1.0

From Discord discussion: The "sound dictionary" may be affected and "it seems the contents of {data: {push:{*}}} aren't passed through when data_template is used"

2020.1 bug

Most helpful comment

All 8 comments

For benefit of Robbie, we did a fair amount of testing of this on Discord. I can produce this, you don't need to use a template anywhere bust as soon as you switch to data_template it seems critical: 1 is ignored

Perhaps I shouldn't be writing this, as I really don't have a clue; merely guessing. But have you tried adding extra data's?

action:
- service: notify.mobile_app_vic_iphone
  data_template:
    title: "Water Sensor Alert"
    message: "Water detected from {{ trigger.to_state.attributes.friendly_name }}"
    data:
      push:
        data:
          badge: 1
          sound:
            data:
              name: default
              critical: 1
              volume: 1.0

I might be wrong, but seem to recall an instance where I experienced a surprising difference between data and template_data, and that it, for some reason, was fixed when I added additional data's for each sub-dictionary, so to say?

Or, have you tried replacing the subsequent data's to data_template's even though no template is actually used?

Trying @krissen's suggesting result in no notification and the following error in logs for me:

apns.payload.aps.sound.name must be a non-empty string

Moving name into the sound dictionary and leaving the rest in a new data sub-dictionary just results in a normal notification as before

Temporary fix applied on the server side to coerce critical to an int but that may break setups where people say true or false instead of 1 or 0.

Paulus points out you can also put some stuff in data and other stuff in data_template. But it is expected behavior for data_template to aggressively coerce everything to strings.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamieshaw picture jamieshaw  路  8Comments

riemers picture riemers  路  11Comments

wolverinevn picture wolverinevn  路  3Comments

TacoRocket picture TacoRocket  路  8Comments

snowe2010 picture snowe2010  路  12Comments