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.

Does anyone know why critical: 0 seems to send a notification sound with no actual notification? I’m trying to get a critical notification if I left something open at home after I leave, and a regular notification if everything is closed up properly, but when critical is 0, I get the sound like I get a notification but nothing actually ends up coming through. This also happens if I remove the template and just set critical:0

data_template:
  data:
    push:
      category: home_secure
      sound:
        critical: >
          {% if is_state('group.doors_windows', 'off') and
          is_state('group.garage_doors', 'closed') %}
            0
          {% else %}
            1
          {% endif %}
        name: default
        volume: 1
      thread-id: home-secure
  message: >
1 Like

Anybody, this should be a supported feature if it is not.

1 Like

I managed to get mine working. Here are the JSON codes.

{
   "title": "Motion Detected",
   "message": "Press and hold to see live feed",
   "data": {
       "subtitle": "Someone at the front door.",
       "push": {
           "sound": {
                "name": "3rd_party_critical.caf",
                "critical": 1,
                "volume": 1 },
           "category": "camera"
           
        },
       "entity_id": "camera.rpizero2w"
    }
}