mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
95_holiday.pm: add Link for editing the .holiday file (Forum #81527)
fhem.pl: holiday2we may contain a comma separated list of holiday files git-svn-id: https://svn.fhem.de/fhem/trunk@15710 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6c7115e66e
commit
46de1dcc10
@ -2255,8 +2255,7 @@ FW_style($$)
|
|||||||
$ret = FW_fC("reload $fileName") if($fileName =~ m,\.pm$,);
|
$ret = FW_fC("reload $fileName") if($fileName =~ m,\.pm$,);
|
||||||
$ret = FW_Set("","","rereadicons") if($isImg);
|
$ret = FW_Set("","","rereadicons") if($isImg);
|
||||||
DoTrigger("global", "FILEWRITE $filePath", 1) if(!$ret); # Forum #32592
|
DoTrigger("global", "FILEWRITE $filePath", 1) if(!$ret); # Forum #32592
|
||||||
$ret = ($ret ? "<h3>ERROR:</h3><b>$ret</b>" :
|
$ret = ($ret ? "<h3>ERROR:</h3><b>$ret</b>" : "Saved $fileName");
|
||||||
"Saved the file $fileName to $forceType");
|
|
||||||
FW_style("style list", $ret);
|
FW_style("style list", $ret);
|
||||||
$ret = "";
|
$ret = "";
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ holiday_Initialize($)
|
|||||||
$hash->{SetFn} = "holiday_Set";
|
$hash->{SetFn} = "holiday_Set";
|
||||||
$hash->{UndefFn} = "holiday_Undef";
|
$hash->{UndefFn} = "holiday_Undef";
|
||||||
$hash->{AttrList} = $readingFnAttributes;
|
$hash->{AttrList} = $readingFnAttributes;
|
||||||
|
$hash->{FW_detailFn} = "holiday_FW_detailFn";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -228,17 +229,38 @@ sub
|
|||||||
holiday_Set($@)
|
holiday_Set($@)
|
||||||
{
|
{
|
||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
|
my %sets = (
|
||||||
|
createPrivateCopy => $hash->{READONLY},
|
||||||
|
deletePrivateCopy => !$hash->{READONLY},
|
||||||
|
reload => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
return "unknown argument $a[1], choose one of ".
|
||||||
|
join(" ", map { "$_:noArg" }
|
||||||
|
grep { $sets{$_} } keys %sets) if(!$sets{$a[1]});
|
||||||
|
|
||||||
return "unknown argument $a[1], choose one of createPrivateCopy:noArg"
|
if($a[1] eq "createPrivateCopy") {
|
||||||
if($a[1] ne "createPrivateCopy");
|
return "Already a private version" if(!$hash->{READONLY});
|
||||||
return "Already a private version" if(!$hash->{READONLY});
|
my $fname = $attr{global}{modpath}."/FHEM/holiday/$hash->{NAME}.holiday";
|
||||||
my $fname = $attr{global}{modpath}."/FHEM/holiday/$hash->{NAME}.holiday";
|
my ($err, @holidayfile) = FileRead($fname);
|
||||||
my ($err, @holidayfile) = FileRead($fname);
|
return $err if($err);
|
||||||
return $err if($err);
|
$fname = $attr{global}{modpath}."/FHEM/$hash->{NAME}.holiday";
|
||||||
$fname = $attr{global}{modpath}."/FHEM/$hash->{NAME}.holiday";
|
$err = FileWrite($fname, @holidayfile);
|
||||||
$err = FileWrite($fname, @holidayfile);
|
return $err if($err);
|
||||||
holiday_refresh($hash->{NAME});
|
holiday_refresh($hash->{NAME});
|
||||||
return $err;
|
|
||||||
|
} elsif($a[1] eq "deletePrivateCopy") {
|
||||||
|
|
||||||
|
return "Not a private version" if($hash->{READONLY});
|
||||||
|
my $err = FileDelete($attr{global}{modpath}."/FHEM/$hash->{NAME}.holiday");
|
||||||
|
return $err if($err);
|
||||||
|
holiday_refresh($hash->{NAME});
|
||||||
|
|
||||||
|
} elsif($a[1] eq "reload") {
|
||||||
|
holiday_refresh($hash->{NAME});
|
||||||
|
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -311,6 +333,17 @@ western_easter($)
|
|||||||
|
|
||||||
return $month, $day;
|
return $month, $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
holiday_FW_detailFn($$$$)
|
||||||
|
{
|
||||||
|
my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
|
||||||
|
|
||||||
|
return "" if($defs{$d}{READONLY});
|
||||||
|
return FW_pH("cmd=style edit $d.holiday",
|
||||||
|
"<div class=\"dval\">Edit $d.holiday</div>", 0, "dval", 1);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
@ -329,8 +362,9 @@ western_easter($)
|
|||||||
Define a set of holidays. The module will try to open the file
|
Define a set of holidays. The module will try to open the file
|
||||||
<name>.holiday in the <a href="#modpath">modpath</a>/FHEM directory
|
<name>.holiday in the <a href="#modpath">modpath</a>/FHEM directory
|
||||||
first, then in the modpath/FHEM/holiday directory, the latter containing a
|
first, then in the modpath/FHEM/holiday directory, the latter containing a
|
||||||
set of predefined files. The set will be shown if an error occures at the
|
set of predefined files. This list of available holiday files will be shown
|
||||||
time of the definietion.<br>
|
if an error occurs at the time of the definition, e.g. if you type "define
|
||||||
|
help holiday"<br>
|
||||||
|
|
||||||
If entries in the holiday file match the current day, then the STATE of
|
If entries in the holiday file match the current day, then the STATE of
|
||||||
this holiday instance displayed in the <a href="#list">list</a> command
|
this holiday instance displayed in the <a href="#list">list</a> command
|
||||||
@ -409,6 +443,15 @@ western_easter($)
|
|||||||
modified. With createPrivateCopy the file will be copied to the FHEM
|
modified. With createPrivateCopy the file will be copied to the FHEM
|
||||||
directory, where it can be modified.
|
directory, where it can be modified.
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<li>deletePrivateCopy<br>
|
||||||
|
<ul>
|
||||||
|
delete the private copy, see createPrivateCopy above
|
||||||
|
</ul></li>
|
||||||
|
<li>reload<br>
|
||||||
|
<ul>
|
||||||
|
set the state, tomorrow and yesterday readings. Useful after manually
|
||||||
|
editing the file.
|
||||||
|
</ul></li>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="holidayget"></a>
|
<a name="holidayget"></a>
|
||||||
@ -446,7 +489,7 @@ western_easter($)
|
|||||||
Datei <name>.holiday erst in <a href="#modpath">modpath</a>/FHEM zu
|
Datei <name>.holiday erst in <a href="#modpath">modpath</a>/FHEM zu
|
||||||
öffnen, und dann in modpath/FHEM/holiday, Letzteres enthält eine
|
öffnen, und dann in modpath/FHEM/holiday, Letzteres enthält eine
|
||||||
Liste von per FHEM-update verteilten Dateien für diverse
|
Liste von per FHEM-update verteilten Dateien für diverse
|
||||||
(Bundes-)Länder. Diese Liste wird bei einer Feherlmeldung angezeigt.
|
(Bundes-)Länder. Diese Liste wird bei einer Fehlermeldung angezeigt.
|
||||||
|
|
||||||
Wenn Einträge im der Datei auf den aktuellen Tag passen wird der STATE
|
Wenn Einträge im der Datei auf den aktuellen Tag passen wird der STATE
|
||||||
der Holiday-Instanz die im <a href="#list">list</a> Befehl angezeigt wird
|
der Holiday-Instanz die im <a href="#list">list</a> Befehl angezeigt wird
|
||||||
@ -530,6 +573,15 @@ western_easter($)
|
|||||||
update aktualisiert wird. Mit createPrivateCopy kann eine private Kopie
|
update aktualisiert wird. Mit createPrivateCopy kann eine private Kopie
|
||||||
im FHEM Verzeichnis erstellt werden.
|
im FHEM Verzeichnis erstellt werden.
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<li>deletePrivateCopy<br>
|
||||||
|
<ul>
|
||||||
|
Entfernt die private Kopie, siehe auch createPrivateCopy
|
||||||
|
</ul></li>
|
||||||
|
<li>reload<br>
|
||||||
|
<ul>
|
||||||
|
setzt die state, tomorrow und yesterday Readings. Wird nach einem
|
||||||
|
manuellen Bearbeiten der .holiday Datei benötigt.
|
||||||
|
</ul></li>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="holidayget"></a>
|
<a name="holidayget"></a>
|
||||||
|
@ -1459,9 +1459,11 @@ The following local attributes are used by a wider range of devices:
|
|||||||
If this attribute is set, then the <a href="#perl">$we</a> variable
|
If this attribute is set, then the <a href="#perl">$we</a> variable
|
||||||
will be true, if the value of the <a href="#holiday">holiday</a>
|
will be true, if the value of the <a href="#holiday">holiday</a>
|
||||||
variable referenced by this attribute is not none.<br>
|
variable referenced by this attribute is not none.<br>
|
||||||
|
If it is a comma separated list, then it is true, if one of the
|
||||||
|
referenced entities is not none.<br>
|
||||||
Example:<br>
|
Example:<br>
|
||||||
<ul>
|
<ul>
|
||||||
attr global holiday2we hessen
|
attr global holiday2we he
|
||||||
</ul>
|
</ul>
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
@ -1557,6 +1557,8 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
href="#perl">$we</a> Variable als "true" betrachtet, wenn der
|
href="#perl">$we</a> Variable als "true" betrachtet, wenn der
|
||||||
Wert der <a href="#holiday">holiday</a> Variable zu diesem Attribut
|
Wert der <a href="#holiday">holiday</a> Variable zu diesem Attribut
|
||||||
nicht "none" ist.<br>
|
nicht "none" ist.<br>
|
||||||
|
Falls es eine Komma getrennte Liste ist, dann ist es wahr, falls einer
|
||||||
|
der referenzierten Instanzen nicht "none" ist.<br>
|
||||||
Beispiel:<br>
|
Beispiel:<br>
|
||||||
<ul>
|
<ul>
|
||||||
attr global holiday2we hessen
|
attr global holiday2we hessen
|
||||||
|
@ -1049,10 +1049,9 @@ AnalyzePerlCommand($$;$)
|
|||||||
my $hms = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
|
my $hms = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
|
||||||
my $we = (($wday==0 || $wday==6) ? 1 : 0);
|
my $we = (($wday==0 || $wday==6) ? 1 : 0);
|
||||||
if(!$we) {
|
if(!$we) {
|
||||||
my $h2we = $attr{global}{holiday2we};
|
foreach my $h2we (split(",", AttrVal("global", "holiday2we", ""))) {
|
||||||
if($h2we && Value($h2we)) {
|
|
||||||
my ($a, $b) = ReplaceEventMap($h2we, [$h2we, Value($h2we)], 0);
|
my ($a, $b) = ReplaceEventMap($h2we, [$h2we, Value($h2we)], 0);
|
||||||
$we = 1 if($b ne "none");
|
$we = 1 if($b && $b ne "none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$month++;
|
$month++;
|
||||||
@ -3884,7 +3883,7 @@ sub
|
|||||||
ReplaceEventMap($$$)
|
ReplaceEventMap($$$)
|
||||||
{
|
{
|
||||||
my ($dev, $str, $dir) = @_;
|
my ($dev, $str, $dir) = @_;
|
||||||
my $em = $attr{$dev}{eventMap};
|
my $em = AttrVal($dev, "eventMap", undef);
|
||||||
|
|
||||||
return $str if($dir && !$em);
|
return $str if($dir && !$em);
|
||||||
return @{$str} if(!$dir && (!$em || int(@{$str}) < 2 ||
|
return @{$str} if(!$dir && (!$em || int(@{$str}) < 2 ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user