#I m getting some errors using an then

1 messages · Page 1 of 1 (latest)

zinc trench
#
2023-01-02 18:00:00.023 ERROR (MainThread) [homeassistant.components.automation.sprinker_water_control] Sprinkler Water Control: Error executing script. Error for choose at pos 1: Error rendering service name template: TypeError: '>' not supported between instances of 'str' and 'int'
2023-01-02 18:00:00.029 ERROR (MainThread) [homeassistant.components.automation.sprinker_water_control] Error while executing automation automation.sprinker_water_control: Error rendering service name template: TypeError: '>' not supported between instances of 'str' and 'int'```
#

Here is the code

#
description: Provides updated data to sprinkler controller
trigger:
  - platform: time
    at: "18:00:00"
    id: calc_rain_delay
condition: []
action:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id: calc_rain_delay
        sequence:
          - if:
              - condition: numeric_state
                entity_id: input_number.sprinkler_rain_delay_days
                above: 0
            then:
              - service: input_number.decrement
                entity_id: input_number.sprinkler_rain_delay_days
          - service: |
              {% if states('input_number.sprinkler_rain_delay_days') | int > 0 %}
                switch.turn_on
              {% else %}
                switch.turn_off
              {% endif %}
            entity_id: switch.automatic_watering_enable_switch
mode: single```
#

The problem is in the if-then block. Any ideas?

crimson ravine
#

Yes, your input_number entity has a state that cannot be interpreted as a number somehow, and you didn't provide a default for int

zinc trench
#

How do you provide the default. I did that for the jinja below the error

crimson ravine
#

I also suggest using >- instead of | to introduce the template

zinc trench
#

I