Hey, would it be possible for you experts to help me out?
Thanks for your advice!
I was trying to calculate the daily cost of my gas consumption based on a yearly fixed cost + tariff/kwh.
However, when adding the “gas price” sensor to my config, I get below error.
Invalid config for [template]: invalid template (TemplateSyntaxError: unexpected '}') for dictionary value @ data['sensor'][12]['state']. Got "{% set a = states('sensor.daily_gas') | float %} {% set b = states('input_number.all_in_tarief_gas') | float %} {% set c = states('input_number.vaste_kosten_gas') | float / 365 %} {{ ((a * b) + c) | round(2) }\n". (See /config/configuration.yaml, line 143).
Here’s the config:
utility meter:
daily_gas:
source: sensor.gas_consumed_belgium
cycle: daily
input_number:
all_in_tarief_gas:
name: All-in tarief Gas
initial: 0.974
min: 0.000
max: 0.999
mode: box
step: 0.001
unit_of_measurement: 'EUR per m3'
vaste_kosten_gas:
name: Vaste Kosten Gas
initial: 117.34
min: 0.00
max: 200.00
mode: box
step: 0.01
unit_of_measurement: 'EUR per jaar'
template:
- sensor:
- name: "Today Gas Price"
unit_of_measurement: 'EUR'
state: >
{% set a = states('sensor.daily_gas') | float %}
{% set b = states('input_number.all_in_tarief_gas') | float %}
{% set c = states('input_number.vaste_kosten_gas') | float / 365 %}
{{ ((a * b) + c) | round(2) }