Split in Automation Template

Hello everyone, I’m currently trying to create a template in an automation.

I have 2 values,

Value1:
input_text.notification_to_processing

(Alexa: This is a test 8)

Value2:
input_text.benstufen_david

(Debug: Info: Alexa:)

I want from

input_text.notification_to_processing

Remove the first part before the : and then compare whether this part is present in input_text.benstufe_david.

condition: template
value_template: "{{ states('input_text.notification_for_processing').split(':')[1] in states('input_text.benstufe_david') }}"

I always get the following error:

In 'template' condition: TypeError: 'in <string>' requires string as left operand, not LoggingUndefined`

What am I doing wrong? Does anyone have a hint?

To understand you right: You want to check, if the word „Alexa“ is in input_text.benstufen_david ?

If so, copy and paste the following into Developer Tools —> Template:


{% set n = states('input_text.notification_to_processing').split(':')[0] %}
{% set b = states('input_text.benstufen_david') %}

{{ n }}
{{ b }}
{{ b is search(n, ignorecase=true) }}

@pedolsky

Yes right!

That works great! Thank you very much :slight_smile:

1 Like