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"
calisro
(Rob)
August 30, 2022, 2:18pm
2
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
calisro
(Rob)
August 30, 2022, 2:22pm
4
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?
calisro
(Rob)
August 30, 2022, 2:24pm
5
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