Buying advice weatherstation or -binding controlling sunscreen

Hi all,
I have OpenHab2/Hasbian on RaspberryPi2 with Aeon z-wave stick and five wallplugs to get started and learn. Since a week I finally make some progress and now I want to procede and start controlling my sunscreen in such a way that it rolls up as soon as it starts to rain or when the wind is too strong.
First I will need the switch, this will be the Fibaro rollershutter switch v2. But then lots of questions pop up.

I could try to use a weatherbinding like weatherunderground. But for one: I cannot get the weatherunderground-binding to work; two: would it give me rain information quick enough and accurate enough to prevent the sunscreen from getting wet?

Probably it is better to buy my own wheather station.
There is Netatmo with a plus that it also measures CO2 indoors. But when I need to extend the starter kit with rain and wind, it wil be very costly (about €330,- at my local shop) and is this completely compattible with openhab? Is it possible to only use the rain gauge and wind meter, since its all wifi, or is the starter kit necessary?

Then there is the Qubino ZMNHZD1 which has its own dongle to translate between zwave and 466Mhz. Is this actually a RFXComm dongle? Could I use it to also control other devices like ‘Klikaan-klik-uit’? (Sorry, I do not know the English word, tell me if you need clarification) That would also be a plus, since I could buy more RFXcom things and not need to buy the extra dongle.

There is also the Ventus W-830 Wunderground 868 MHz this is about €150,- which I am ok with. But I can not find what communication protocall it uses or if it is supported by openhab2 when I have only TCP and z-wave. The same goes for the Alecto WS4050 which also is affordable, but can I connect it to opebhab?

Could anyone comment on my thoughts and questions and hopefully give advice which way to go. The WAF is very high here, so I better not waight much longer :wink:

I’ve made a custom weather service that uses forecast from the swedish meteorological institute. From there I get updated forecast every hour, with values for every hour. I don’t know how the weather binding works, but if you can get hourly forecasts, you can use it in a at of rules that raises the sunscreen if there is a chance of rain or to much wind in within the current hour. That’s how I do it and it works really well. Sometimes I have to raise my sunscreens manually when there’s a sudden rain showers that the forecast didn’t predict, but I don’t know if a weather station can register the first few drops of rain anyway, so don’t think that would make any difference.

Provided you can get hourly data from a weather service, I would go for that.

Hi Guido,
Like you, I also wanted to use live weather information to open and/or close my home’s sunscreens. I used the WeatherUnderground service, but I found it inaccurate and often lagging, and therefor not ideal. I opted for a personal weather station. I did some research and found this set, Renkforce WH2600 Wunderground. made by FineOfset (I guess that the devices you mentioned are also made by this company).
The WH2600 has some useful features in general:

  • The set is quite affordable .
  • The outdoor sensor-unit is solar powered.
  • It’s also equipped with a light intensity sensor, convenient for using with screens.
  • Its bridge is a small, mains powered device without a screen, buttons or batteries that you won’t be needing anyway.
    And for integrating it with openhab it has multiple useful features:
  • It has a nice webinterface that shows the sensor data live, openhab can get the data from there by making an http GET request and parsing the WH2600’s reply.
  • The set is intended to upload the sensor data to a personal Wunderground account. You can fetch that data from there and use it.
  • The webinterface allows you to change the address the data is send to and the upload protocol’s specifications are public. So basically you can host your own webserver and relay the uploaded data to openhab’s rest api with a simple php script that performs some PUT requests (beware, the sensor data will be uploaded in empirical, so you might want to convert that to metric before relaying). For openhab1 the script can look like this:
<?php

function postUpdate($item, $data) {
  $url = "http://192.168.1.11:8080/rest/items/" . $item . "/state";

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

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

  return $result;
}
	
foreach ($_GET as $i => $s) {
  if($i == "solarradiation") {
    $s = strval(round(floatval($s) / 0.0079,0)) ;
  }
  elseif($i == "windchillf" || $i == "dewptf" || $i == "tempf" || $i == "indoortempf") {
    $s = strval(round(((floatval($s)- 32) * 5)/9,1)) ;
  }
  elseif($i == "baromin") {
    $s = strval(round(floatval($s) * 33.864,1)) ;
  }
  elseif(strpos($i, "rainin") !== false) {
    $s = strval(round(floatval($s) * 25.4,1)) ;
  }
  elseif(strpos($i, "mph") !== false) {  
    $s = strval(round(floatval($s) * 1.609344,1)) ;
  }
  postUpdate('weather_local_' . $i, $s);
}

if(true) {
  echo "success";
}
?>

Without converting it can be as simple as:

<?php

function postUpdate($item, $data) {
  $url = "http://192.168.1.11:8080/rest/items/" . $item . "/state";

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

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

  return $result;
}

foreach ($_GET as $i => $s) 
  postUpdate('weather_local_' . $i, $s);

if(true) {
  echo "success";
}
?>

Cheers,

Jesse

5 Likes

Thank you both for your advice! Both of you go the other direction :wink: of course what works for one may or may not work for another. I will try to get Wunderground to work for now, and I have put the WH2600 on my whish list. Indeed I don’t want yet another screen somwhere consuming power if I don’t need the display. So the device seams like a logical choice and within budget!
If I do buy the weather station, where would I put the php-script, and how would you couple this to things/items in OH2?

Hi Guido,

You can do the following:

Create these items:

Group	weather_local					"Local Weather"			(all)

Number  weather_local_tempf 			"Temperature [%.2f °C]" (weather_local)	
Number  weather_local_humidity         	"Humidity [%d %%]"      (weather_local)	
Number weather_local_dewptf				"Dewpoint [%.2f °C]"	(weather_local)
Number weather_local_windchillf			"Windchill [%.2f °C]" 	(weather_local)
Number  weather_local_windspeedmph      "Wind speed [%.2f km/h]"	(weather_local)  
Number  weather_local_windgustmph		"Gust speed [%.2f km/h]"  	(weather_local)  
String  weather_local_winddir			"Wind degree [%s °]"	(weather_local)	
Number	weather_local_solarradiation	"Solar radiation [%.2f lux]"	(weather_local)
Number	weather_local_UV				"UV [%.2f index]"			(weather_local)
Number	weather_local_indoortempf		"Temperature indoor [%.2f °C]"	(weather_local)
Number	weather_local_indoorhumidity	"Humidity indoor [%.2f %%]"      	(weather_local)
Number	weather_local_baromin			"Pressure [%.2f mb]"	(weather_local)

Number	weather_local_rainin			"Rain [%.2f mm]"		(weather_local)
Number	weather_local_dailyrainin		"Rain daily [%.2f mm]"	(weather_local)
Number weather_local_weeklyrainin		"Weekly rain [%.2f mm]"	(weather_local)
Number weather_local_monthlyrainin		"Monthly rain [%.2f mm]"	(weather_local)
Number weather_local_yearlyrainin		"Yearly rain [%.2f mm]"	(weather_local)
String weather_local_lowbatt			"Low battery [%s]"		(weather_local)
String weather_local_softwaretype		"Software type [%s]"	(weather_local)
String weather_local_realtime			"Realtime [%s]"			(weather_local)
Number weather_local_rtfreq				"Update [%s]"			(weather_local)
String	weather_local_action			"Action [%s]"      		(weather_local)
String	weather_local_ID 				"ID [%s]"      			(weather_local)
String	weather_local_PASSWORD			"PASSWORD [%s]"      	(weather_local)
String	weather_local_dateutc			"Last update [%s]"    	(weather_local)

You don’t have to bind these items to anything.

On your openhab server install a webserver with php and cgi supprt, something like this if you’re on Linux.
In the server’s root folder create a folder named “weatherstation”.
Put the php script, named “updateweatherstation.php” in the folder you just created.
In the weatherstation’s webinterface go to the “Weather Network” tab and enter the following settings:
- Remote Server: “Customized”
- Server IP/Hostname: Address of your server
- Server Port: Port of your server
- Server Type: “PHP”
- Station ID: What ever you want
- Password: What ever you want

hi Jesse,

it looks like your weatherstation is the same as ‘Wireless Weather Station WeatherSleuth’:

… so I’ll give them a try on mine. Thank you! :slight_smile:

Yes, that works beautifully! Thank you Jesse.

I’d still like to post the data to Wunderground as well, tho, so do you how the php can be amended to post it on to wunderground, please?

I managed to sort it, by adding the code below immediately after the ‘echo success’ part.

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "http://rtupdate.wunderground.com" . $_SERVER['REQUEST_URI']);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_exec($ch);
  curl_close($ch);

My setup is probably influenced by order of implementing. Some years ago I purchased a weather station and then only recently started trying out OpenHAB.

When I purchased the weather station (a WH1080 rebadged by an electronics/hobby store chain) I setup the weewx software to query the data from the console and publish it to a personal web page and also publish the data to both WOW and Weather Underground.

After installing OpenHab and playing around with it I wanted to be able to know what the temperature is, or if it is windy, or raining. There is a weewx addon to publish current weather data to an MQTT broker. I was already trying to use MQTT with OwnTracks for presence detection. So using MQTT is the obvious choice for me to publish my weather data to OpenHAB.

The only downside is the need to manually define the weather items. Everything else I try to have graphical/automatic configuration with Paper UI. But it is not that complex. My local weather items are below

Number 	CurrentTemp					"Temperature [%.1f °C]"		{ mqtt="<[broker:weather/outTemp_C:state:default]"}
Number	TodaysRain					"Rain Today [%.1f mm]"		{ mqtt="<[broker:weather/rain24_cm:state:default]"}
Number	HourRain					"Rain Last Hour [%.1f mm]"	{ mqtt="<[broker:weather/hourRain_cm:state:default]"}
Number	WindSpeed					"Wind Speed [%.1f kph]"		{ mqtt="<[broker:weather/windSpeed_kph:state:default]"}

There were really good examples on the forum and in the documents that helped me to configure it all without problems.

The weewx mqtt addon publishes more data than is in my current items definitions. These are just the details I chose to setup for the moment.

@ Guido,

Another possible solution.
I combined the Information on: ftp://ftp.knmi.nl/pub_weerberichten and https://xml.buienradar.nl/

See:

https://community.openhab.org/t/australian-bureau-of-meteorology-integration-with-openhab/23007

Regards Bert

Hi @Bert Vischer,
That is very interesting too! Oh how many possibilities, child in a candy store!
I will investigate this direction now.

To give you some direction, Just for one day:grinning:

Some Items:

Number KMNIUpdate				"Update			[%d]"	(Weersvoorspelling)
String Dag_1					"Dag			[%d]"	(Weersvoorspelling)
String Icoon_1					"Icon			[%d]"	(Weersvoorspelling)
Number ZonKans_1				"Zonneschijn	[%s]"	(Weersvoorspelling)
Number NeerslKans_1				"Neerslagkans	[%s]"	(Weersvoorspelling)

Some Script:

import urllib.request
from lxml import etree

url = 'ftp://ftp.knmi.nl/pub_weerberichten/middellange_termijn_verwachting.xml'
print('Requesting file...')
rawPage = urllib.request.urlopen(url)
print('File received...')

read = rawPage.read()
tree = etree.XML(read)

print('Parsing data...')
KMNIUpdate = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/tijd_aanmaak//text()")[0]

Dag_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/dag1_ddd//text()")[0]
ZonKans_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/zonneschijnkans_dag1//text()")[0]
NeerslKans_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/neerslagkans_dag1//text()")[0]
NeerslMin_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/neerslaghoeveelheid_min_dag1//text()")[0]
NeerslMax_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/neerslaghoeveelheid_max_dag1//text()")[0]
MinTempMin_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/minimumtemperatuur_min_dag1//text()")[0]
MinTempMax_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/minimumtemperatuur_max_dag1//text()")[0]
MaxTempMin_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/maximumtemperatuur_min_dag1//text()")[0]
MaxTempMax_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/maximumtemperatuur_max_dag1//text()")[0]
WindRichting_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/windrichting_dag1//text()")[0]
WindKracht_1 = tree.xpath("//dataroot/Middellange_x0020_en_x0020_lange_x0020_Termijn/windkracht_dag1//text()")[0]

print('Updating OpenHAB...')
urlBase = 'http://192.168.2.2:8080/classicui/CMD?'
rawPage = urllib.request.urlopen(urlBase + 'KMNIUpdate=' + KMNIUpdate)

rawPage = urllib.request.urlopen(urlBase + 'Dag_1=' + Dag_1)
rawPage = urllib.request.urlopen(urlBase + 'ZonKans_1=' + ZonKans_1)
rawPage = urllib.request.urlopen(urlBase + 'NeerslKans_1=' + NeerslKans_1)
rawPage = urllib.request.urlopen(urlBase + 'NeerslMin_1=' + NeerslMin_1)
rawPage = urllib.request.urlopen(urlBase + 'NeerslMax_1=' + NeerslMax_1)
rawPage = urllib.request.urlopen(urlBase + 'MinTempMin_1=' + MinTempMin_1)
rawPage = urllib.request.urlopen(urlBase + 'MinTempMax_1=' + MinTempMax_1)
rawPage = urllib.request.urlopen(urlBase + 'MaxTempMin_1=' + MaxTempMin_1)
rawPage = urllib.request.urlopen(urlBase + 'MaxTempMax_1=' + MaxTempMax_1)
rawPage = urllib.request.urlopen(urlBase + 'WindRichting_1=' + WindRichting_1)
rawPage = urllib.request.urlopen(urlBase + 'WindKracht_1=' + WindKracht_1)

print('End')

And a bit of rule

rule "knmi"
when
	Time cron "0 0 0/1 1/1 * ? *" // update every hour
then
	executeCommandLine("python3@@/home/pi/KNMI.py@@")
end

It was a puzzle but it workt.

regard Bert

Thank you @Bert!
I will be away for some time now, but I’ll try this definately!

Hi Guido,

I’m not sure about Jetty and Nginx.
You might want to take a look at Lighttpd ( https://redmine.lighttpd.net/projects/1/wiki/TutorialLighttpdAndPHP )

Cheers,
Jesse

Hi @greenJ,
I would like to test this, but the RasPi is already loaded with jetty and nginx, and I read here that it is possible to run php from nginx. Then I would only have to install php (or is this also possible with lightphp?
I am just a bit worried that I mess up the openhabinstallation. Does anybody know what steps to take and what the chance of messing up openhab is? Mmm, better start a new topic I guess. I will do so, and post a link here for refference.
Thanx!

Visit Topic or reply to this email to respond.

In Reply To

greenJ
:evergreen_tree::evergreen_tree::evergreen_tree::evergreen_tree::evergreen_tree::evergreen_tree::evergreen_tree:

July 24

Hi Guido,

You can do the following:

Create these items:

Group weather_local “Local Weather” (all)

Number weather_local_tempf “Temperature [%.2f °C]” (weather_local)
Number weather_local_humidity “Humidity [%d %%]” (weather_local)
Number weather_local_dewptf "De…

Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

I also think about the Same issue.

I think for local Wind Speed etc i Will Go for netatmo

Hello, please help. I have raspberry pi3 with raspbian and openhab. try to install pywws but fails.
procedure:

apt-get install python-pip - ok
apt-get install python-dev - ok
apt-get install python-usb - ok
pip install pywws - after this error message, see the attachment. apt-get update and apt-get upgrade, of course. thank you very much

error:
Traceback (most recent call last):
File “/usr/bin/pip”, line 9, in
load_entry_point(‘pip==1.5.6’, ‘console_scripts’, ‘pip’)()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2476, in load_entry_point
return ep.load()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2190, in load
[‘name’])
File “/usr/lib/python2.7/dist-packages/pip/init.py”, line 74, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File “/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py”, line 9, in
from pip.download import path_to_url
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 25, in
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead