Logging Non Associated-HA data to a database (Plants)

Since HA is a computer and it processes and stores data, why not use it to store other information?

Yes - HA is a state machine with a short term memory, and the prime function is to respond to state changes, update the state model, and run automations, so anything else should avoid excessive use of CPU time and memory space.

That said, I believe that there could be an argument for augmenting the HA data with manually input information, and for long term data store for later use.

I am running a project to capture long term data from my solar PV system, specifically so that I can perform retrospective modelling on various energy tariffs and inverter control models.

I clearly do not want to mess up my HA, so I first experimented with my stand alone Raspberry Pi running Node-RED, and installed SQLite, capturing data from my HA. It worked, but I have moved to using MariaDB. To be ultra safe I purchased a new Odroid HA just to run Node-RED with MariaDB. My main HA runs a Node-RED flow each hour to push data to context, and once a day the full array goes to a sensor attribute which my second HA picks up and pushes to the database as hourly records.

I use MariaDB as an addon, and this is alongside and not in replacement of SQLite which HA uses. I store data as serialised JSON strings, so it is easy to change schema and repair existing data. It was easy to set up, is quicker than SQLite on my Pi, and seems compact. Also as I have installed phpMyAdmin, MariaDB can be accessed from the sidebar, and as it is a server SQL engine, I can access it from my desk PC. It works easily with Node-RED.

I capture solar performance, load and battery power status, as well as inverter settings, solar forecast, and weather forecast. I also capture my energy tariff and meter readings and other agile tariff half hourly figures.

I now have almost 180 days worth of data so far (less than 6 MiB storage) and plan to cross-analyse things like weather forecast with solar forecast to actual PV. Nothing quite like hindsight. Then tariff modelling, and inverter control testing. Maybe heuristic modelling control too?

At the moment I only collect HA entity values, but there is no reason why I could not add notes or manually collected data, such as when taking part in energy saving sessions, or if I have used the oven or done laundry. Indeed, our laundry activity, being an electric washing machine and drier, is prompted by sunny weather. So why not capture this ‘activity / action / intent’ manually in the same long term database?

Getting stuff back out of my private database and into HA with Node-RED and JSONata is easy, and I probably could also use the HA SQL integration. I only use Node-RED to both write and read, but I found a custom integration for writing using an HA notification (I have not tested this).

https://community.home-assistant.io/t/mysql-command/539839

My route was to install the MariaDB addon, and the phpMyAdmin, which I used to create a database and table, and then I used Node-RED MySQL node to write and read records. I can edit the database directly using phpMyAdmin from HA, so manual updates could be as simple as just using this tool.

Clearly not the ‘use case’ but then why not?