Notify Mobile Companion App Devices

@Grumblezz So I guess after I imported the blueprint I have to go to blueprints and create a script?
I then enter as entity ID the id of my mobile phone of the companion app (notify.mobile_app_pixel_6 → so I enter just pixel_6).
Then a script named pixel_6 is created and I can go to the developer tools.
After I selected script.pixel_6 and filled the request with example data I executed the service and got the error:
Fehler beim Aufrufen des Diensts script.pixel_6. Unable to find service notify.mobile_app_pixel_6_2

Why is it trying to call the mobile_app_pixel_6_2 instead of mobile_app_pixel_6?
Did I anything wrong?

I have taken a few screenshots that show how to import and use the script. I hope that helps

  1. Import the Blueprint : Click here

  2. Click on Preview and followed by Import Blueprint

  3. Create the script by clicking on Create Script

  4. Enter the Name, Icon and “Entity ID”. The “Entity ID” will become script.<entity_id>. So in this case script.notify_mobile_app_devices . Click on Save Script

    .

  5. Check you mobile app devices

  6. Navigate to the developer tools to validate the imported script. So in this case script.notify_mobile_app_devices where the “Device to notify” should be the same as the previous step.

  7. Enter a “Notification message” click on Call Service.

  8. Check your phone and you should see the notification

That should be it :slight_smile:

1 Like

I consistently get a ‘timeout’ when trying to import your blueprint using the button, which I do not experience with other blueprints. Any clue what might cause this?

Have you tried pasting the GitHub url? Maybe Pi Hole or another service is blocking this action?

The file is hosted on GitHub, so not some random webserver or so… The links that I have used where generated via the Home Assistant (Create a link – My Home Assistant) Link generator. So all of it refers to services that should be generally be accessible

HI , TTS on iOS does not work? Any idea?

Well, turns out disabling IPv6 did the trick. No clue why that didn’t interfere with other blueprints, but that does not matter now, it’s solved. Found the solution here: Timeout error while importing blueprint - #6 by Mr-Beat

Good one! I had a similar issue yesterday as well. Thanks for the feedback

I seem to have the same issue. I will have a look at it

TTS appears an Andriod only thing…

In the docs it is also only mentioned for Andriod
Introduction | Home Assistant Companion Docs (home-assistant.io)

With Frigate blueprint TTS works in IOS…. so it seems an issue in the Skript ?!

Can you share that blueprint? Because I’m using the companion app features.

Sure….

When I look at there code they have the same limitations of the mobile app. So no, you can’t use TTS on iPhone. What their Blue print does, is that it make use of the build in sounds of iPhone/Homeassistant. This same thing can also be done in this blueprint. So please check this page: Sounds | Home Assistant Companion Docs and then use your custom sound file name in this script

So here are some examples

FYI: update the service name to what ever you have defined during the creation of the blueprint, mine is called script.notify_devices

Example 1
This will send an sound notification to all of the IOS devices which have the mobile app installed. By default the sound level is set to 50%

service: script.notify_devices
data:
  notify_message: There is somebody at the door!
  data_ios_sound: US-EN-Alexa-Motion-At-Front-Door.wav
  notify_home_or_away: Both
  notify_devices: >-
    {%set devices=namespace(id=[])%}
    {% for device in (expand(integration_entities('mobile_app'))|selectattr('domain','in','device_tracker')|map(attribute='entity_id')|list) %}
    {% if is_device_attr(device,'manufacturer','Apple')==true%}
    {%set devices.id=devices.id+[(device_id(device))]%}
    {%endif%}
    {%endfor%}
    {{devices.id}}

Example 2
This will send an sound notification to all of the IOS devices which have the mobile app installed. Volume MAX and a critical notification marker

service: script.notify_devices
data:
  notify_message: There is somebody at the door!
  data_ios_sound: US-EN-Alexa-Motion-At-Front-Door.wav
  notify_home_or_away: Both
  data_critical: true
  data_ios_sound_volumelevel: 1
  data_ios_interruption_level: critical
  data_ios_presentation_options:
    - alert
    - sound
  notify_devices: >-
    {%set devices=namespace(id=[])%}
    {% for device in (expand(integration_entities('mobile_app'))|selectattr('domain','in','device_tracker')|map(attribute='entity_id')|list) %}
    {% if is_device_attr(device,'manufacturer','Apple')==true%}
    {%set devices.id=devices.id+[(device_id(device))]%}
    {%endif%}
    {%endfor%}
    {{devices.id}}

1 Like

Just wanted to say thank you for this blueprint! I never digged in to the details of how to trigger notifications in the companion app, and thanks to your work, I don’t need to either. Great work! Very appreciated!

1 Like

Thanks for this!
I have been personally struggling with how to pass data into a script blueprint and eventually gave up. You have provided a roadmap for me.
I truly appreciate your contribution to the community!
Time for more BP’s!

1 Like

A new version has released Release 2023.06 · Grumblezz/Home-Assistant-Notify-Mobile-Companion-App-Devices (github.com) check it out!

1 Like

Hi,

Thanks for this.

I have another question, related to the source of truth.

Rencently I have this in the script options:

Response variable This service can return a response, if you want to use the response, enter the name of a variable the response will be saved in 

However I cannot find this variable if in the github repo
`response_variable``

Hi zaggash,

The group feature is not supported by this automation, but there are a few options:

  • Make a feature requests at Home Assistant to be able to create a group with device_tracker objects. Because this is currently not supported.
  • Do not use the group option to call this script, but instead use a template , to filter for the devices and pass it on to this script, like:
{% set ns_devices=namespace( device_id=[] ) %}
{% for e in (integration_entities("mobile_app")|select("search","device_tracker")|list) %}
{% set ns_devices.device_id=ns_devices.device_id+[device_id(e)] %}
{% endfor %}
{{ ns_devices.device_id }}

And then add additional select() options to the second line

Or…

{% set ns_devices=namespace( device_id=[] ) %}
{% for e in ['device_tracker.apple','device_tracker.android'] %}
{% set ns_devices.device_id=ns_devices.device_id+[device_id(e)] %}
{% endfor %}
{{ ns_devices.device_id }}

Secondly the TTL feature is already available in the script by enabling the Important Notification. That will set the TTL to 0.