# Graph from independent data points

**URL:** <https://community.openhab.org/t/graph-from-independent-data-points/70437>\
**Category:** Scripts & Rules\
**Tags:** database, rules, influxdb\
**Created:** [March 17, 2019, 3:06pm UTC](https://community.openhab.org/t/graph-from-independent-data-points/70437 "2019-03-17T15:06:44Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![wjaceh](https://community.openhab.org/user_avatar/community.openhab.org/wjaceh/32/35158_2.png) [@wjaceh](https://community.openhab.org/u/wjaceh)\
**Post date:** [March 24, 2019, 2:35pm UTC](https://community.openhab.org/t/graph-from-independent-data-points/70437/12 "2019-03-24T14:35:57Z")

</div>

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/rest-api-persistence-service-not-modifiable-influxdb/70710/16)  
[https://community.openhab.org/t/solved-openhab-2-and-executecommandline-exec/21558/39](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:

```csv
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:

```csv
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](https://community.openhab.org/t/datetime-conversion/54266)

```csv
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?

---

_[View the full topic](https://community.openhab.org/t/graph-from-independent-data-points/70437)._
