Automation to make a phone call via Android companion app

I don’t think so, but try this to make a call from HA via SIP.

1 Like

I don’t know if it can be done via the app but I just set up twilio to automate a call using HA.

You could set an automation for HA to tell twilio to call your desired number when you enter the home zone.

It’s $1 per month for the “rental” of the twilio phone number and a call is dirt cheap (I can’t remember exactly how much but I think it’s only a few cents per minute).

Thanks both, but the call has to come to my sim card as it’s the only one authorized on the system to open the gate. I don’t even need to connect the phone call, the gate rejects all calls and and only opens itself if the caller is authorized. Maybe is it possibile to trigger some sort of Tasker automation?

That is trickier :slight_smile:

For tasker there is this https://kleypot.com/using-tasker-to-trigger-android-tasks-from-home-assistant/

I have also been thinking about something similar! The front door intercom to my building has a sim integrated into it. You can call it to open the door, otherwise you need to put in the code. Another thought for you, I initially was also thinking of triggering via location/gps, but I was worried it would not be accurate enough. I was thinking of using a NFC tag to trigger it, something else to consider! Do let us know how you get on!

I have a solution!

  1. Need 3G GSM USB modem with stick mode firmware. I have Huawei E3131.
    From Windows PC turn off modem’s CD-ROM and SD-card by AT command:
    AT^SETPORT="FF;1,2"

  2. Connect modem with host PC (Debian 11) and find it:

$ lsusb
Bus 003 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

dmesg | grep usb
[  580.865094] usbserial: USB Serial support registered for GSM modem (1-port)
[  580.866366] usb 3-1.2: GSM modem (1-port) converter now attached to ttyUSB0
[  580.867342] usb 3-1.2: GSM modem (1-port) converter now attached to ttyUSB1
  1. Try to call with shell command from host:
    $ echo -ne "ATD+79286666666;\r\n" > /dev/ttyUSB1

  2. Change host settings to run SSH commands from hassio.

  3. Add to config.yaml:

shell_command:
  call2gate: ssh -i /config/sshkey/id_rsa -o StrictHostKeyChecking=no [email protected] 'echo -ne "ATD+79286666666;\r\n" > /dev/ttyUSB1'

where
user - is host (Debian 11) user
+79286666666 - is gate number
/dev/ttyUSB1 - is modem host port
192.168.33.112 - host IP

In recent versions of the Android Companion App, you can do it with a service call like this:

service: notify.mobile_app_<device_id_here>
data:
  message: command_activity
  data:
    intent_package_name: com.android.server.telecom
    intent_action: android.intent.action.CALL
    intent_uri: tel:<phone_number_to_call_here>
    ttl: 0
    priority: high

You need to grant some additional permissions to the app. Please see the Companion App Documentation and the Android Developer Documentation for further information.

The above has been updated to take into account changes in version 2022.8 of the Companion App and has been tested on a Samsung Galaxy S9 and S21. If you are getting an “Unable to send activity intent, please check command format” error, try removing the Phone permission from the Companion App and then reinstating it.

10 Likes

Thank you for sharing this info. I would like send an sms. I tried the following

service: notify.mobile_app_juan_android
data:
  title: tel:3009
  message: command_activity
    data:
      channel: com.android.server.telecom
      tag: android.intent.action.SEND
      ttl: 0
      priority: high
      sms_body: test

But I get “unable to send activity intent” on the phone. Have you been able to do this?

Thank you

1 Like
service: notify.<device>
data:
  message: command_activity
  title: sms:<number>
  data:
    channel: com.google.android.apps.messaging
    tag: android.intent.action.SENDTO
    group: type:vnd.android-dir/mms-sms,sms_body:Sample Message
    ttl: 0
    priority: high

This will compose the message, but the user still needs to send the message.

Thank you very much for your prompt reply. Much appreciated.

FWIW there’s also the Twilio SMS integration and UK based ClickSend SMS, which is cheaper and easier to use than Twilio, for sending text messages (there may be other options too) if it doesn’t need to come from your phone.

1 Like

For SMS, on Android at least, you can also use the IFTTT Android SMS integration to send from your phone.

I haven’t found how to automatically send without having to confirm sending using Android intents yet, although given that IFTTT can do it, it must be possible. It potentially looks like the HA Companion App may need an update to grant it SMS permissions to allow this though.

we do not qualify for this permission as we are not a default SMS app like IFTTT can be. Only certain apps are granted this permission.

That’s a pity as it would be far preferrable to be able to use intents to do this than having to resort to IFTTT, or a paid service like Twilio or ClickSend. Not sure I understand why IFTTT qualifies for it and Home Assistant doesn’t. :thinking:

1 Like

This does not work for me, says “Unable to send activity event, please check command” something like that. Does this still work for you?
P.S. I did go through the permissions and did it successfully. I also use the same notification mechanism to disable DnD mode on the phone and it works great. This one uses the native intent sending mechanism from Android though so it’s probably a lot more brittle…

Did you try this?

1 Like

oh somehow i missed it, i’ll give it a try - thanks!

This worked perfectly

intent_package_name: com.android.server.telecom
intent_action: android.intent.action.CALL
intent_uri: tel:+00xxxxxxxx
ttl: 0
priority: high

But anybody knows how to END the same call… ?

I don’t belive it’s possible, as the Android Developer Documentation makes no mention of an ENDCALL or similar intent.

thats correct there is no end call intent but looks like tasker may be used to achieve this if really desired so an intent could be created and used to interact with tasker to handle ending the call

1 Like