#Sensor, which shows the value of another but adds a specific value

1 messages · Page 1 of 1 (latest)

kindred tinsel
#

Hey folks,

to migrate my old energy sensor properly, I want to build a helper sensor, which shows the current value of my sensor but add "889.24" to it.
For that I build a template sensor and added it to the configuration.yml:

    - sensor:
        - name: "Migrated Shelly-Wechselrichter Eingespeister Strom"
          unique_id: wechselrichter_einspeisung_with_history
          device_class: energy
          state_class: total_increasing
          unit_of_measurement: "kWh"
          value_template: "{{ states('sensor.wechselrichter_einspeisung') | float + 889.24 }}"

But sadly the sensor does not appear in HA after restarting the system.
Can somebody help me with that issue?

T

tiny tusk
river patrol
#

that will not copy over the statistics data

#

the right way is to:

  • delete the old entity
  • add new entity
  • rename new entity_id to the old entity_id
kindred tinsel
#

Okay, just changing "value_template" to "state" worked for me. I changed the meta_id in statistics sql table and now I have the history and a new device.
Energy board looks well too

river patrol
#

That was not necessary

#

All you had to do was change the name 😅

kindred tinsel
#

Hm. My solution does not work:

#

Maybe I try it without the helper template sensor. But the problem then is that the historic values are accurate, but the new values not . And I get a difference then…

#

I think the same problem would occur if I rename the new sensor to the name/id of the old one ?

#

You see it here:

#

Hmm but I think it would only the current day, because there are partially values of the old sensor and the new sensor. Maybe I could only delete the todays values from the table and it could work again !?

river patrol
#

If you rename the sensor everything will transfer

kindred tinsel
#

Are you sure? Because the new values will be start at 0 ?

#

Okay, I did it. It is strange. because the graph shows the correct value, but the state is 0.45:

river patrol
#

State can reset independently from the statistics

#

Energy dashboard only needs the cumulative sum