New sensor not available

Hello,
i am creating in the configuration.yaml a new sensor value but it is not available.
What i am doing wrong here?

thank you!
BR Mario

  - trigger:
      - platform: time_pattern
        minutes: "/1"
    sensor:
      name: "Temp x COP"
      unique_id: "temp_x_cop"
      unit_of_measurement: "ct/kWh"
      state: >
        {{  13 / (state_attr('E3_Vitocal', 'sensor.e3_tcu10_x07_aussentemperatur') | float + 51.111) | round(0) }}

state_attr needs the id of the sensor first, and the name of the attribute after that. Try the template in developer tools first to see if it works, then create the sensor.

This one is working but not state_attr. What is the reason for it?

 - trigger:
      - platform: time_pattern
        minutes: "/1"
    sensor:
      name: "Temp x COP"
      unique_id: "temp_x_cop"
      unit_of_measurement: "ct/kWh"
      state: >
        {{  13 / (states('sensor.e3_tcu10_x07_aussentemperatur', 'E3_Vitocal Außentemperatur') | float + 51.111) | round(0) }}

What does the template editor tell you?

i got this error:

ValueError: Template error: float got invalid input ‘None’ when rendering template ‘- trigger: - platform: time_pattern minutes: “/1” sensor: name: “Temp x COP” unique_id: “temp_x_cop” unit_of_measurement: “ct/kWh” state: > {{ 13 / (state_attr(‘sensor.e3_tcu10_x07_aussentemperatur’, ‘E3_Vitocal Außentemperatur’) | float + 51.111) | round(0) }}’ but no default was specified

Actually this is a clear error. Attributes do not have spaces in their name. Put the correct attribute in first. Then see if there is still a problem.

Hi, I advise you to test new code snippets in the “developer tools” > “template” before you add code to your configuration.yaml. In a bad case you can crush your system and unable it to reboot. This will appear on the next reboot for an addons or module of HA.

If everything works you will also get some example values for your variables, so you can check if your sensor works as expected.

Also you need to test your template one step at a time. eg test this first

{{ states('sensor.e3_tcu10_x07_aussentemperatur', 'E3_Vitocal Außentemperatur')}}

Obviously it’s not going to work, as I said in my last post. Once you do have it working, put the next bit in.