How to simulate sensor / import its historical data?

I have recently installed PV and do not have ernergy consumption meter - in result I have no info about energ usage.

In fact I dont need precise info how much I consumed specific day / hour - Im more interested total ballance (what amount of energy was produced / consumed) - to see potential savings.

My idea then is to simulate energy taken from Grid by manual reading energy consumption from energy meter’s LCD and import that to HA

I can easly calculate day/hr average usage based on previous coinsumpton and prepare eg CSV with data series.
Then I’d like to store that in HA DB, so this data can be then displayed as regular (energy meter) sensor, resulting below charts / stats showing reasonable info

Can someone pleeeese advise how to start / best approach ?

  1. Create an input_number to actually enter manually your spot consumption (I assume what is displayed is total , ever increasing, kw/h), e.g. input_number.the_conso
  2. Create a template sensor like
template:
    sensor:
      - name: "Energy Consumption"
        state: '{{ states("input_number.the_conso")|float }}'
        unit_of_measurement: "kWh"
        device_class: energy 
        state_class: total_increasing
  1. Use sensor.energy_consumption in the energy dashboard

There is no way to inject “historical” data in HA

Thank you I’ll give a try

There is no way to inject “historical” data in HA

So how HA get this historical data. it must be somwhere kept…
Do you mean there is no interface to import such data ?
If so I can connect directly to Database using SQL and do that manually

Yes, no API or anything.

I guess. You’d have to inject into the statistics table and keep relational integrity, but theoritically feasible.

1 Like

@koying did You manage to insert the historical data? I’m searching for exactly the same

me too :wink: