Cannot solve error from template: Incorrect type. Expected "integer"

I get this error in my delay statement in the action below, and I cannot find the solution. Error occurs with or without | int

The template itself evaluates OK.

    action:
      - service: homeassistant.turn_on
        entity_id: switch.vanning_bryter
      - service: notify.adults
        data:
          title: Vanning startet
          message: 'NY_Vanning på terrassen startet kl. {{now().strftime("%H:%M")}}'
      - delay:
          seconds: "{{ states('sensor.smart_irrigation_daily_adjusted_run_time') | int }}"
      - service: homeassistant.turn_off
        entity_id: switch.vanning_bryter

What is the error message?

I wonder if this needs to be filtered to a str?

It’s in the header, @ronytomen; Incorrect type. Expected "integer"

See Rule 1:

You must use data_template in place of data when using templates in the data section of a service call.

While the data versus data_template, that shouldn’t be generating this error.

Agreed. @palengh: what does this show in Developer Tools / Template?

{{ states('sensor.smart_irrigation_daily_adjusted_run_time') }}

I managed to get rid of the error by parsing the delay string like this:

    - delay: "00:00:{{ states('sensor.smart_irrigation_daily_adjusted_run_time') | int }}"

… as opposed to

 - delay:
     seconds: "{{ states('sensor.smart_irrigation_daily_adjusted_run_time') | int }}"

2 Likes

I was just typing the two ways I have gotten this to work… The string method, you have shown, which I have used for a while now and the following:

 - delay: 
     seconds: > {{ states('sensor.smart_irrigation_daily_adjusted_run_time') | int }}

This is probably a bug and I forgot to come back to and track this down.

And returns “0”

Is that the expect value? :slight_smile:

Yes. it’s a fair number :slight_smile:

However; This causes the same error