Outside WiFi weather station "WS3500" and local customized upload (no cloud needed)

Thank this helps me a lot.

You have mentioned that your weather station sends not the “elev” key.

How do you request the data/key from your weather station?
Can I just type in the browser e.g.

http://my_weather_station_ip/getData

I would like to check what my weather stations sends out, maybe the name is not matching.
But I do not know how to read out these information from the weather station

No, you can’t. Please read the thread from the beginning (I know, annoying, if there’s info splattered across).

You have to configure the weather station in the “WS View”-App to call a certain script. It will then do that periodically - you set the seconds in the “upload interval”.

you can

  1. you can check your PHP webserver’s logfile
  2. you can edit the PHP script to write the GET-parameters in a file or something

easiest would be 1. I guess, if you know, where it is.

Also, this is, what my WS3500 aka WIFI50DD sends (Firmware: EasyWeathev1.6.4) - already converted to JSON-format

{
  "ID": "123",
  "PASSWORD": "987",
  "indoortempf": "78.1",
  "tempf": "84.4",
  "dewptf": "56.8",
  "windchillf": "84.4",
  "indoorhumidity": "47",
  "humidity": "39",
  "windspeedmph": "1.8",
  "windgustmph": "3.4",
  "winddir": "165",
  "absbaromin": "28.358",
  "baromin": "30.036",
  "rainin": "0.000",
  "dailyrainin": "0.000",
  "weeklyrainin": "0.000",
  "monthlyrainin": "0.791",
  "solarradiation": "577.79",
  "UV": "5",
  "dateutc": "2022-07-28 13:36:02",
  "softwaretype": "EasyWeatherV1.6.4",
  "action": "updateraw",
  "realtime": "1",
  "rtfreq": "5"
}

Thanks, for your tip.
I have added this to the php file:
My first php code but it works :grinning:

	// write data from weather station into txt file
	$result = array($_GET);
	file_put_contents("weatherstation_data.txt",print_r($result, true));

Here my data:

Array
(
    [0] => Array
        (
            [ID] => XXX
            [PASSWORD] => XXXX
            [tempf] => 87.6
            [humidity] => 37
            [dewptf] => 58.3
            [windchillf] => 87.6
            [winddir] => 280
            [windspeedmph] => 3.80
            [windgustmph] => 5.82
            [rainin] => 0.000
            [dailyrainin] => 0.000
            [weeklyrainin] => 0.000
            [monthlyrainin] => 0.071
            [yearlyrainin] => -9999
            [totalrainin] => 0.071
            [solarradiation] => 225.11
            [UV] => 2
            [indoortempf] => 80.8
            [indoorhumidity] => 43
            [absbaromin] => 29.211
            [baromin] => 29.716
            [lowbatt] => 0
            [dateutc] => now
            [softwaretype] => EasyWeatherPro_V5.0.7
            [action] => updateraw
            [realtime] => 1
            [rtfreq] => 5
        )

)

Here my info regarding the weatherstation Sainlogic WS3500 built 05.2022.
When I look into WSView Plus app the weather station is called "EasyWeatherPro-0FDC2.1
image

We both have no “elev” and my “dateutc” is only a string with now.

I have created my additional data and changed the the Data to String, makes no sense but I get now all data provided by the weather station;-)

Number 					Weatherstation_lowbatt			"Batterie"				<temperature>	(gWeather, Wetter)	
Number:Length 			Weatherstation_yearlyrain		"Niederschlag/Jahr [%.1f mm]"   <rain>	(gWeatherHeight, Wetter)	
**String**  				Weatherstation_dateutc			"Uhrzeit"							<temperature>	(gWeather, Wetter)	

1 Like

I think, your Firmware has an bug with “now” instead of a UTC-timestamp!
other than that, it looks good! And beware of your skills in scripting growing over time using openHAB! :wink:

Hi all, for anyone looking to use the ECOWITT output type. Here is a php that performs well. It’s just a modification of @binderth’s amazing code.

You’ll need to use this if you need data such as additional sensors and battery data, which aren’t supported by the wunderground format.

I’ve also included a corresponding items file. I have one additional sensor on CH2. You can add extras as you have configured.

I’ve also included a handy function at the top, comment this back in to troubleshoot and see the values your php file is receiving.

<?php

// Code to log your Ecowitt output to a file for exploration and troubleshooting.
// You'll need to create the directory /var/log/weather/ and give it permissions.

// $date = date_create();
// $handle = fopen("/var/log/weather/" . date_timestamp_get($date), "w");
// $result = print_r($_POST, true);
// print_r(error_get_last());
// fwrite($handle, $result);
// fclose($handle);

// Beispiel von Wetteratation
// 192.168.0.119 - - [12/Jun/2020:20:29:37 +0000] "GET /wetterstation.php?ID=1&PASSWORD=1&indoortempf=81.1&tempf=70.5&dewptf=52.7&windchillf=70.5&indoorhumidity=40&humidity=53&windspeedmph=1.6&windgustmph=2.2&winddir=79&absbaromin=29.064&baromin=29.903&rainin=0.000&dailyrainin=0.000&weeklyrainin=0.000&monthlyrainin=0.000&solarradiation=0.00&UV=0&dateutc=2020-06-12%2020:29:37&softwaretype=EasyWeatherV1.5.0&action=updateraw&realtime=1&rtfreq=5 HTTP/1.0" 200 913 "-" "-"
$weatherprefix = "Weatherstation_"; // if you have a prefix in your OH2 items configuration
// resends all GET-Values directly to OH2 API
foreach ($_POST as $key => $value) {
	// looking for suffixes and redirecting them
	/* Weatherunderground format looks like this:
		* ID				ID (configuratble in the App)
		* PASSWORD			KEY (configurable in the App)
		* indoortempf		in Fahrenheit
		* windchillf		in Fahrenheit
		* indoorhumidity	in percent
		* humidity			in pfpro_cleanup	
		* windspeedmph		in mp/h
		* windgustmph		in mp/h	
		* winddir			in degrees
		* absbaromin		in inch of mercury
		* baromin			in inch of mercury
		* rainin			in inch
		* dailyrainin		in inch
		* weeklyrainin		in inch
		* monthlyrainin		in inch
		* solarradiation	in W/m2
		* UV				in index (0 - 11)
		* dateutc			current date (UTC)
		* softwaretype		used software
		* action			usually "updateraw"
		* realtime			using real-time updates (0/1)
		* rtfreq			update frequency (configurable in the App)
		
		as seen here, with the last character(s) of a attribute you can tell, which unit is used
	*/
	
	switch ($key) {
		
		case "tempinf":
		case "tempf":
		case "temp1f":
		case "temp2f":
		case "temp3f":
		case "temp4f":
		case "temp5f":
		case "temp6f":
		case "temp7f":
		case "temp8f":
		// case ""
			// unit is in Fahrenheit (remove "f")
			if(f2c($value) < -40) { //Filter für unmögliche Werte
				sendOH2Command($weatherprefix . "error", "Filter: " . $key . "=" . $value . "(" . f2c($value) . "°C)");
			}
			else {
				sendOH2Command($weatherprefix.str_replace("f", "", $key), f2c($value));
			}
			break;
		// case "ptf":
		// 	// unit is in Fahrenheit also (remove "f")
		// 	if(f2c($value) > -40) //Filter für unmögliche Werte
		// 		sendOH2Command($weatherprefix.str_replace("ptf", "pt", $key), f2c($value));
		// 	else
		// 		sendOH2Command($weatherprefix . "error", "Filter: " . $key . "=" . $value . "(" . f2c($value) . "°C)");
		// 	break;
		// case "llf":
		// 	// unit is in Fahrenheit also (remove "f")
		// 	if(f2c($value) > -40) //Filter für unmögliche Werte
		// 		sendOH2Command($weatherprefix.str_replace("llf", "ll", $key), f2c($value));
		// 	else
		// 		sendOH2Command($weatherprefix . "error", "Filter: " . $key . "=" . $value . "(" . f2c($value) . "°C)");
		// 	break;
		case "baromrelin":
		case "baromabsin":
			// unit is in inHg (remove "min")
			sendOH2Command($weatherprefix.str_replace("in", "", $key), inHG2hPa($value));
			break;
		case "rainratein":
		case "eventrainin":
		case "hourlyrainin":
		case "dailyrainin":
		case "weeklyrainin":
		case "monthlyrainin":
		case "yearlyrainin":
			// unit is in inch (remove "in" from end of field)
			sendOH2Command($weatherprefix.substr($key, 0, -2), in2mm($value));
			break;
		case "windspeedmph":
		case "windspdmph_avg10m":
		case "windgustmph":
		case "maxdailygust ":
			// unit is in mph (remove "mph")
			sendOH2Command($weatherprefix.str_replace("mph", "", $key), mph2kmh($value));
			break;
		case "utc":
			// unit is in UTC
			sendOH2Command($weatherprefix.$key, str2UTC($value)."");			
			break;
		default:
			// everything else: not a unit, or percent or string
			if($value > -1000) //Filter für unmögliche Werte
				sendOH2Command($weatherprefix.$key, $value);
			else
				sendOH2Command($weatherprefix . "error", "Filter: " . $key . " = " . $value);
	}	
}

function sendOH2Command($item, $data) {
  $url = "http://openhabian:8080/rest/items/" . $item;
  //  $url = "http://localhost:32080/rest/items/" . $item; //geht mit localhost nicht

  $options = array(
	'http' => array(
		'header'  => "Content-type: text/plain\r\n",
		'method'  => 'POST',
		'content' => '' . $data  //http_build_query($data),
	),
  );

  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  return $result;
}

function str2UTC($given_value) {
	return str_replace(" ", "T", $given_value);
}

function mph2kmh($given_value) {
	return '' . round( floatval($given_value) * 1.60934, 1);
}

function in2mm($given_value) {
	return '' . round( floatval($given_value) * 25.4, 1);
}

function inHG2hPa($given_value) {
	return '' . round( floatval($given_value) * 33.8639 , 1); //1 inHG = 3386,39 Pa, Bespielwert: 29.064 sollte ca 985 sein
}

function f2c($given_value) {
	return '' . round( (5.0 / 9 * (floatval($given_value) - 32 )), 1);
}


?>
String 					Weatherstation_JSON 			"Weatherstation JSON"
Group					Weather							"Weather Observations"								(All)

// Config Info
// String 					Weatherstation_PASSKEY				"id"
String 					Weatherstation_PASSKEY			    "Key / Passsword"
String 					Weatherstation_stationtype			    "Software Version"
String 					Weatherstation_model			    "Station Model"
DateTime				Weatherstation_dateutc			"Date"							<temperature>	(gWeather, Weather)	
String 					Weatherstation_softwaretype		"Software"							<temperature>	(gWeather, Weather)	
String 					Weatherstation_action			"WeatherAction"						<temperature>	(gWeather, Weather)	
String 					Weatherstation_realtime			"Realtime"							<temperature>	(gWeather, Weather)	
String 					Weatherstation_rtfreq			"Updatefrequency"					<temperature>	(gWeather, Weather)

// Temperature
Number:Temperature 		Weatherstation_tempin		"Indoor Temperature [%.1f %unit%]"	<temperature>	(gWeatherTemp, Weather)	
Number:Temperature 		Weatherstation_temp			"Outdoor Temperature [%.1f %unit%]"	<temperature>	(gWeatherTemp, Weather)	
Number:Temperature 		Weatherstation_dewpt				"Dew Point [%.1f %unit%]"			<temperature>	(gWeatherTemp, Weather)	
Number:Temperature 		Weatherstation_windchill			"Windchill [%.1f %unit%]"			<temperature>	(gWeatherTemp, Weather)
Number:Temperature 		Weatherstation_temp2			"Greenhouse Temp [%.1f %unit%]"			<temperature>	(gWeatherTemp, Weather)

// Barometer
Number:Pressure 		Weatherstation_baromrel			"Barometer min [%.1f %unit%]"		<temperature>	(gWeatherPressure, Weather)	
Number:Pressure 		Weatherstation_baromabs			"Abs. Barometer min [%.1f %unit%]"	<temperature>	(gWeatherPressure, Weather)	

// Rain
Number:Length 			Weatherstation_rainrate				"Rain [%.1f mm]"		<temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_eventrain				"Rain Event [%.1f mm]"		<temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_hourlyrain		"Rain Hourly [%.1f mm]"	<temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_dailyrain			"Rain Daily [%.1f mm]"	<temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_weeklyrain		"Rain Weekly %.1f mm]"	<temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_monthlyrain		"Rain Monthly [%.1f mm]" <temperature>	(gWeatherHeight, Weather)	
Number:Length 			Weatherstation_yearlyrain		"Rain Yearly [%.1f mm]" <temperature>	(gWeatherHeight, Weather)	

// Wind
String 					Weatherstation_winddir			"Wind Direction"						<temperature>	(gWeather, Weather)	
String			        Weatherstation_winddir_avg10m			"Wind Speed [%.1f %unit%]" 	<temperature>	(gWeatherSpeed, Weather)	
Number:Speed 			Weatherstation_windspeed			"Wind Speed [%.1f %unit%]" 	<temperature>	(gWeatherSpeed, Weather)	
Number:Speed 			Weatherstation_windspd_avg10m			"Wind Speed (Ave 10 mins) [%.1f %unit%]" 	<temperature>	(gWeatherSpeed, Weather)	
Number:Speed 			Weatherstation_windgust	"Wing Gust [%.1f %unit%]"				<temperature>	(gWeatherSpeed, Weather)	
Number:Speed 			Weatherstation_maxdailygust	"Wing Gust (Max Daily) [%.1f %unit%]"				<temperature>	(gWeatherSpeed, Weather)	

// Humidity
Number 					Weatherstation_humidity			"Outdoor Humidity [%.1f %%]"	<temperature>	(gWeather, Weather)	
Number 					Weatherstation_humidityin 	"Indoor Humidity [%.1f %%]"	<temperature>	(gWeather, Weather)	
Number 					Weatherstation_humidity2	"Greenhouse Humidity [%.1f %%]"	<temperature>	(gWeather, Weather)	

// Solar Info
Number 					Weatherstation_solarradiation	"Solar Radiation [%.1f]"			<temperature>	(gWeather, Weather)	
Number 					Weatherstation_uv				"UV-Index [%.1f]"				<temperature>	(gWeather, Weather)	

//Battery
Number 					Weatherstation_wh65batt				"WH65 Battery"				<temperature>	(gWeather, Weather)	
Number 					Weatherstation_wh25batt				"Indoor Sensor Battery [%.1f]"				<temperature>	(gWeather, Weather)	
Number 					Weatherstation_batt2				"Greenhouse Sensor Battery[%.1f]"				<temperature>	(gWeather, Weather)	
1 Like

how do I run the php script can this run on a pi thanks and does it work find in openhab 4

the script has to run on a webserver. could be a small nginx on your pi or if you have, some NAS, which also offer webserver capability. unfortunately, the firmware of the WH3500s doesn’t send JSON, but GET-values, which are not compatible with the REST API of openHAB. You could also upload your data to a cloud service (configuration via APP) and poll it from there