Use template in input_text.set_value

I’m trying to write a template that performs an action to set an input_text but I can’t get it to work. This is what I wrote

- trigger:
    - trigger: event
      event_type: carbu_com_lowest_fuel_price_on_route
  sensor:
    - name: "Cheapest Fuel Station on route"
      state: "{{ trigger.event.data.price }}"
      attributes:
        fuel_type: "{{ trigger.event.data.fuel_type}}"
        fuelname: "{{ trigger.event.data.fuelname}}"
        postalcode: "{{ trigger.event.data.postalcode}}"
        supplier: "{{ trigger.event.data.supplier}}"
        url: "{{ trigger.event.data.url}}"
        entity_picture: "{{ trigger.event.data.entity_picture}}"
        address: "{{ trigger.event.data.address}}"
        city: "{{ trigger.event.data.city}}"
        latitude: "{{ trigger.event.data.latitude}}"
        longitude: "{{ trigger.event.data.longitude}}"
        region: "{{ trigger.event.data.region}}"
        date: "{{ trigger.event.data.date}}"
  action:
    - action: input_text.set_value
      metadata: {}
      target:
        entity_id: input_text.waze_url
      data:
        value: >-
          "{{ https://waze.com/ul?q={{trigger.event.data.supplier}}{{trigger.event.data.address}} | replace(" ", "%20") }}"

Everything works correctly if I just use static string values, but when I try templating it breaks, so there is some problem with the templating and I can’t figure out what I’m doing wrong.Thanks to anyone who’ll help me

Remove the " around the template
You already use the >-

Edit there was more…

      data:
        value: >-
          {{ ("https://waze.com/ul?q=" ~ trigger.event.data.supplier ~ trigger.event.data.address) | replace(" ", "%20") }}

(post deleted by author)

I believe he needs %20 on all spaces in the string not just the last part

thank you so much, it worked, and yes, I needed %20 on the whole string, not just the last part

I wouldn’t use replace at all, the urlencode filter seems a safer bet.

1 Like

(post deleted by author)