i am working with a Raspberry pi 3b+ and the razberry modul. And for some weeks now, i have a little weatherstation in my garden based on the tinkerforge system. Up to here, everything’s fine and no problems.
Now the neighbours have of course seen that such a white box is in the garden and asked if they can get the data.
Since I don’t want to open access to the WLAN, my idea was to send the data to openweathermap (as a new station) and simply give them the link to station. On the Website of openweathermap i can find the informatoin how to add data, but did not understand (because of my rather non-existent programming Knowledge) how to do that with openhab. Add neew Station in openweathermap
As an alternative, if easier: i have some webspace (hosted) where i can to “something”.
Please notice, i am a not really talented beginner.
And for informaion, for the beginng i want to give Information about temperature, humidity and pressure, in a second step (Need to buy the sensors) for windspeed, direction and rain, maybe for UV-light and ozone.
But the OpenWeathermap API looks to be pretty simple, You would need to use the sendHttp*Request Actions (if possible) to issue the POST and PUT commands necessary to update the sensor readings from your weather station. If you need to do more than is supported by the Actions, you may need to use executeCommandLine and use the curl command. It’s going to take some research and trying stuff out to make it work but it should be pretty achievable.
I do agree with Jürgen, this is out of scope for the openweathermap binding.
I don’t understand the question. The link is to how to construct the HTTP PUT request to modify information about your weather station. You put that JSON in the body of your request and it will return the indicated JSON as a response.
So to come back to this topic, i try to tinker a little bit and if i send a post request (with postman) i get a answer and i can look to the data via get. But when i try with OH, i am not able to send my information,
had somebody a idea whats going wrong ?
rule “Daten an OWM schicken”
when
Time cron “0 0/30 * * * ?” // every 30 minutes
then
var epoch = now().getMillis()
var Number temperatur = Temperatur.state as DecimalType
var Number luftfeuchte = Luftfeuchte.state as DecimalType
var Number luftdruck =Luftdruck.state as DecimalType
val String URL = “http://api.openweathermap.org/data/3.0/measurements?APPID=APPID”
var String contenttype = “application/json”
var String jsondata = ‘{“station_id”: “STATIONID”,“dt”: ‘+epoch+’,“temperature”: ‘+temperatur+’,“pressure”: ‘+luftdruck+’,“humidity”: ‘+luftfeuchte+’}’
sendHttpPostRequest(URL, contenttype, jsondata)
end
Okay, openweathermap has rejected your message. Mention of key:value pair suggests they don’t like your JSON, try logging that out to review what you have built.
logInfo ("test", "JSON: " + jsondata)
I would guess that you need to convert your Numbers to strings when adding them to the jsondata string.
When i try the var Number… as Decimal Type:
Error during the execution of rule ‘Daten schicken’: Could not cast 28.15 °C to org.eclipse.smarthome.core.library.types.DecimalType; line 12, column 29, length 49
And when i try “state as String” the same error with “could not cast…to String”
So there is no more error, the log said that the data has been send but i did not reach openweathermap.
Example:
JSON: {“station_id”: “ID”,“dt”: 1567104060124,“temperature”: 23.15,“pressure”: 1020.493,“humidity”: 80.76}
And to be honest. I want the expand the system in the next days/weeks/months with some sensors that openweathermap can’t handle and so i have to look for something else anyway. So i am waiting for the TF binding integration from wind and rain (As far as I can know, it’s in work) and i want to implent particulate matter sensor (That is the measurement owm cant “read”). So i think i had to look to a differnt solution to share my data with the neigbours. So i startet a new post. Link to additional post
BUT, if someone has a idea what possible go wrong, i can test it with my second pi and publish if it work, or not.
Just stumbled over your post. Maybe I have a solution for you. I found an old branch in my private repository - nearly have a year old - where I started to implement the support for Station API in the OpenWeatherMap binding. Some changes in the build process stopped my work and I never picked it up again. If I will find some time I can try to prepare a beta version for you for testing purposes. Wdyt?
IIRC I had some design issue where I was not sure how to move on. Like to discuss them once I figured them out again.