Detecting if an iPhone is in a call

Hi everyone, is there a way to detect when a phone is in a call using the iOS integration and the companion app?

I would like to build some sort of automation like “if the phone rings or i am in a call, pause roomba or pause the media player”

Is there any way to do that at all or iOS is too strict about these things?
thanks!

You may be able to get this working using Shortcuts.app’s automation > “when Phone is opened” to execute a service call or fire an event. There’s no way for the app to be notified of this otherwise.

hmm will look into that… is that even possible with shortcut?
I cannot find any trigger that says “when an app is opened do something”…

In the Shortcuts app it’s under the “Automations” tab and then “Create Personal Automation.” There’s an “Open App” trigger there. After that you can add the Home Assistant actions (pausing your roomba and media players) by following these docs.

I’ve just tested this myself and here’s what I found. When you answer a phone call from the lock screen, it doesn’t actually open the phone app, it’s like a background process or something. But if you then tap on the Phone app and make that active on screen, your shortcut will run.

So it kinda sorta works, but maybe not quite to the level you’re wanting. iOS 14 beta added new personal automation triggers for emails and text messages in Shortcuts, but not phone calls yet. Hopefully that is next on Apple’s list…

Just tried it… indeed it is linked to the app being manually opened so not really fit to an automation purpose.

I will probably use a simpler automation like a button to pause the roomba itself and wait for some automation triggers in the future…
thanks!

The Android app is pretty straight forward, however, I am trying to run some automations based on in call status. Does anyone know if this sensor is available in the IOS mobile app?

alias: New Automation
description: ''
trigger:
  - platform: state
    entity_id: sensor.phone_name_phone_state
    to: offhook
    id: offhook
condition: []
action:
  - service: media_player.media_pause
    target:
      entity_id: media_player.device
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.phone_name_phone_state
        to: idle
        id: idle
  - service: media_player.media_play
    target:
      entity_id: media_player.device
mode: single

you can double check this in developer mode opening the phone state then place a phone call check to see that the state changes and what it changes to use this as your trigger

My phone is called iphone_12 but I don’t have a sensor.iphone_12_state and among the sensor I have for iphone_12, none of them contains info about offhook
Is there something I have to enable on the iOS app?

EDIT: and on the logbook I don’t have any entry about phone calls.

It is not possible with the iOS app

check the configuration on your ios hass app and loot to see if there are sensors disabled