Have Home Assistant Do Something When Phone Rings (Android)

Okay. I’ve been making progress but haven’t gotten into Tasker yet.

input_boolean.yaml:

phone_in_progress: name: "Phone Call In Progress" initial: off

configuration.yaml:

[code]automation:

  • alias: “Incoming Phone Call”
    trigger:
    platform: state
    entity_id: input_boolean.phone_in_progress
    state: “on”
    action:
    service: script.turn_on
    entity_id: script.phone_in_progress
  • alias: “Phone Call Complete”
    trigger:
    platform: state
    entity_id: input_boolean.phone_in_progress
    state: “off”
    action:
    service: script.turn_on
    entity_id: script.phone_progress_complete[/code]

Now here’s the fun part:

phone_incoming: alias: "Incoming Phone Call" sequence: - service: input_boolean.turn_on data: entity_id: input_boolean.phone_in_progress - service: light.turn_on data: entity_id: group.all_lights brightness: 255 - delay: seconds: 2 - service: light.turn_on data: entity_id: group.all_lights brightness: 32 - delay: seconds: 1 - service: light.turn_on data: entity_id: group.all_lights brightness: 192 - delay: seconds: 2 - service: light.turn_on data: entity_id: group.all_lights brightness: 32 - delay: seconds: 1 # repeating... phone_answered: alias: "Phone answered" sequence: - service: script.turn_off data: entity_id: script.phone_incoming - service: light.turn_on data: entity_id: group.all_lights brightness: 128 phone_in_progress: alias: "Phone Call In Progress" sequence: - service: media_player.volume_mute data: entity_id: media_player.Living_Room_Receiver is_volume_muted: "true" phone_progress_complete: alias: "Phone Progress Complete" sequence: - service: script.turn_off data: entity_id: script.phone_incoming - service: media_player.volume_mute data: entity_id: media_player.Living_Room_Receiver is_volume_muted: "false"

For testing, I have activated “Incoming Phone Call” from the frontend. This turns on the input boolean’s “Phone in Progress” which then activates the associated script, thereby muting my home theater receiver. This begins the ringing mode until I activate the “phone answered” script, which stops the “Incoming Phone Call” script and the lights are set to a preset level Once done, turning off the “Phone Call In Progress” activates the “Phone Call Complete” script.

Wow. Can’t believe I’m implementing the smarts! LOL!

Well, I could probably figure things out from here with Tasker, although I’m unsure if Tasker supports cURL, but the Tasker forum would be more suitable than here, as I’ll need to figure out how to get tasks executed so long as I’m in my own Wi-Fi Network.

Thanks.

Update as of 3:54 PM EST: After I execute the “Phone Ringing” task,Tasker will immediately follow by “Phone idle;” thus, immediately triggering the “Phone Call Complete” script but it seems the input boolean for “phone call in progress” did not turn off in time. I’ve had to add a delay right before media_player.volume_mute and that’s how I know – that when I watch the frontend, “Phone Progress Complete” switches to the “on” position for a number of seconds I’ve set and then unmutes my receiver.

I think it’s Tasker that does this kind of behavior. The only thing I can rule out is this:

[code]curl -X POST -d ‘{“entity_id”: “script.phone_incoming” }’ Http://localhost:8123/api/s
ervices/script/turn_on

curl -X POST -d ‘{“entity_id”: “script.phone_answered” }’ Http://localhost:8123/api/s
ervices/script/turn_on

curl -X POST -d ‘{“entity_id”: “input_boolean.phone_in_progress” }’ Http://localhost:8123/api/services/input_boolean/turn_off[/code]

The three commands are executed as expected. If this were for real (I don’t have another phone number to test), Tasker will probably not execute the “Phone idle” immediately after “phone ringing.”