Possible to add manual data to an entity which has no data on certain dates?

Was wondering if it’s possible to add missing data to a energy entity with mariadb database?

For example, the entity has become unknown from the 2nd till the 4th and in the database there are no data to edit for those dates. Would like to manually populate/add data on those dates if it’s possible.

If you know how to work with SQL you can certainly insert records.

was doing some research on how to get this done but didn’t find many solutions on others doing smth similar. I have taken a look at the database with phpMyAdmin and the problem I’m facing is how to add a record properly.

I can see that the states would keep incrementing and increasing the state_id, I don’t think I’m able to put in any number since it goes up in order. Was wondering how could i use the right state_id, and how the context_id work

State Id is the identity column and will be auto assigned by the database when you insert a record. In other words you don’t provide it in your insert statement.

1 Like

so when inserting a record, if I were to only insert the values for the entity_id, state and last_updated, would that work?

For example:

INSERT INTO states (entity_id, state, last_updated)
VALUES ('sensor.main_energy', '4567.1', '2023-01-26 12:49:17.575202');

Have tried this and it added the missing records into the entity, which looks like it works. Not too sure if it has or would cause any other issues in the database

I edit stuff when I need to remove bad sensor values, etc. No problems.

But one area I don’t know and/or use are the statistics. I do not know if these changes or new records get picked up by statistics and/or if there is something that needs to be manually triggered to cause it to recalculate.

I have tried the code above and it has added it into the statistics which seems to work

1 Like