Using API with Openhab

#1

Just want to say Hello and thank you for the API from Switzerland. I’m using your API for my Smart Home Project with Openhab and our PV at home with 14 kwp.
Screenshot from today (using Influxdb and Grafana):


Green: Production Red: Consumption Blue: Forecast

3 Likes
#2

Would you like to share your API integration code for others to learn from? Your choice of distribution GitHub, GitLab, BitBucket, self hosting, etc.

#3

Thanks very much for posting your feedback!

We plan on announcing some exciting features to our API before the end of the year which we’ll post about on these forums. :tada:

We appreciate any sharing of data, code and the like which better informs us how users are using the API.

Thanks again :slight_smile:

#4

Hi @hippo_2 - that looks like a fantastic use of the solcast API and exactly what I’m trying to achieve with my system at the moment.

Is there any chance you’d be able to share how you brought the information into influxDB/openHAB? I’ve followed one of the worked examples on the InfluxDB website to try and get the overall concepts, but it would be great to see how you’ve actually implemented getting data from Solcast in to InfluxDB (then displayed in openHAB).

Thanks very much in advance!

2 Likes
#5

Hi @joncknott , I started with this tutorial to setup Influxdb and Grafana working with Openhab.

Create a persistence-file “influxdb.persist”. After that I made a cache item with the URL

solcast.url=https://api.solcast.com.au/pv_power/forecasts?longitude=yourlongitude&latitude=yourlatitude&capacity=14000&tilt=17&azimuth=-174&install_date=20160901&api_key=yourapikey&format=json

Create a “items” file like that:
Number Solcast005 { http="<[solcast:300000:JSONPATH($.forecasts.[0].pv_estimate)]" }

In Grafana you have to create a new graph like that:

I hope this will help you with your project. Have fun!

2 Likes
#6

@hippo_2 - thank you so much for the detailed response (and apologies for the delay in mine)!

I was able to get the forecast data into openHAB and then have it pop the data into InfluxDB, but I was having a real rough time trying to deal with the data structures and manipulating timestamps within openHAB so i ended up employing the excellent Solcast API python library to do all the heavy lifting for our prediction models outside of the openHAB environment. I also bring some values directly to openHAB for plotting and some rules-based behaviour with a separate API call.

As an aside, it is possible to do a direct HTTP request using something along the lines of:

Number Solcast005 "Value: [%.1f W]" { http="<[solcast.url=https://api.solcast.com.au/pv_power/forecasts?longitude=yourlongitude&latitude=yourlatitude&capacity=14000&tilt=17&azimuth=-174&install_date=20160901&api_key=yourapikey&format=json
:60000:JSONPATH($.forecasts.[0].pv_estimate)]" }

Is there any value to doing the HTTP cache method? The openHAB HTTP binding documentation just says that it is possible to do a HTTP cache or a direct HTTP API call, and doesn’t make recommendations for one way or the other. My reasoning is doing a direct API call every 30 mins or so achieves the same ends as refreshing a HTTP cache every 30 mins. I am certainly no expert, so it would be great to know if you’ve selected the HTTP cache method for a specific reason that I’m missing (programming best-practices, flexibility, etc.).

2 Likes
#7

Hi…I have been utilizing rotini as an interface for two or three months at this point, and the venture is going an unexpected course in comparison to I need to go with my framework. I don’t care for the new interface for the application or the web form accessible. Particularly making singular arrangements for every gadget.

At last, I need a tasker module, or arrangement that pulls in all things and effectively permits arrangement of tasker without knowing the name of each thing random. Simply need to parse the xml document that profits fro the REST demand.

Do you have any connections, or see how to parse the returned data without any problem? what might be the most ideal approach to do that? I need to have the option to make factors with every thing, and a variable for the present status of that thing. it is sufficiently simple to share tasker arrangements between gadgets. they can connect in to nearly all that you can consider and they won’t change arbitrarily in light of a designers singular taste evolving.

order pcb

#8

What is rotini and why can’t you parse the XML? I wouldn’t use that format as json has a much larger set of support libraries.