[SOLVED] Why does this template value return zero?

Hi, any idea why this returns zero (0)? I had it working before. Both entities return correct values. I am not a dev and can’t write Jinja well - I don’t see the error… Thanks!

  platform: template
    sensors:
      czk_price_per_kwh:
        friendly_name: "Current Electricity Price"
        value_template: >-
          {% set CURRENT_PRICE = states("sensor.current_ote_energy_cost") | float(0) %}
          {% set EUR_CZK = states("sensor.exchange_rate") | float(0) %}
          {{- (CURRENT_PRICE * EUR_CZK / 1000) | round(3) -}}
        unit_of_measurement: "CZK/kWh"

Have you stepped through it in the dev tools?

What do these return in the developer tools:

{% set CURRENT_PRICE = states("sensor.current_ote_energy_cost") | float(0) %}
{% set EUR_CZK = states("sensor.exchange_rate") | float(0) %}


CURRENT_PRICE: {{ CURRENT_PRICE }}
EUR_CZK: {{ EUR_CZK }}

COMP: {{- (CURRENT_PRICE * EUR_CZK / 1000) | round(3) -}}

statecost: {{states("sensor.current_ote_energy_cost")}}
stateexch: {{states("sensor.exchange_rate")}}

I’m very sorry, the error is in the sensor.exchange_rate_sensor entity. It was missing _sensor at the end.

Case closed, sorry for wasting your time :slight_smile:

I updated the templates so we can see which is which. But I do see an ‘unknown’ which would be a problem most likely. Can you do that again?

haha. What was the issue? and you should mark the thread solved if it is.

The entity was sensor.exchange_rate_sensor, not sensor.exchange_rate 🤦

Marking as solved.

1 Like