Can you define a global VAR to define a device to notify and use in Automations?


I’m trying to find out if it is possible to define a (global?) variable that identifies a mobile device entity (e.g. device_tracker.device_name_here).
Since I have several Automations that use the Notifications service I’m looking for an easier way to make the Automation more generic and use a variable that defines the device to notify.
When you switch device, then you don’t need to update several Automations to send messages to the correct device.

Hope this makes sense…

And thanks in advance!

Maybe the Integrations add in called “Variable” may help.

Thanks, have that already in my config.yaml, but I’ve not been able to get it working when using device notifications in Automations :roll_eyes:

Okay, I had similar issues that I finally solved (with much guidance here) by using the Config Template Card available in the “Frontend” add ins.

Depending on where/how you’re using it you can define your “variable” as a secret in secrets.yaml.

In your automation, script etc.:

icon_url: !secret ALARM_ICON

In secrets.yaml:

ALARM_ICON: /local/images/notification/alarm_icon.png

Poudenes recently posted an interesting observation: Variables.yaml file included in automation

Specific to your use case.

You can group notify services and you can have a group of one.

When I get a new phone I just update my group membership

Use case is: when entering or leaving zone(s), notify several mobile devices.


#Notification Groups
  - name: family_devices
    platform: group
    - service: mobile_your_phone_here
    - service: mobile_your_so_phone_here

  - name: family_devices_verbose
    platform: group
    - service: mobile_your_phone_here

  - name: admin_devices
    platform: group
    - service: mobile_your_phone_here

Thank you for this - super!