iOS Critical Notifications

Hi all HA Guys,
I’m having hard times in automating a critical alert in my configuration.
I’m on
iOS 13
HA 0.98.5
Companion App 2.0 .

If I use the “test” under Dev Tools -> services , calling my iphone notification service with this Json:

{
    "title": "my test!",
    "message": "Testing if this works",
    "data": {
        "push": {
            "sound": {
                "name": "default",
                "critical": 1,
                "volume": 1
            }
        }
    }
}

Everything is fine, I receive Critical Alerts when in sleep mode.

But If I put this code in automations.yaml, I receive the Notification, but at normal level:

- alias: Avviso se un sensore di porte o movimento si apre
  trigger:
  - platform: state
    entity_id: binary_sensor.finestra_camera,binary_sensor.finestra_bagno,binary_sensor.finestra_cucina,binary_sensor.porta_ingresso,binary_sensor.finestrina_sala,binary_sensor.ir_balcone_cucina,binary_sensor.ir_balcone_sala
    to: 'on'
#  condition: 
#    condition: state
#    entity_id: group.famiglia
#    state: 'not_home'
  action:  
    - service: notify.mobile_app_iphone
      data_template:
        title: "Smart Home"
        message: "rilevata effrazione {{ trigger.to_state.attributes.friendly_name }}"
        data:
          push:
            category: "alarm"
            sound:
              critical: 1
              name: default
              volume: 1.0 

Is anyone able to understand what I’m missing ? I tried several times making minor changes, but without success.

I am not running iOS 13 yet so cannot test for sure but this is an automation that works 100% for me

  alias: Work to Home Days
  initial_state: True
  trigger:
    platform: numeric_state
    entity_id: sensor.neil_work_to_home
    above: 70
  condition:
    - condition: time
      after: '18:00'
      before: '21:00'
    - condition: state
      entity_id: input_boolean.days
      state: 'on'
  action:
    service: notify.mobile_app_neils_iphone
    data:
        title: "Traffic Alert - Work to Home Days"
        message: "Current travel time is {{ states.sensor.neil_work_to_home.state }} minutes"
        data:
          push:
            #category: "alarm"
            sound:
              critical: 1
              name: default
              volume: 1.0 # 0.0 to 1.0

Hi Neil, thanks for the snippet. I tried everything without success.
I tried to convert the Dev Tools version to Yaml using a online converter to be ABSOLUTELY sure.
It sounds like a bug to me, or a strange combination of HASS and iOS App Version. I’ll try with the next releases. The only difference between my version and yours is that I use data_template: after service line. But if I change it to data: I don’t receive any notification.

My final code is:

  trigger:
    platform: state
    entity_id: 
        - person.gaia 
        - person.mamma
        - person.giulio
    to: 'home'
  action:
    - service: notify.mobile_app_iphone
      data_template:
        title: 'Smart Home'
        message: '{{ trigger.to_state.attributes.friendly_name }} è rientrato'
        data:
          push:
            sound:
              name: default
              critical: 1
              volume: 1

Wooo, just found what was going wrong.
I tried to remove the multiple entities and leave a single one for testing.
I switched than back to data: rather than data_template

- alias: 'Ritorno a casa - Notifica cellulare'
  trigger:
    platform: state
    entity_id: person.giulio
    to: 'home'
  action:
    - service: notify.mobile_app_iphone
      data:
        title: 'Smart Home'
        message: 'Giulio è rientrato'
        data:
          push:
            sound:
              name: default
              critical: 1
              volume: 1.0

This version work seamlessly. Now I’d like to understand how to create a version where I can use multiple entities triggering the automation and replacing the trigger entity friendly name in the message.
Anyone can help ?

Thanks

You can’t.

data_template casts the int / float params to string, and the mobile_app component does not accept those params as a string.

There is an open issue for this problem:

1 Like

Does anyone knows how to make a critical alert work on iOS Shortcuts using call service?

I’m a bit confused with how to format service data, ideally using a dictionary action prior to the call service one.