Alert templating not working correctly?

Hi,

Been busy the last week with getting home-assistant to run and so far so good. However I want to implement a template for an alert name, this should be possible according to documentation:

alert:
  garage_door:
    name: Garage has been open for {{ relative_time(states.binary_sensor.garage.last_changed) }}
    done_message: Garage is closed
    entity_id: binary_sensor.garage
    state: 'on'
    repeat:
      - 30
      - 60
      - 120
    can_acknowledge: true
    skip_first: true
    notifiers:
      - ryans_phone

Having said that however, this doesn’t work for me and I get the literal string. Looking through the sourcecode the name field is marked as string and not template. So…is it a bug in my code (exact copy of the example code for name), in the documentation or in the source?

Don’t you want to use a template in the title rather than the name ? The title officialy supports template while it’s unclear for the name.

In my opinion, the name of the alert has no reason to be a template.

The description of the options is correct (message and title support templates) but the second last example is incorrect. As looking at the component source the name definitely does not support this:

ALERT_SCHEMA = vol.Schema({
    vol.Required(CONF_NAME): cv.string,
    vol.Required(CONF_ENTITY_ID): cv.entity_id,
    vol.Required(CONF_STATE, default=STATE_ON): cv.string,
    vol.Required(CONF_REPEAT): vol.All(cv.ensure_list, [vol.Coerce(float)]),
    vol.Required(CONF_CAN_ACK, default=DEFAULT_CAN_ACK): cv.boolean,
    vol.Required(CONF_SKIP_FIRST, default=DEFAULT_SKIP_FIRST): cv.boolean,
    vol.Optional(CONF_ALERT_MESSAGE): cv.template,
    vol.Optional(CONF_DONE_MESSAGE): cv.template,
    vol.Optional(CONF_TITLE): cv.template,
    vol.Optional(CONF_DATA): dict,
vol.Required(CONF_NOTIFIERS): cv.ensure_list})

I 've created a pull request to remove that example from the documents.

2 Likes

It seems logical.

Thanks @tom_l