I’d like to implement simple control of IoT devices based on the electricity price data for the current and the next day. I am aware of alternatives such as HomeAssistant and various proprietary clouds of IoT device manufacturers.
Last year, I wrote a shell script that made use of the jshn library to parse JSON price data and to schedule the cheapest time slot for a warm water boiler. I implemented an improved version of the logic in an ESP-32 based Tasmota device (pull request). Now I would want to port this to LuCI.
I see that many of the graphs in the LuCI web interface for CPU usage, bandwidth, connections, and so on are based on data that will be read from files in the directory /var/lib/luci-bwc by a C program luci-bwc.
I’d want to present a graph similar to https://sahkotin.fi or https://dashboard.elering.ee/et/nps/price and some user interface for highlighting the time slots when power will be used, as well as setting some parameters for the price optimization.
For a ‘price database’ I could simply use a JSON file in the file system. Every 15 minutes, a Lua or shell script would be invoked to parse the file, to write it back with any past entries removed, and to initiate action when needed. For example, an action could be sending an HTTP GET request to turn on a heater. About once per day, the script would try to refresh the price data from an online data source. Part of the code would be interacting directly with the web browser, such as sending the data for drawing the price graph.
I’d be grateful for any pointers, such as LuCI extensions that try to achieve anything similar.