Hello,
I really like the new functionality in 4.1 with forecast values. I wanted to take advantage of it and display a graph of energy prices in the future. I use the Energi Data Service binding which supports future values, and wanted to combine/sum the channel values into a new item.
I found several ways to read the forecasted values in a script but I lack a way of writing a value with a timestamp to an item.
How do I write a future value to an item?
Example code for getting timeseries data:
var logger = log("timeseries");
var fromdate = new Date();
fromdate.setHours(fromdate.getHours()-3);
var toDate = new Date();
toDate.setHours(toDate.getHours()+6);
var itemWithForecast = items.getItem('Energi_Data_Service_Spot_Price');
var entries = itemWithForecast.history.getAllStatesBetween(fromdate, toDate, "influxdb");
//var entries = itemWithForecast.history.getAllStatesSince(fromdate, "influxdb");
var entry = itemWithForecast.history.historicState(toDate, "influxdb");
for(var i = 0; i < entries.length; i++)
{
logger.info(entries[i].state);
}