Hi,
I am running an ESP32 with 4 pulse kwh meters (Grid Import, Solar Export, House Usage and Solar Generation). All meters are 1000/pulses per kWh except Solar Export which is 1600. I realise that HA doesn’t need data from my House Usage sensor
I have these set up and working well with PVoutput and sql and other data formats. I have just started to play around with getting the data into Home Assistant Energy Dashboard.
As PVoutput takes data in 5 minute intervals I was planning to do the same cycle time and sending the data to HA Energy via MQTT. I have this seemingly working as data is coming through to HA Energy but my data seems off. Also to clarify the values I am sending just relate to the last 5 minutes (ie. not hourly or daily totals etc.).
Firstly the data I am sending to PVoutput is basically just the number of measured watt hours (for 3 of the meters that is just the number of pulses) and times by 12 (as there is 12 x 5 minutes in an hour.
I have my config file configured as follows (have all 4 sensors but only showing 1 here
mqtt:
sensor:
- name: "SolarGeneration kwh"
state_topic: "PowerESP32/SolarGeneration"
value_template: "{{ value | float(0) / 12 }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total #measurement
force_update: true
With my config above I have a couple of queries
- Does my value template look right. In essence the incoming value received via MQTT is the average WattHour value over that 5 minute period. My value template should be converting that back to Wh by dividing it by 12. I am assuming I am accounting for everything right here
- Guides I had seen indicated having state_class as “measurement” but when I have it as this it fails and indicates it wants me to use a last_reset variable also
More generally do I also need to let HA know anywhere that I am sending data in 5 minute increments.
The reason I find my data looks wrong is it appears to kind of graph correctly in the History Tab but in the energy tab it shows data in 24 bars but it ranges between 0.25 and -0.25kWh (for context my usage for that period in PVoutput is 22.6kWh (minus solar 4.8kWh).
Any tips and clarification would be appreciated. Thanks.