Hi
I’ve got a energy usage sensor in W that is transformed into kWh using integration as follows:
- platform: integration
source: sensor.grid_consumed_power
name: grid_consumed_power_integration
unit_time: h
unit_prefix: k
method: left
round: 2
On the other hand, the result is used in a template so to have its hourly cost (pvpc is an official integration with hourly energy prices):
- platform: template
sensors:
coste_energia_porhour:
friendly_name: "Gasto en energía por hora"
unit_of_measurement: '€'
value_template: "{%if states.sensor.pvpc.state %}{{ ((states.sensor.grid_consumed_power_integration.state | float) * (states.sensor.pvpc.state | float)) | round(5) }}{% else %}unknown{% endif %}"
entity_id:
- sensor.grid_consumed_power_integration
- sensor.pvpc
Template seems to work fine but on some rate changes (in the one at 13h in the picture), template shows a jump that does not make sense:
Is there something I’m missing in the template definition ?
Thanks