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!

2 Likes

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

1 Like

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

1 Like

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

Three years after this was first asked. Does anybody know if this is now possible (I cannot see a way, but am hoping I’ve missed something). Would like to turn down music, TV etc and raise lighting (if dimmed for TV) when the phone rings or a call is answered/made

I think we might ask in the discord to the app developers if they can implement a sensor for this option. I will try there and keep you guys posted :wink:

Actually @zacwest just confirmed the only solution would be to create a shortcut as per his earlier post in here… anyhow apparently apple provide CallKit | Apple Developer Documentation
therefore there could be some possible development of a sensor in the app.

1 Like