-
Notifications
You must be signed in to change notification settings - Fork 22
datawalls
Define a composite “infographic” that combines text, images, raw data, and graphs into a single output (typically one image) to display on a screen or webpage.
There are two key elements to a datawall, the 'preset' and 'module' the preset loads all the required data into a package then hands it to the module, these two tasks are handled separately rather having the module itself request the information to allow situations where small changes in the data sources are made (for example switching from a bme sensor to an si71 for temperature readings) or where multiple options for the same layout are required (switching between displaying the prior week or months data for example).
Datawall presets are simple text files (located in the ./datawall_presets/ folder) that allow you to mix several types of content into one cohesive output. In a datawall preset, each line defines an action. For example, a typical preset file might contain:
info_read = sensor_status picture_path = plant_image graph_preset = 1weektemp log_preset = temp_bme
Each option is interpreted as follows:
info_read:
Tells Pigrow to run a designated info module. This module queries a remote Raspberry Pi for a block of text (such as sensor status or system information) and returns it. The returned text is stored under the “info” key in the data package.
picture_path:
Tells Pigrow to load an image. The system checks whether the requested image is already available locally; if not, it downloads the image from the remote source. The local file path is then stored under the “images” key in the data package.
graph_preset:
Tells Pigrow to load a graph preset by name, generate the corresponding graph image, and then store the image’s file path under the “graphs” key in the data package.
log_preset:
Tells Pigrow to load the dataset(s) defined in a graph preset (from the corresponding JSON file) without creating a graph. This allows you to use the raw data later (for example, to display tabular data or perform further analysis). The dataset is stored under the “data” key in the data package.
Once a datawall preset is loaded, Pigrow builds a data package that is passed on to a datawall module. A datawall module is a Python script that receives the data package and generates a composite “datawall” image (or output file). The data package is a dictionary with the following keys:
info:
Contains text strings returned by various info modules. For each info module requested (via an info_read line), there is an entry in this dictionary.
images:
Contains file paths to images that were loaded or downloaded (via a picture_path line). These images can be embedded in the final datawall.
data:
Contains the raw datasets loaded from logs. When you use a log_preset option, Pigrow loads the dataset(s) from the corresponding graph preset JSON file and packages them as a list of dataset dictionaries. Each dataset dictionary includes the key name, trimming mode, start/end times (if applicable), and the actual data points.
graphs:
Contains file paths to graph images generated from a graph preset (via the graph_preset line). Each graph image shows processed data according to the graph preset options.
A typical data package might look like this (represented in JSON-like format):
{ "info": { "sensor_status": "All sensors operating normally. Battery level: 92%." }, "images": { "plant_image": "/local/path/to/plant_image.jpg" }, "data": { "temp_bme": [ { "key": "temp_bme", "trim_mode": "none", "start_datetime": "2024-01-01T00:00:00", "end_datetime": "2024-01-31T23:59:59", "data": [ ["2024-01-01T00:00:00", 21.5], ["2024-01-01T01:00:00", 21.3], ... ] } ] }, "graphs": { "1weektemp": "/local/path/to/graph_1weektemp_graph.png" } }
This complete package is handed to your datawall module, which then uses the provided text, images, data, and graphs to produce a single, unified datawall image. The module simply returns the file path of the final image. Creating Your Own Datawall Module
If you’re looking to create your own datawall module your module will receive a data package with the keys described above. You can access:
Info text to display as status or commentary,
Images for visual content,
Raw datasets if you want to create custom charts or tables,
Graph images that have already been generated.
Your module’s task is to take these components and assemble them into a single visual output. Typically, your module will perform some layout calculations and then output a composite image file. Once created, your module simply returns the path to this final image.