Send sensor data via SMS on esphome

Hi, i want to send sensor data via sms on demand from an esphome node. The sms config works fine but i don´t get the sensor data inside the message. This ist the part of the yaml:

sim800l:
  on_sms_received:
    then:
      - sim800l.send_sms:
          recipient: 'myphonenumber'
          message: "{{ states('sensor.lte_rssi') }}"

Inside the template preview in the developer section this works as intended and shows the sensor data. But on the esphome node the sms just got the template code as plain text and not the sensor data itself.

Thanks in advance,
hellfish

I´ve made a bit progress on this one. I can send a bare sensor value via SMS now:

          message: !lambda |-
            return esphome::to_string(id(signal_strength).state);

The problem was that i´ve tried to insert a floating value instead of a string.

Can someone help me to get a better format for the sms? I don´t know how to get some text in front of the value and how i get more than one value inside one sms.

Thanks!
hellfish

Did it myself. So if anyone is interested you have to build the string like this:

message: !lambda 'return "The time is " + id(hatime).now().strftime("%H:%M") + " The IP is " + esphome::to_string(id(IP).state) + " ESPHOME ROCKS!";'