This was embarrising. I just multiplied the time with 1000000 and now it worked.
rule "Spotpriser"
when
Item testSwitch received update
then
var rows = 0
var i = 0
while((i=i+1) < 25) {
//get the spot price
val spotPrice = transform("JSONPATH", "$.data.Rows[" + rows +"].Columns[2].Value",sendHttpGetRequest("https://www.nordpoolgroup.com/api/marketdata/page/29?currency=SEK"))
//get the start time for the spot price
val String startTime = transform("JSONPATH", "$.data.Rows[" + rows +"].StartTime",sendHttpGetRequest("https://www.nordpoolgroup.com/api/marketdata/page/29?currency=SEK"))
//replace the comma (,) with dot (.) before sending to influx
val spotPriceDot = transform("JS", "dotComma.js", spotPrice)
//transform the timestamp (string) to Java LocalDateTime then add timezone to get ZonedDateTime and finally to Epoch millis
val startTimeEpoch = ((LocalDateTime.parse(startTime)).atZone(ZoneId.systemDefault())).toInstant.toEpochMilli*1000000
//write the value to influxDB
val input = executeCommandLine(Duration.ofSeconds(5), "curl", "-i", "-XPOST", "http://localhost:8086/write?db=openhab_db", "--data-binary", "NordPoolSpotPrice,item=NordPoolSpotPrice value=" + spotPriceDot + " "+ startTimeEpoch)
logInfo(" Spot", "The spot price is " + spotPriceDot + " and the timestamp is " + startTime + ". In Epoch " + startTimeEpoch)
logInfo("Spot price", "The command result " + input)
rows = rows + 1
}
end