Syntax problems with variables in packages

I want to change the update interval of a Modbus via a text sensor, but I don’t know how to transfer it.

text_sensor:
  - platform: template
    name: "Update Intervall schreiben"
    id: template_update

switch:
  - platform: template
    id: test04
    name: Testbrücken 
    optimistic: True  
    lambda: |-
      if (id(test04).state) {
        return true;
      } else {
        return false;
      }
    on_turn_on: 
      then:
        - text_sensor.template.publish:
            id: template_update
            state: "10s"
    on_turn_off: 
      then:
        - text_sensor.template.publish:
            id: template_update
            state: "10min"



packages:

  daten_w: !include 
     file: packages/sdm/growatt_n.yaml
     vars:
       sensor_id: daten_w
       sensor_name: in
       sensor_adresse: 0x0001 
       sensor_interval: 10s

It’s about the “sensor_interval” from the package. I would like to transfer the content of the text sensor there, but how?

Have you tried:

packages:

  daten_w: !include 
     file: packages/sdm/growatt_n.yaml
     vars:
       sensor_id: daten_w
       sensor_name: in
       sensor_adresse: 0x0001 
       sensor_interval: !lambda 'return id(template_update).state;'

Sorry for the late reply, but work…
I tried your suggestion, but it doesn’t work. I got the following error message:
“This option is not templatable!.”

Ah - bummer… I didn’t actually check that. :smiley: Sorry.

Why not store the result from id:template_update into a global variable?
Normally the !includes should have access to globals.

Yes, access should be possible, but there is no variable type called “time.” One option might be to use an int and add an “s” at the end using a string operation. However, I have now completely reworked my automation and no longer need to change the interval time. Therefore, I will not pursue this solution any further. Thank you for the tips; I’m sure they will come in handy in another context.