@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?
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
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.
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
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
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
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}}
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!
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!
I read the whole thread but I did not find a way to use a group of phone instead of selecting each one individually.
This would help if we change the phone to not edit all the automations but only the group !
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.