Replace energy dashboard sensor with template sensor


I am using the energy dashboard for quite a while and it tracks the energy produced by my SMA PV inverter that I interface via the sbfspot tool over bluetooth (my inverter only has a BT interface). The sensor data arrives via MQTT in HomeAssistant. I use the total energy produced in kWh reading as input to the dashboard.

This has been working OK as the readings from the inverter were ever increasing.

Due to an issue with the inverter I had to send it in for repair. The inverter is repaired OK but while it was serviced the firmware was updated. This results in a small change in behaviour: as soon as the inverter goes off-grid it now reports the total energy counter as ‘0’. This causes a jump in produced energy that amounts to the total energy that is produced daily when the inverter gets back on the grid. The reading then changes from 0 to 48 MWh > this pollutes the energy dashboard.

No problem, I created a template sensor that takes the MQTT input and reports the sensor as ‘unavailable’ when the reading is ‘0’.

My question: how can I add this new sensor to the energy dashboard? If I remove the old sensor then the historic data from that sensor is removed from the dashboard. If I just add the template sensor then the readings are added twice to the dashboard, plus the jump at the start of the day remains.

Is the correct way to proceed to change the configuration of the original sensor to a new name, and then update the template sensor so it has the name of the old sensor? Will this work? I would rather not loose 2 years worth of energy dashboard information :slight_smile:


That’s what I would say. Using the old name for the new entity will ensure you see all the data. HA won’t know the difference.

Thank you for the fast response Pieter, I’ll test it out tomorrow when the sensor is producing data again and report back!

The suggested approach works as expected, thanks @parautenbach.

1 Like