Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106494

Template error: float got invalid input when rendering template

$
0
0

Hello all,

I have following blueprint (minimum example):
The faulty/interesting part starts after the section variables.

blueprint:
  name: Outdoor Irrigation
  description: Automate outdoor irrigation based on soil moisture and sunlight.
  domain: automation
  input:
    target_soil_moisture_beet:
      name: Target Soil Moisture (Beet)
      description: The desired soil moisture level for the beet area.
      selector:
        number:
          min: 0
          max: 100
          step: 5
    percentage_per_min_beet:
      name: Percentage increase of soil moisture per minute for the beet area
      description: Number how much the soil moisture value in percentage increases after one minute of watering
      selector:
        number:
          min: 0
          max: 30
          step: 1
    moisture_sensor_beet:
      name: Moisture Sensor (Beet)
      description: The moisture sensor for the beet area.
      selector:
        entity:
          domain: sensor
    valve_beet:
      name: Valve Beet
      description: The valve for irrigaiton for the beet area
      selector:
        entity:
          domain: switch

variables:
  var_target_soil_moisture_beet: !input target_soil_moisture_beet
  var_moisture_sensor_beet: !input moisture_sensor_beet
  var_percentage_per_min_beet: !input percentage_per_min_beet

trigger:
  - platform: sun
    event: sunrise

action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: !input valve_beet
  - delay: >-
      {{ ((var_target_soil_moisture_beet | float(85)  -
      var_moisture_sensor_beet | float(75))  /
      var_percentage_per_min_beet | float(10)) * 60 }}
  - service: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: !input valve_beet
mode: single

The issue here is, that my moisture sensor delivers an invalid input and if I don’t specify a default value, I get following error:

Logger: homeassistant.components.automation.outdoo_irrigation_blueprint
Quelle: helpers/script.py:2002
Integration: Automatisierung (Dokumentation, Probleme)
Erstmals aufgetreten: 21:33:13 (5 Vorkommnisse)
Zuletzt protokolliert: 21:55:47

Outdoo Irrigation - Blueprint: If at step 2: Error rendering Outdoo Irrigation - Blueprint: If at step 2 delay template: ValueError: Template error: float got invalid input 'sensor.tuya_feuchtigkeitssensor_soil_moisture' when rendering template '{{ ((var_target_soil_moisture_beet | float - var_moisture_sensor_beet | float) / var_percentage_per_min_beet | float) * 60 }}' but no default was specified

With a specified default value, the default value will always be used.

If I test the template in the development tools, I get a valid result:

delay: >-
  {{ ((states( 'input_number.target_soil_moisture_beet' ) | float  - states(
  'sensor.tuya_feuchtigkeitssensor_soil_moisture' ) | float)  / states(
  'input_number.percentage_per_min_beet' ) | float) * 60 }}


Maybe it is an issue, that I receive the result of type “string”?

Last, but not least some informations about the entity:

I just want to calculate a delay, depending on the current soil moisture.

What I tried so far:

  1. I’m using variables in the template instead of “!input” method
  2. I added the prefix “var_” for a unique naming of the variables
  3. I specified default values, when parsing

Best regards!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106494

Trending Articles