I’m now able to manually write data to influxdb:
https://community.openhab.org/t/rest-api-persistence-service-not-modifiable-influxdb/70710/16
https://community.openhab.org/t/solved-openhab-2-and-executecommandline-exec/21558/39
Next step would be to automate the whole process.
This rule works:
rule "Write NordPool energy prices to Influxdb"
when
Item Renew_price changed
then
val results = executeCommandLine("curl@@-i@@-XPOST@@http://192.168.50.30:8086/write?db=openhab_db@@--data-binary@@NP_Electricity_price_test value=919 1435362189575692180@@",5000)
logInfo("NPpriceDB.rules",results)
end
I need to cycle through all the value and time pairs:
executeCommandLine("curl@@-i@@-XPOST@@http://192.168.50.30:8086/write?db=openhab_db@@--data-binary@@NP_Electricity_price_test value=[price of the hour].state [fixed time of the day in Epoch format]@@",5000)
Do I understand correctly that “value=[price of the hour].state” part is simply value=NP_Electricity_price_today_00_01_num.state?
How is time conversion made ?
There is a nice example here:
https://community.openhab.org/t/datetime-conversion/54266
Number MyEpochFromDateTimeTypeItem_VariantA = (MyDateTimeTypeItem.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
But I can’t use dynamical time “now” as my “time brackets” are fixed.
Is there a way to do something like this: “today.plusminutes(0)”,“today.plusminutes(60)”,“today.plusminutes(120)” etc?
And lastly, what is the best practice for the amount of datapoints if I want a bar-graph type of chart not smooth curves, as my graph shows prices that are constant for the hour and then they change for the next hour. Do I need to give two equal value datapoints in the beginning of the hour and in the end of it or is one datapoint enough to show flat bar-graph?