Problems with a template not providing expected results in Lovelace card

I am trying to use a template in button card but not getting the expected results. I think it is because the the result of the template is not a proper string.

This is how I want the results to end up

tap_action:
  action: url
  url_path: 'http://172.16.0.176'

Except that I want the url entry to come from a template. These are the three versions I have tried in the developer template tool and they all seem to work fine there, but not as the url_path in button card.

{{ "http://"~state_attr('sensor.tuyad7_status', 'IPAddress')}}

{{'http://'}}{{state_attr('sensor.tuyad7_status', 'IPAddress')}}

http://{{ state_attr('sensor.tuyad7_status', 'IPAddress') }}

Any ideas ?

It’s likely that you can’t use templates there. There is certainly no mention of it in the documentation.

Hey, did you find a solution?

Sort of. My issue was running Ha in rpi3b and it was getting tight on memory, so I wanted to off load Tasmota Admin and make my own basic dashboard to monitor Tasmota devices. ( swap file was being used a lot) I ended up with using info button. After you click info, double click displayed ip address to select it, and right click to open in browser. A bit convoluted but didn’t use this feature too often. More used / needed was a way to restart mqtt device. I then used a long press to do mqtt restart. Not sure if this will help you, but here’s my card code, and sensor_mq_cnt_yaml

## lovelace code
entity: sensor.mq_cnt_tuyad5
hold_action:
  action: call-service
  confirmation:
    text: tuyad5 restart ?
  service: mqtt.publish
  service_data:
    payload: 1
    topic: tuyad5/cmnd/restart
label: |
  [[[
    var mq = states['sensor.tuyad5_status'].attributes.MqttCount;
    return 'mqtt: ' + (mq ? mq : '0') ;
  ]]]
name: tuyad5
show_label: true
state:
  - icon: 'mdi:wifi'
    operator: default
    styles:
      icon:
        - color: |
            [[[
              if (states['sensor.tuyad5_status'].attributes.MqttCount < Math.round(states['input_number.mqtt_threshold'].state) ) return 'green';
              else return 'red';
            ]]]
          opacity: 0.5
tap_action:
  action: more-info
  entity: sensor.tuyad5_status
type: 'custom:button-card'
############## mq_cnt.yaml
  - platform: mqtt
    name: "mq_cnt_tuyad5"
    icon: mdi:web
    state_topic: "tuyad5/tele/HASS_STATE"
    value_template: "{{ value_json.MqttCount }}"