Haystack Lua - Enabling interop with existing CLI tools

Projects
haystack
lua
skyspark
visualisation
AWK/GAWK like interop with linux utilities like gnuplot.
Author

Christopher Andronikos

Published

July 30, 2025

Modified

July 30, 2025

gnuplot example found here
Important

Note: This project is actively being developed, and users may encounter breaking changes when using it in libraries or automation scripts and upgrading between versions. Because of this, please ensure you thoroughly test your workflows when adopting new versions of this tool until the project stabilizes.

If you have any feedback or suggestions for improvement, feel free to raise an issue on Github .

Overview

The Haystack Lua project (See readme.md for more info) builds on the work done in haystack-rust by providing lua bindings that enable seamless integration with typical CLI workflows.

This library lends itself to reading manipulating zinc data in workflows similar to that used with AWK or GAWK. Detailed examples of this can be found here.

Basic Usage

local hs = require('haystack')

-- Parse a simple Zinc grid
local zinc_data = [[
ver:"3.0"
id,dis
@p:demo,"Demo Site"
]]

local grid = hs.io.parse.zinc.grid(zinc_data)
print("Parsed", #grid, "rows")
print("First site:", grid:first().dis)

Advanced Usage

The gnu plot visualisation example here leverages interop with the haystack-client with the below to produce the image used at the start this post:

  (
    export HAYSTACK_AUTH_CONFIG=`hs default auth`;
    
    POINTS="$(haystack-client read --filter "point and (power or energy) and equipRef->siteMeter")"
    POINT_IDS="$(echo "$POINTS" | lua haystack_to_rec_ids.lua)"
    HIS="$(haystack-client hisRead 2025-01-01,2025-01-07 ${POINT_IDS} |
      lua plot_history.lua <(echo "$POINTS"))"
    gnuplot -psc <(echo "$HIS")
  )

Conclusion

This project is actively being developed, and support will continue to improve over time. You may download or build the source code, via the repository link below.

Github Repository

Citation

BibTeX citation:
@online{andronikos2025,
  author = {Andronikos, Christopher},
  title = {Haystack {Lua} - {Enabling} Interop with Existing {CLI}
    Tools},
  date = {2025-07-30},
  url = {https://candronikos.com/projects/haystack-lua},
  langid = {en}
}
For attribution, please cite this work as:
Andronikos, Christopher. 2025. “Haystack Lua - Enabling Interop with Existing CLI Tools.” July 30, 2025. https://candronikos.com/projects/haystack-lua.