Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106705

Using a text input on a blueprint template

$
0
0

I’m creating a somewhat complex template blue print and I’m having an issue using the text selector in a template (jinja). I was able to reproduce using a much simpler blueprint.

So I have this blueprint:

blueprint:
  name: Text Input Tester
  description: Testing how to use a text input in a template
  domain: template
  input:
    test_text:
      name: Test Text
      description: The text to text with.
      selector:
        text:
    test_trigger_entity:
      name: Test Trigger Entity
      description: The entity to trigger this test
      selector:
        entity:
          filter:
            domain: input_boolean
variables:
  test_text: !input test_text
trigger:
  - trigger: state
    entity_id: !input test_trigger_entity
    to:
binary_sensor:
  state: >
    {% if trigger.platform == 'state' and test_text in 'this is a test' %}
      on
    {% else %}
      off
    {% endif %}
  attributes:
    testText: >
      {{ test_text }}

Here is my template binary_sensor using that template:

 - use_blueprint:
      path: sirmeili/text_input_tester.yaml # relative to config/blueprints/template/
      input:
        test_text: test
        test_trigger_entity: input_boolean.epic_tv_exception
    name: Text Input Tester
    unique_id: a36ab10b-4b7f-43b4-ad10-3257af47c6b9

When I execute the “input_boolean” I get the following error in the logs:

Error rendering state template for binary_sensor.text_input_tester: TypeError: ‘in ’ requires string as left operand, not LoggingUndefined

I thought the selector: text: was for text input and in the configuration I’m sending in Text, is this not correct?

I did try changing

  input:
    test_text:
      name: Test Text
      description: The text to text with.
      selector:
        text:

to just this:

  input:
    test_text:
      name: Test Text
      description: The text to text with.
      default: ''

Am I not comparing the text correctly in the template it self? if I change test_text with “test” it works just fine.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>