Hi guys! Can someone help me setting up a rule that detects when it’s raining so I can close my skylights automatically? I want to try it with the OpenWeather plugin and see how that works before I buy a rain sensor. But I can’t get the rules to work - it’s probably super simple but I’m clueless… Can someone provide an example rule?
-
Rule "if it starts to rain..."
-
WHEN rain of weatherdevice =
From there you have to work with the status you get from OpenWeatherLike my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
Thanks - is there some kind of list of available values?
-
Not that I now of. Try take a look at the OpenWeather API documentation.
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
I’m almost there. I’m going to set up two rules:
- one that checks if the value of weather status changed and if the status is one of those that mentions rain -> update an “is_raining” variable to “true”
- a second one that checks if “is_raining” changed and if the new value is “true” will close the skylights.
I’ll post them here once they work.
I wonder if I have to list every single status for rule #1 that mentions “rain” or if there is a way to look for a status that “mentions” rain?
-
@GuybrushMR80 said in Rule "if it starts to rain...":
I wonder if I have to list every single status for rule #1 that mentions “rain” or if there is a way to look for a status that “mentions” rain?
I was wondering that too.
I wanted to create a rule for my light if it’s raining and afternoon that it turns on my light in the living room but I couldn’t anything to work with “if status of $weather contains…”Would be great to hear your results!
-
maybe it is possible to get the rain state either as json output or with a curl command from the website itself. then the logreader or shellsensor device can parse the rain string and inform about the state. you may compare the state with a rule like `WHEN $rain = “rainy” or when $rain = “whatever” THEN do something…"
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
@leader21 I think the problem is not getting the status, it’s more about making sure the different types of rain are all triggering whatever you want to trigger if it starts to rain.
-
Use bash wget a website and then strip until you have what you want…
Just tested;
Create a bash script and paste following code(dont forget to edit the location):
#!/bin/bash wget -q -O - http://www.accuweather.com/en/nl/enschede/250111/weather-forecast/250111 | grep -o '<div class="info"> <span class="cond">[A-Z].*</span><strong' | sed -e 's/.*<span class="cond".//' | sed -e 's/<\/span>.*//'
chmod +x yourscript.sh
Run it, output should be stripped to
Mostly cloudy
Create a shellsensor device named weatherbash, attributename “Weather” attributeType “string” and for command:
/path/to/script.sh
As for the rule:
WHEN Weather of weatherbash is "Mostly cloudy" THEN turn lamp1 on
I dont know all the outputs like Rainy, mostly rainy etc. Figure that out yourself hehe. You can then create a rule for every weather event!
Good luck
-
ok I understand.
well as already said in another thread, I would recommend a rain sensor (somewhere around the house) rather then a weather prediction from a forecast service.pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
The problem with most weather pages like yahoo, accuweather and so on is that nearly all values are calculated based on satelite pictures. This means it is not rearrly accurate and also not “real time”.
If you don’t have a own weather station, i would recommand to check wunderground.
Here you have tons of real weather station with real precip rates (enschede area > 15 stations). Create an free accound and grep the data via json.
I use a weatherstation around 3 km away and 99% of the rain rate is fine. Only in the summer with really local and small thunderstorms are not 100%. -
@Raducanu that sounds like a way better option indeed. When I tested OpenWeather today, the status sometimes showed rain where there was none and the other way round. Would you mind sharing a short tutorial on how you exactly figured out the setup for Wunderground?
-
I also like the way to get information of the weather on wunderground. I would like to put up the screens with rain but with openweather it is not good. I says its sunny but it rains. Can i use the openweather plugin and use api off wunderground.
Thanks gerrit.
-
Currently waiting for the API key to test.
Maybe later on a small tutorial on using wunderground then
-
So an update, get a dev key from weather underground and use this bash instead of the one i posted earlier, change interval to 60000 (once a minute) and adjust your rules to it.
Code:
#!/bin/bash # jsonval credit: https://gist.github.com/cjus/1047794 jsonval () { temp=`echo $haystack | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $needle` echo ${temp##*|} } dev_key='xxxxxxxxxxxx' city='Enschede' state='OV' red=$(tput setaf 1) textreset=$(tput sgr0) haystack=$(curl -Ls -X GET http://api.wunderground.com/api/$dev_key/conditions/q/$state/$city.json) needle='weather' current_condition=$(jsonval $needle $haystack) echo -e $current_condition
Change dev key, city and state. Will result in following output on which you can base your rules:
WHEN Weather of weatherbash is "Patches of Fog" THEN turn lamp1 on
-
Thank Glenn0h,
will try it out later today! -
Weather conditions available:
[Light/Heavy] Drizzle [Light/Heavy] Rain [Light/Heavy] Snow [Light/Heavy] Snow Grains [Light/Heavy] Ice Crystals [Light/Heavy] Ice Pellets [Light/Heavy] Hail [Light/Heavy] Mist [Light/Heavy] Fog [Light/Heavy] Fog Patches [Light/Heavy] Smoke [Light/Heavy] Volcanic Ash [Light/Heavy] Widespread Dust [Light/Heavy] Sand [Light/Heavy] Haze [Light/Heavy] Spray [Light/Heavy] Dust Whirls [Light/Heavy] Sandstorm [Light/Heavy] Low Drifting Snow [Light/Heavy] Low Drifting Widespread Dust [Light/Heavy] Low Drifting Sand [Light/Heavy] Blowing Snow [Light/Heavy] Blowing Widespread Dust [Light/Heavy] Blowing Sand [Light/Heavy] Rain Mist [Light/Heavy] Rain Showers [Light/Heavy] Snow Showers [Light/Heavy] Snow Blowing Snow Mist [Light/Heavy] Ice Pellet Showers [Light/Heavy] Hail Showers [Light/Heavy] Small Hail Showers [Light/Heavy] Thunderstorm [Light/Heavy] Thunderstorms and Rain [Light/Heavy] Thunderstorms and Snow [Light/Heavy] Thunderstorms and Ice Pellets [Light/Heavy] Thunderstorms with Hail [Light/Heavy] Thunderstorms with Small Hail [Light/Heavy] Freezing Drizzle [Light/Heavy] Freezing Rain [Light/Heavy] Freezing Fog Patches of Fog Shallow Fog Partial Fog Overcast Clear Partly Cloudy Mostly Cloudy Scattered Clouds Small Hail Squalls Funnel Cloud Unknown Precipitation Unknown```
-
Awesome, great to see the progress on this! Can someone help me with the basics here? Where do I have to put the code above? And one thing I realized: For the API you’re allowed to have 500 calls/day so setting the interval to 3 minutes is probably better, right (=480 calls/day)?
-
@GuybrushMR80 do as you please.
Look at my earlier post. Replace that bash with this one. In short, again,Create a bash script and copy that code.
sudo nano /home/pi/pimatic-app/scripts/weather.sh
Shift insert to paste, ctrl x - y - enter to save.
chmod +x /home/pi/pimatic-app/scripts/weather.sh
to make it executable.Then simply create a shellsensor and point it to the bash. Follow the rules i made and presto.
-
Has anyone tried it?
I am curious to know so i can eventually create a tutorial.I can imagine other people want this too so a decent tutorial would be needed. I dont have the time or equipment to properly test it because my laptop failed on me.