2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

added set <name> update

added event for STATE renewal

git-svn-id: https://svn.fhem.de/fhem/trunk@1802 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2012-08-15 19:32:59 +00:00
parent 5d624a92eb
commit ae8d9a69f0
2 changed files with 23 additions and 4 deletions

View File

@ -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($)
{

View File

@ -5168,11 +5168,13 @@ To send the data, both send or write could be used.<br>
<a name="Weatherset"></a>
<b>Set </b>
<ul>
N/A
<code>set &lt;name&gt; update</code><br><br>
Forces the retrieval of the weather data. The next automatic retrieval is scheduled to occur
<code>interval</code> seconds later.<br><br>
</ul>
<br>
<a name="Weatherget"></a>
<b>Get</b>
<ul>