Is there any way to signal to HomeAssistant to (temporarily) hold off writing to the HA database?
I have a 3rd party app that writes to the SQL database and I want to avoid conflicts.
I know in general, it’s not a good idea to access HA db directly, but I need to batch insert historical states for my water meter and there doesn’t seem to be a REST API that allows one to “backdate” the time (last_updated_ts), so I do this manually with SQL.
I would like to avoid collisions with HA writing to the database.
Indeed, I noted that if I write to the HA db at the hour or 5 minute marks, that it can collide with statistics and prevent them from being written.
Ideally, it would be great if I could send a REST API that says “hold off from writing to db”, then I do my SQL db manipulation, then I send a message saying “resume writing to db”
Alternatively and conversely, it would also work if there were an API that would let me safely inject (arbitrary) SQL commands to HA db without collisions.
Of course, I could each time shutdown and then restart ha core
but that seems like overkill plus it even more likely results in missed recordings of states, statistics and missed automations etc.
BTW, I do backup the DB before writing to it “just in case” but that’s only a minimal solution to protect me in case DB gets corrupted
Any suggestions?