Pellet boiler sums up its pellet consumption over time, have this persisted as an item in Postgresql, so the data might be 3775, 3791, 3810 (kg). But I do not have the daily increase, I’d like to have an item with the daily delta for the Analyze view. So, I thought I might try to create an SQL view and put it under an item.
The openHAB persistence creates a table for each persisted item, the table name is item_idx with idx the index in the items table.
jdbc.conf:
tableUseRealItemNames=true
tableIdDigitCount=0
INSERT INTO items (itemname) VALUES (‘boilerdailykg’);
This got at index 17, so I created a view
create view boilerdailykg_17 as select time, value - LAG(value) OVER(ORDER BY time) as value from boilertotalkg;
The view uses the LAG positional function.
dbview.items: Number boilerdailykg
jdbc.persist:
boilerdailykg : strategy = restoreOnStartup
restarted openhab, had to switch to month in the Gui Analyze view of the item, and the data line appeared.