(solved) Template use input number

Can someone help me and explain what I forgot.


UndefinedError: ‘input_number’ is undefined

template:
  - sensor:
      - name: "Gas Verbrauch Buderus"
        unique_id: "gas_verbrauch_buderus"
        device_class: "gas"
        state_class: "total_increasing"
        unit_of_measurement: "m³"
        state: >
          {% set kwh = states('sensor.recording_ractualpower') | float %}
          {% set normdichte_value = input_number.gas_normdichte | float %}
          {% set mengengewichtet_value = input_number.gas_mengengewichtet | float %}
          {{ ( kwh/(normdichte_value * mengengewichtet_value) ) | round(1) }}

Picture shown my Input_number

If I put static value it works…

template:
  - sensor:
      - name: "Gas Verbrauch Buderus"
        unique_id: "gas_verbrauch_buderus"
        device_class: "gas"
        state_class: "total_increasing"
        unit_of_measurement: "m³"
        state: >
          {% set kwh = states('sensor.recording_ractualpower') | float %}          # kWh Sensor setzen
          {% set normdichte_value = 0.80314 | float %}                             # normdichte setzen
          {% set mengengewichtet_value = 11.5593 | float %}                        # mengengewichtet setzen
          {{ ( kwh/(normdichte_value * mengengewichtet_value) ) | round(1) }}      # (kwh / (Normdichte * mengengewichtet)) gerundet auf 0,1

compare these lines. Line 1 is correct. Line 2 is not. What’s the difference?

1 Like

You cannot use this directly, you need something like
states('input_number.gas_normdichte')

1 Like

Thanks so mutch I got it… tryed severl times…!!!

template:
  - sensor:
      - name: "Gas Verbrauch Buderus"
        unique_id: "gas_verbrauch_buderus"
        device_class: "gas"
        state_class: "total_increasing"
        unit_of_measurement: "m³"
        state: >
          {% set kwh = states('sensor.recording_ractualpower') | float %}
          {% set normdichte_value = states('input_number.gas_normdichte') | float %}
          {% set mengengewichtet_value = states('input_number.gas_mengengewichtet') | float %}
          {{ ( kwh/(normdichte_value * mengengewichtet_value) ) | round(1) }}