Hello, first time poster here. I have just started using HA and am having some trouble getting my head around the language and how to do things.
I have set up HA on a RPi to take reading from my heat pump. The heat pump I have hacked the configurations.yaml file to read the voltage and the current and multiplied these together to get the power the unit is consuming. I then plot this onto a graph. The yaml code is this…
sensor:
- platform: template
sensors:
...some code here not shown...
espaltherma_power:
friendly_name: "Power consumption"
value_template: "{{ state_attr('sensor.althermasensors','Voltage (N-phase) (V)') * state_attr('sensor.althermasensors','INV primary current (A)') * 0.001}}"
unit_of_measurement: 'kW'
and an example of the graph it produces is shown here - so far so good:
I thought it would be more useful to see how much power I had used in the last hour and maybe the last 24 hours, but i can’t figure out how to do it and everything i try seems to result in garbage readings. Mathematically i want to integrate it over time, so i used the integration add-in (Integration - Riemann sum integral - Home Assistant) but this doesn’t reset and just gives a number that seems too high.
I also tried to use a global variable (well that is what I would call it in C++) where everytime the power was read I added the current reading to previous ones - but I couldn’t get that to compile?
Can anyone help me?