Just try to Concat/Join strings


I have pass all this afternoon to try to concatenate strings…
Tried Join, +, & with no luck!
Do you know the synthax?
Thanks a lot for your help.

  - device_id: 04f3b98e4924c358996481802d04641d
    domain: mobile_app
    type: notify
    title: ''
    message: '{{ ''mobile_'' &  trigger.entity_id.split(''.'')[1] }}'

I believe it is a ~ like this

message: '{{ ''mobile_'' ~  trigger.entity_id.split(''.'')[1] }}'

Many thanks, it works great now!

The part after the “.” is called the object_id, so you could also access it with trigger.to_state.object_id.

+ can be used to operate on like objects, and I would have expected {{ 'mobile_' + trigger.to_state.object_id }} to work. This works for me:

{{ "foo_" + states.switch.fr_table_lamp.object_id }}foo_fr_table_lamp

~ can concatenate arguments of different types. For instance,

{{ "foo" + 5 }} results in

TypeError: can only concatenate str (not "int") to str

But {{ "foo" ~ 5 }} produces the likely desired result: