• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Contribute to openweathermap
#1
Since today, pilight can use openweathermap to retrieve weather data. However, this website solely depends on community input. So, i was thinking, what about integrating an option into pilight to upload weather station information to openweathermap? pilight has a large community that can offer a great deal of support for them while we can use their API for free.

Is there someone that would like to figure out how their upload api works with his own weather station. Just build an example in C, Python, PHP or Java and when necessary, i will port and integrate the code into pilight. I don't own a weather station so it's hard for me to test their upload function.
 
Reply
#2
Maybe you found it yourself already, but doesn't this help? http://jim-easterbrook.github.io/pywws/d...#ToService
 
Reply
#3
I asked the community about this because i didn't want to put much effort into looking. If you guys can find a solution i can just implement it.
 
Reply
#4
I really like the Idea of contributing to Openweathermap.

code in php (using curl) is:
Code:
$User="Enter username here";
$Pass="Enter password here";
$temperature="Temperature from pilight";
$humidity="Humidity from pilight";
$name="Name of your weatherstation";
$long="Longitude of weatherstation's position";
$lat="Latitude of weatherstation's position";




$postData=array(
"temp"=> $temperature,
"humidity"=>$humidity,
"lat"=>$lat,
"long"=>$long,
"name"=>$name);

$s = curl_init();
curl_setopt($s, CURLOPT_URL, "http://".$User.":".$Pass."@openweathermap.org/data/post");
curl_setopt($s, CURLOPT_POST, count($postData));
curl_setopt($s, CURLOPT_POSTFIELDS, $postData);
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
$owm = curl_exec($s);
curl_close($s);
 
Reply
#5
How should the post data be formatted?
 
Reply
#6
Temp and Humidity: just numbers with . as decimal delimiter
Lat, Long: Decimal degrees with . as decimal delimiter (52.376593, 4.897269 for Amsterdam)
 
Reply
#7
Ofc, but how does the post data looks. What should i send over the socket?
 
Reply
#8
@Niek, what are your ideas about how to implement this?
 
Reply
#9
I will think about this and let you know my ideas asap.
 
Reply
#10
@curlymo

I see two possibilities:

  1. Implementation in the weather protocols.
    This will require for each weather protocol (except the generic):
    • Extral options for location, for enabling/disabling the sending of the weather data and the update interval (if not fixed in the code).
    • Functionality for periodic sending the weather data (thread).

  2. Implementation in the openweathermap protocol.
    • Extra setting to enable/disable sending the weather data and possibly the update interval (if not fixed in the code or equal to the openweathermap interval setting)
    • Functionality to search for a configured weather device
    • Functionality for retrieving the data from that weather device
    • Functionality for periodic sending the weather data (thread).
  3. Creation of a new protocol with only the functionality required.
Personally I would definitely go for the second option, mainly for these reasons:
  1. It is intended for openweathermap only, so why would we bother other protocols with it?
  2. Maintenance will be easier because everything is concentrated in one protocol

Implementation of the http post as such shouldn't be difficult, although I haven't looked at details yet (like time constraints and statuscodes).
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)