Data_template - spurious error

I am getting what appears to be spurious errors in my log.

This works perfectly well and gives result as expected:

  - service: input_number.set_value
    data_template:
      entity_id: input_number.rain_3days_ratio
      value: >
        {{ states.input_number.rain_3days_ratio.state | float / 12 }}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.rain_3days_ratio
      value: >
        {% if states.input_number.rain_3days_ratio.state | float > 1 %}
          1
        {% endif %}

And so does this (it is a different input_number but apart from that only the quotient changes from 12 to 25):

  - service: input_number.set_value
    data_template:
      entity_id: input_number.rain_5days_ratio
      value: >
        {{ states.input_number.rain_5days_ratio.state | float / 25 }}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.rain_5days_ratio
      value: >
        {% if states.input_number.rain_5days_ratio.state | float > 1 %}
          1
        {% endif %}

even though it works (and I am happy with the results) I am getting this error:


Log Details (ERROR)

Mon May 07 2018 10:25:01 GMT+0100 (GMT Summer Time)
Invalid service data for input_number.set_value: expected float for dictionary value @ data[‘value’]. Got ‘’


BUT it doesn’t give an error if I comment out only the second service in the second example, like this:

  - service: input_number.set_value
    data_template:
      entity_id: input_number.rain_5days_ratio
      value: >
        {{ states.input_number.rain_5days_ratio.state | float / 25 }}
  # - service: input_number.set_value
  #   data_template:
  #     entity_id: input_number.rain_5days_ratio
  #     value: >
  #       {% if states.input_number.rain_5days_ratio.state | float > 1 %}
  #         1
  #       {% endif %}

Any ideas anyone?

You don’t set a value if the if statement is false.

2 Likes

Do I need to? wouldn’t it just do nothing in that case?
I’ll try and see.

EDIT: yes, that was it, thanks.

1 Like