Why does this:
throw this error?
you cannot use templates here. do it in yaml file
NOT TRUE! See below
You can’t use templates in the dev tools
Edit: @AhmadK JINX
But why does this work?
can you call persistent_notification.create
service with the same data and tell us how it works?
Works!
well spotted!
so it looks like it depends on an integration - some of them accept templates in input data and some don’t.
here’s how input_number
is configured inside
:
component.async_register_entity_service(
SERVICE_SET_VALUE,
{vol.Required(ATTR_VALUE): vol.Coerce(float)},
"async_set_value",
)
so good luck in passing templates to it
on the other hand, with persistent_notification
:
SCHEMA_SERVICE_CREATE = vol.Schema(
{
vol.Required(ATTR_MESSAGE): cv.template,
vol.Optional(ATTR_TITLE): cv.template,
vol.Optional(ATTR_NOTIFICATION_ID): cv.string,
}
)
So yes, it depends on an integration you’re using.
Speaking about persistent_notification
- the docs would benefit from mentioning this handy feature.
Actually, I use it all the time but didn’t think there is no mention of templates’ support in the docs.
It’s there, but below service parameters’ description - not ideal I’d say, so easy not to reach that line…
PR merged!
@jocnnor, looks like we’re too fast to answer