CarPlay Support

When using iOS actions (eg for CarPlay, Apple Watch, widgets…), no actual HA status is visible in the action itself. To overcome this, it might often be desired to have an action which will trigger a notification (or even an ‘actionable notification’) to be returned immediately. Such actionalable notifications can have many more actions and may include information on the actual status of your home.

With the new carplay support, you’ll notice HA notifications are only shown in the car if these are pushed as critical. Yet, when the same action would be launched from another source (eg Apple Watch) it might probably not be desired to get the notification as a critical (making a lot of noise).

So to make sure the notification is send as a critical one when the iOS action is launched from car (triggerSource carPlay), while still sending it as a standard (actionable) notification when send from Apple Watch, below little example can be used.

This makes the iOS actions very powerfull (especially for Apple Watch, see also these action tricks for Apple Watch). In the car the actions of the actionable notification can not be used, yet, critical notifications will be visible and the message can be read aloud by Siri.

ios action:

ios:
  actions:
    - name: AlarmStatus
      background_color: "#000000"
      label:
        text: "Alarm status info and actions"
        color: "#ff0000"
      icon:
        icon: alarm_light
        color: "#ffffff"

automation:

alias: Alarm status iOS event action
description: ""
trigger:
  - platform: event
    event_type: ios.action_fired
    event_data:
      actionName: AlarmStatus
  - platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: AlarmStatus
condition: []
action:
  - variables:
      critical_desired: >-
        {% if states('sensor.iphone_activity') == 'Automotive' or 
        (trigger is defined and trigger.event is defined and
        trigger.event.data.triggerSource == 'carPlay') %}1{% else %}0{% endif %}
  - service: notify.iphone_notification_group
    continue_on_error: true
    data:
      title: Alarm status
      message: >-
        {{now().strftime("%H:%M:%S %d/%m/%Y")}}
        Alarm status: {{states('alarm_control_panel.home_alarm')}}
      data:
        push:
          sound:
            name: default
            critical: "{{critical_desired}}" #1 for cticial, 0 for non critical
        entity_id: camera.doorbell
        attachment: #show image as attachment
          content-type: jpeg
        url: /lovelace-alarm/alarm
        group: alert #combine notifications together visually
        tag: alarm #replace previous alarm notification
        actions:
          - action: AlarmBlock
            title: Temporary block the alarm
            activationMode: background
            authenticationRequired: true
            destructive: false
            behavior: default
          - action: AlarmSirene
            title: "Sirenes en light ALARM"
            activationMode: background
            authenticationRequired: true
            destructive: true
            behavior: default