Using value template as a service name for notify

Hi there,

First post here so excuse me if I did anything wrong!

I’m trying to make my life easier and use variables to refer to phones throughout hass. With this, I’m trying to refer to one of the variables in my configuration.yaml when specifying which phones to send notifications to.

The following works fine as is:

  - name: ALL_PHONES
    platform: group
      - service: mobile_app_my_iphone
      - service: mobile_app_my_partners_iphone

… and the following evaluate fine when using the template tester in developer tools:


… but when I try to do something like this is my configuration.yaml:

      - service_template: > 
          mobile_app_{{ states("variable.my_phone") }}

… I get this error:

homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Invalid config for []: required key not provided @ data['services'][2]['service']. Got None. (See ?, line ?).

Not sure what to do about this. Any help would be greatly appreciated!

  1. that’s not a valid service. The service would be notify.mobile_app_{{..
  2. service_template and data_template are no longer needed. Just use service and data everywhere.

You can find your list of services in developer tools → services (tab). You’ll notice they all have a domain and id. i.e. where, notify is the domain and the id is mobile_app_..

Thank you for that!

The following service call works works when I put it into the services yaml editor in developer tools:

service: notify.mobile_app_{{states("variable.my_phone")}}
  message: Test

… but if I put this into the configuration.yaml file:

  - name: ALL_PHONES
    platform: group
      - service: notify.mobile_app_{{states("variable.my_phone")}}

I still get the same error. Is there something I’m missing?

You can’t template a notify group. And the services section of a notify group requires a list of id’s, not the whole service name. This is different than the services that go into the actions of an automation, do not get them confused.

You can tell if a field is templatable by looking at the docs. If it says template, it can be templated.

Thank you so much for your help and tips! I’m still settling in with home assistant and now I know what to look out for when I run into a similar issue.
I really appreciate it!