PiBrewing / craftbeerpi4

GNU General Public License v3.0
57 stars 29 forks source link

Start and stop sensor logging on dashboard #113

Open Tampzarian opened 1 year ago

Tampzarian commented 1 year ago

At the moment you can log data only continously for all sensors in a rotating CSV file or in an Influxdb. To create sensor logs for later review and control it would be nice to a widget on the dashboard to start and stop recording each sensor individually, choose a meaningful name (i.e. the name of the recipe, the sensor and a time stamp) and set the interval at which the data is logged. With the collected data you can review the process later on and make adjustments on the system later on or adjust/develop you recipes. This is useful for both temperatures of mashing and fermentation and gravity readings during fermentation. This could also be connected to a live graph on the dash board (avoiding the graph having to read the complete log like it is set up now) and also possible to load files in the Analysis tab. My programming skills are very basic, but maybe the SensorLogTarget_CSV extension already contains the basic functionality to realize this function. I'd be willing to help, but as said, I'm just a beginner programmer.

avollkopf commented 1 year ago

Not straightforward, but could be theoretically realized with a plugin via the new [logging capability] (https://github.com/PiBrewing/craftbeerpi4/commit/f01bdb94bde622d07bcca788ca18699688e6538a) via plugin implemented by @prash3r.

Will for sure require some time if it can be done.

avollkopf commented 1 year ago

For now, export from InfluxDB/Grafana Dashboard to Excel works pretty well -> Fermentation image

prash3r commented 1 year ago

Hi @Tampzarian , individually starting and stopping single sensors logging is currently not implemented, changing the logging interval (in general or individually) is currently impossible and it would be hard to implement without changing the current plugin api because the sensor logic themselves (the sensor plugins) call the log_data() and push_update() that are responsible for writing the data to the logfiles or sending a new value update to the connected clients respectively.

I am aiming to make it possible and to manually be able to change logging intervals for each sensor but for this to happen we need big changes and i dont see it coming soon. if #59 is realized maybe one day then i would love to add the logging interval and maybe add a data logging check mark to the hardware config of each sensor.

At this point it could be created as a plugin which would writer to a seperate log folder relatively simple. At least storing the data would be very easy with the new logging capability i added recently. Controlling the logfile behaviour (delete, pause, start, interval) from UI would be more work but also possible. And having a completely new plotting functionality for dashboard would be heavy plugin work i am not familiar with at all.

I can just recommend you setup an InfluxDB logging target because over there you can do all the fancy stuff with your data including the InfluxDB/Grafana Dashboard to Excel export mentioned by @avollkopf . and then probably some stuff like the Grafana plots in cbpi4 ui but i dont know i am not using them myself.

But even without Influx or Grafana you can still delete all the logs beforehand and after your process you can download all logs. You can prepare you plotting in an Excel file and import all the csv logs in seperate worksheets where you already set up the plotting. The data is all there.

I would note this down as: For being core functionality it requires the completion of #59 which may never come because it changes the plugin api.

avollkopf commented 1 year ago

Most sensors of the latest version have the ability to define a log frequency for brewing / fermenting.

-> assign a kettle or fermenter to your sensor and define the logging frequency if the kettle / fermenter is not active (no active logic). -> reduced frequency '0' is equal to no logging if the kettle or fermenter logic is not active.