How Do I Format Lambda for text_sensor - ESPHome Sprinkler

I’m running into issues trying to set up a text_sensor to display remaining seconds/minutes. I’ve tried several lambda configurations without luck. My latest code throws an error on compile;

Compiling /data/irrigation-valve-ctrl-unit-a/.pioenvs/irrigation-valve-ctrl-unit-a/src/main.cpp.o
/config/esphome/irrigation-valve-ctrl-unit-a.yaml: In lambda function:
/config/esphome/irrigation-valve-ctrl-unit-a.yaml:80:75: error: return-statement with a value, in function returning 'void' [-fpermissive]
   80 |           return id($devicename).time_remaining().value_or(0);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            ^  
*** [/data/irrigation-valve-ctrl-unit-a/.pioenvs/irrigation-valve-ctrl-unit-a/src/main.cpp.o] Error 1
========================== [FAILED] Took 7.75 seconds ==========================

Despite searching for a solution on Google, I’m unable to figure out what’s wrong.

The block of code where the trouble occurs reads;

  - platform: template
    name: Time Remaining
    icon: mdi:progress-clock
    on_value:
      then:
        lambda: |-
          return id($devicename).time_remaining().value_or(0);     

Any help in pointing me in the right direction would be appreciated.