mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
added set <name> update
added event for STATE renewal git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1802 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
55560e6183
commit
c4f0484135
@ -52,6 +52,7 @@ sub Weather_Initialize($) {
|
|||||||
$hash->{DefFn} = "Weather_Define";
|
$hash->{DefFn} = "Weather_Define";
|
||||||
$hash->{UndefFn} = "Weather_Undef";
|
$hash->{UndefFn} = "Weather_Undef";
|
||||||
$hash->{GetFn} = "Weather_Get";
|
$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";
|
$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";
|
my $val= "T: $temperature H: $humidity W: $wind";
|
||||||
Log GetLogLevel($hash->{NAME},4), "Weather ". $hash->{NAME} . ": $val";
|
Log GetLogLevel($hash->{NAME},4), "Weather ". $hash->{NAME} . ": $val";
|
||||||
$hash->{STATE}= $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
|
readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); # DoTrigger, because sub is called by a timer instead of dispatch
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -247,6 +248,23 @@ sub Weather_Get($@) {
|
|||||||
return "$a[0] $reading => $value";
|
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($$) {
|
sub Weather_Define($$) {
|
||||||
@ -330,7 +348,6 @@ WeatherIconIMGTag($$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# This has to be modularized in the future.
|
|
||||||
sub
|
sub
|
||||||
WeatherAsHtml($)
|
WeatherAsHtml($)
|
||||||
{
|
{
|
||||||
|
@ -5168,11 +5168,13 @@ To send the data, both send or write could be used.<br>
|
|||||||
<a name="Weatherset"></a>
|
<a name="Weatherset"></a>
|
||||||
<b>Set </b>
|
<b>Set </b>
|
||||||
<ul>
|
<ul>
|
||||||
N/A
|
<code>set <name> 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>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
<a name="Weatherget"></a>
|
<a name="Weatherget"></a>
|
||||||
<b>Get</b>
|
<b>Get</b>
|
||||||
<ul>
|
<ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user