summaryrefslogtreecommitdiffstats
path: root/kachelmann/changes
diff options
context:
space:
mode:
authorMomo <momorientes@online.de>2011-08-06 03:47:06 +0200
committerMomo <momorientes@online.de>2011-08-06 03:47:06 +0200
commit4545d08ac81eab0cd9edce793f69b41f204aaf2f (patch)
tree80ec5862290487714bcbe20c29d03ce26cf70701 /kachelmann/changes
parentc1ac7524bdf08d1f9d5bbcb3f9b7cb979f76a8c6 (diff)
Added changes to Kachelmann so he can notify you when the weather
changes
Diffstat (limited to 'kachelmann/changes')
-rw-r--r--kachelmann/changes31
1 files changed, 31 insertions, 0 deletions
diff --git a/kachelmann/changes b/kachelmann/changes
new file mode 100644
index 00000000..dfd22b64
--- /dev/null
+++ b/kachelmann/changes
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+use XML::Simple;
+my $xml = new XML::Simple;
+my $data_new = undef;
+my $data_old = undef;
+
+
+&startup;
+while (true) {
+ if($status_new != $status_old){
+ system("espeak -v de \"Das Wetter hat sich von $status_old in $status_new verändert\"");
+ }
+ sleep(300);
+ &get_status;
+}
+
+
+# The startup sub is used to get the first weather state. it should only be used on startup. sorry.
+sub startup(){
+ system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
+ $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml");
+ $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data};
+}
+
+# The get_status sub moves the current data to $data_old and then gets a new one from Googles API
+sub get_status(){
+ system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
+ $data_old = $data_new;
+ $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml");
+ $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data};
+}