From ae8d9a69f03e7a1069e9d1d5ab1c74e09f8a6a66 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Wed, 15 Aug 2012 19:32:59 +0000 Subject: [PATCH] added set update added event for STATE renewal git-svn-id: https://svn.fhem.de/fhem/trunk@1802 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/59_Weather.pm | 21 +++++++++++++++++++-- fhem/docs/commandref.html | 6 ++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/59_Weather.pm b/fhem/FHEM/59_Weather.pm index af33d356a..173ba1f57 100755 --- a/fhem/FHEM/59_Weather.pm +++ b/fhem/FHEM/59_Weather.pm @@ -52,6 +52,7 @@ sub Weather_Initialize($) { $hash->{DefFn} = "Weather_Define"; $hash->{UndefFn} = "Weather_Undef"; $hash->{GetFn} = "Weather_Get"; + $hash->{SetFn} = "Weather_Set"; $hash->{AttrList}= "loglevel:0,1,2,3,4,5 localicons event-on-update-reading event-on-change-reading"; } @@ -215,7 +216,7 @@ sub Weather_GetUpdate($) my $val= "T: $temperature H: $humidity W: $wind"; Log GetLogLevel($hash->{NAME},4), "Weather ". $hash->{NAME} . ": $val"; $hash->{STATE}= $val; - + addEvent($hash, $val); readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); # DoTrigger, because sub is called by a timer instead of dispatch return 1; @@ -247,6 +248,23 @@ sub Weather_Get($@) { return "$a[0] $reading => $value"; } +################################### + +sub Weather_Set($@) { + my ($hash, @a) = @_; + + my $cmd= $a[1]; + + # usage check + if((@a == 2) && ($a[1] eq "update")) { + RemoveInternalTimer($hash); + Weather_GetUpdate($hash); + return undef; + } else { + return "Unknown argument $cmd, choose one of update"; + } +} + ##################################### sub Weather_Define($$) { @@ -330,7 +348,6 @@ WeatherIconIMGTag($$$) { } ##################################### -# This has to be modularized in the future. sub WeatherAsHtml($) { diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 24bd3d049..c7a22284e 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -5168,11 +5168,13 @@ To send the data, both send or write could be used.
Set
- Get