mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 20:24:36 +00:00
Twilight, Heating_Control, WeekdayTimer
Twilight, - minor bugfix in logging Heating_Control, - set command for enabel/disable + new Reading disabled added WeekdayTimer - set command for enabel/disable + new Reading disabled added git-svn-id: https://svn.fhem.de/fhem/trunk@5946 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c2092f6c0d
commit
23b25c141c
@ -361,8 +361,10 @@ sub Twilight_fireEvent($)
|
|||||||
|
|
||||||
my $nextEvent = $hash->{TW}{$sx}{NEXTE};
|
my $nextEvent = $hash->{TW}{$sx}{NEXTE};
|
||||||
my $nextEventTime = "undefined";
|
my $nextEventTime = "undefined";
|
||||||
$nextEventTime = strftime("%H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})) if ($hash->{TW}{$nextEvent}{TIME} ne "nan");
|
if ($hash->{TW}{$nextEvent}{TIME} ne "nan") {
|
||||||
Log3 $hash, 4, "[".$hash->{NAME}."] " . sprintf ("%-10s state=%-2s light=%-2s nextEvent=%-10s %-14s deg=%+.1f°",$sx, $state, $light, $nextEvent, strftime("%d.%m.%Y %H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})), $deg);
|
$nextEventTime = strftime("%H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME}));
|
||||||
|
Log3 $hash, 4, "[".$hash->{NAME}."] " . sprintf ("%-10s state=%-2s light=%-2s nextEvent=%-10s %-14s deg=%+.1f°",$sx, $state, $light, $nextEvent, strftime("%d.%m.%Y %H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})), $deg);
|
||||||
|
}
|
||||||
|
|
||||||
my $eventTime = $hash->{TW}{$sx}{TIME};
|
my $eventTime = $hash->{TW}{$sx}{TIME};
|
||||||
my $now = time();
|
my $now = time();
|
||||||
|
@ -39,14 +39,34 @@ sub Heating_Control_Initialize($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Consumer
|
# Consumer
|
||||||
|
$hash->{SetFn} = "Heating_Control_Set";
|
||||||
$hash->{DefFn} = "Heating_Control_Define";
|
$hash->{DefFn} = "Heating_Control_Define";
|
||||||
$hash->{UndefFn} = "Heating_Control_Undef";
|
$hash->{UndefFn} = "Heating_Control_Undef";
|
||||||
$hash->{GetFn} = "Heating_Control_Get";
|
$hash->{GetFn} = "Heating_Control_Get";
|
||||||
|
$hash->{AttrFn} = "Heating_Control_Attr";
|
||||||
$hash->{UpdFn} = "Heating_Control_Update";
|
$hash->{UpdFn} = "Heating_Control_Update";
|
||||||
$hash->{AttrList}= "disable:0,1 windowSensor ".
|
$hash->{AttrList}= "disable:0,1 windowSensor ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
sub Heating_Control_Set($@) {
|
||||||
|
my ($hash, @a) = @_;
|
||||||
|
return "no set value specified" if(int(@a) < 2);
|
||||||
|
return "Unknown argument $a[1], choose one of enable/disable refresh" if($a[1] eq "?");
|
||||||
|
|
||||||
|
my $name = shift @a;
|
||||||
|
my $v = join(" ", @a);
|
||||||
|
|
||||||
|
Log3 $hash, 3, "[$name] set $name $v";
|
||||||
|
|
||||||
|
if ($v eq "enable") {
|
||||||
|
fhem("attr $name disable 1");
|
||||||
|
} elsif ($v eq "disable") {
|
||||||
|
fhem("attr $name disable 1");
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
sub Heating_Control_Get($@)
|
sub Heating_Control_Get($@)
|
||||||
{
|
{
|
||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
@ -461,7 +481,7 @@ sub Heating_Control_Device_Schalten($$$$) {
|
|||||||
my $mod = "[".$hash->{NAME} ."] "; ###
|
my $mod = "[".$hash->{NAME} ."] "; ###
|
||||||
|
|
||||||
#modifier des Zieldevices auswaehlen
|
#modifier des Zieldevices auswaehlen
|
||||||
my $setModifier = isHeizung($hash);
|
my $setModifier = Heating_Control_isHeizung($hash);
|
||||||
|
|
||||||
# Kommando aufbauen
|
# Kommando aufbauen
|
||||||
if (defined $hash->{helper}{CONDITION}) {
|
if (defined $hash->{helper}{CONDITION}) {
|
||||||
@ -513,7 +533,17 @@ sub Heating_Control_Device_Schalten($$$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
########################################################################
|
########################################################################
|
||||||
sub isHeizung($) {
|
sub Heating_Control_Attr($$$) {
|
||||||
|
my ($cmd, $name, $attrName, $attrVal) = @_;
|
||||||
|
|
||||||
|
if( $attrName eq "disable" ) {
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
readingsSingleUpdate ($hash, "disabled", $attrVal, 1);
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
########################################################################
|
||||||
|
sub Heating_Control_isHeizung($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
my %setmodifiers =
|
my %setmodifiers =
|
||||||
@ -532,8 +562,8 @@ sub isHeizung($) {
|
|||||||
"HM-CC-RT-DN" => 1 } );
|
"HM-CC-RT-DN" => 1 } );
|
||||||
my $dHash = $defs{$hash->{DEVICE}}; ###
|
my $dHash = $defs{$hash->{DEVICE}}; ###
|
||||||
my $dType = $dHash->{TYPE};
|
my $dType = $dHash->{TYPE};
|
||||||
Log3 $hash, 5, "dType------------>$dType";
|
|
||||||
return "" if (!defined($dType));
|
return "" if (!defined($dType));
|
||||||
|
Log3 $hash, 5, "dType------------>$dType";
|
||||||
|
|
||||||
my $setModifier = $setmodifiers{$dType};
|
my $setModifier = $setmodifiers{$dType};
|
||||||
$setModifier = "" if (!defined($setModifier));
|
$setModifier = "" if (!defined($setModifier));
|
||||||
@ -654,6 +684,49 @@ sub SortNumber {
|
|||||||
by well-known Block with {}.<br>
|
by well-known Block with {}.<br>
|
||||||
Note: if a command is defined only this command are executed. In case of executing
|
Note: if a command is defined only this command are executed. In case of executing
|
||||||
a "set desired-temp" command, you must define it explicitly.<br>
|
a "set desired-temp" command, you must define it explicitly.<br>
|
||||||
|
<!-- -------------------------------------------------------------------------- -->
|
||||||
|
<!----------------------------------------------------------------------------- -->
|
||||||
|
<!-- -------------------------------------------------------------------------- -->
|
||||||
|
<li>in the command section you can access the event:
|
||||||
|
<ul>
|
||||||
|
<li>The variable $EVENT will contain the complete event, e.g.
|
||||||
|
<code>measured-temp: 21.7 (Celsius)</code></li>
|
||||||
|
<li>$EVTPART0,$EVTPART1,$EVTPART2,etc contain the space separated event
|
||||||
|
parts (e.g. <code>$EVTPART0="measured-temp:", $EVTPART1="21.7",
|
||||||
|
$EVTPART2="(Celsius)"</code>. This data is available as a local
|
||||||
|
variable in perl, as environment variable for shell scripts, and will
|
||||||
|
be textually replaced for FHEM commands.</li>
|
||||||
|
<li>$NAME contains the device to send the event, e.g.
|
||||||
|
<code>myFht</code></li>
|
||||||
|
</ul></li>
|
||||||
|
|
||||||
|
<li>Note: the following is deprecated and will be removed in a future
|
||||||
|
release. The described replacement is attempted if none of the above
|
||||||
|
variables ($NAME/$EVENT/etc) found in the command.
|
||||||
|
<ul>
|
||||||
|
<li>The character <code>%</code> will be replaced with the received
|
||||||
|
event, e.g. with <code>on</code> or <code>off</code> or
|
||||||
|
<code>measured-temp: 21.7 (Celsius)</code><br> It is advisable to put
|
||||||
|
the <code>%</code> into double quotes, else the shell may get a syntax
|
||||||
|
error.</li>
|
||||||
|
|
||||||
|
<li>The character <code>@</code> will be replaced with the device
|
||||||
|
name.</li>
|
||||||
|
|
||||||
|
<li>To use % or @ in the text itself, use the double mode (%% or
|
||||||
|
@@).</li>
|
||||||
|
|
||||||
|
<li>Instead of <code>%</code> and <code>@</code>, the parameters
|
||||||
|
<code>%EVENT</code> (same as <code>%</code>), <code>%NAME</code> (same
|
||||||
|
as <code>@</code>) and <code>%TYPE</code> (contains the device type,
|
||||||
|
e.g. <code>FHT</code>) can be used. The space separated event "parts"
|
||||||
|
are available as %EVTPART0, %EVTPART1, etc. A single <code>%</code>
|
||||||
|
looses its special meaning if any of these parameters appears in the
|
||||||
|
definition.</li>
|
||||||
|
</ul></li>
|
||||||
|
<!-- -------------------------------------------------------------------------- -->
|
||||||
|
<!----------------------------------------------------------------------------- -->
|
||||||
|
<!-- -------------------------------------------------------------------------- -->
|
||||||
The following parameter are replaced:<br>
|
The following parameter are replaced:<br>
|
||||||
<ol>
|
<ol>
|
||||||
<li>@ => the device to switch</li>
|
<li>@ => the device to switch</li>
|
||||||
@ -806,7 +879,22 @@ sub SortNumber {
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="Heating_Controlset"></a>
|
<a name="Heating_Controlset"></a>
|
||||||
<b>Set</b> <ul>N/A</ul><br>
|
<b>Set</b>
|
||||||
|
|
||||||
|
<code><b><font size="+1">set <name> <value></font></b></code>
|
||||||
|
<br><br>
|
||||||
|
where <code>value</code> is one of:<br>
|
||||||
|
<pre>
|
||||||
|
<b>enable</b> # enables the Heating_Control
|
||||||
|
<b>disable</b> # disables the Heating_Control
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<b><font size="+1">Examples</font></b>:
|
||||||
|
<ul>
|
||||||
|
<code>set hc disable</code><br>
|
||||||
|
<code>set hc enable</code><br>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<a name="Heating_Controlget"></a>
|
<a name="Heating_Controlget"></a>
|
||||||
<b>Get</b> <ul>N/A</ul><br>
|
<b>Get</b> <ul>N/A</ul><br>
|
||||||
|
@ -25,8 +25,7 @@ package main;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
|
########################################################################
|
||||||
#####################################
|
|
||||||
sub WeekdayTimer_Initialize($)
|
sub WeekdayTimer_Initialize($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
@ -37,6 +36,8 @@ sub WeekdayTimer_Initialize($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Consumer
|
# Consumer
|
||||||
|
$hash->{SetFn} = "WeekdayTimer_Set";
|
||||||
|
$hash->{AttrFn} = "WeekdayTimer_Attr";
|
||||||
$hash->{DefFn} = "WeekdayTimer_Define";
|
$hash->{DefFn} = "WeekdayTimer_Define";
|
||||||
$hash->{UndefFn} = "WeekdayTimer_Undef";
|
$hash->{UndefFn} = "WeekdayTimer_Undef";
|
||||||
$hash->{GetFn} = "WeekdayTimer_Get";
|
$hash->{GetFn} = "WeekdayTimer_Get";
|
||||||
@ -44,12 +45,21 @@ sub WeekdayTimer_Initialize($)
|
|||||||
$hash->{AttrList}= "disable:0,1 ".
|
$hash->{AttrList}= "disable:0,1 ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
################################################################################
|
||||||
|
sub WeekdayTimer_Set($@) {
|
||||||
|
my ($hash, @a) = @_;
|
||||||
|
return "no set value specified" if(int(@a) < 2);
|
||||||
|
return "Unknown argument $a[1], choose one of enable/disable refresh" if($a[1] eq "?");
|
||||||
|
|
||||||
|
Heating_Control_Set($@);
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
########################################################################
|
||||||
sub WeekdayTimer_Get($@) {
|
sub WeekdayTimer_Get($@) {
|
||||||
return Heating_Control_Get($@);
|
return Heating_Control_Get($@);
|
||||||
}
|
}
|
||||||
|
########################################################################
|
||||||
|
|
||||||
sub WeekdayTimer_Define($$){
|
sub WeekdayTimer_Define($$){
|
||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
|
|
||||||
@ -57,22 +67,32 @@ sub WeekdayTimer_Define($$){
|
|||||||
$hash->{helper}{DESIRED_TEMP_READING} = "";
|
$hash->{helper}{DESIRED_TEMP_READING} = "";
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
########################################################################
|
||||||
sub WeekdayTimer_Undef($$){
|
sub WeekdayTimer_Undef($$){
|
||||||
my ($hash, $arg) = @_;
|
my ($hash, $arg) = @_;
|
||||||
return Heating_Control_Undef($hash, $arg);
|
return Heating_Control_Undef($hash, $arg);
|
||||||
}
|
}
|
||||||
|
########################################################################
|
||||||
sub WeekdayTimer_UpdatePerlTime($) {
|
sub WeekdayTimer_UpdatePerlTime($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
Heating_Control_UpdatePerlTime($hash);
|
Heating_Control_UpdatePerlTime($hash);
|
||||||
}
|
}
|
||||||
|
########################################################################
|
||||||
sub WeekdayTimer_Update($){
|
sub WeekdayTimer_Update($){
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
return Heating_Control_Update($hash);
|
return Heating_Control_Update($hash);
|
||||||
}
|
}
|
||||||
#
|
########################################################################
|
||||||
|
sub WeekdayTimer_Attr($$$) {
|
||||||
|
my ($cmd, $name, $attrName, $attrVal) = @_;
|
||||||
|
|
||||||
|
if( $attrName eq "disable" ) {
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
readingsSingleUpdate ($hash, "disabled", $attrVal, 1);
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
########################################################################
|
||||||
sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()}
|
sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()}
|
||||||
|
|
||||||
foreach my $hc ( sort keys %{$modules{WeekdayTimer}{defptr}} ) {
|
foreach my $hc ( sort keys %{$modules{WeekdayTimer}{defptr}} ) {
|
||||||
@ -169,7 +189,22 @@ sub WeekdayTimer_SetAllParms() { # {WeekdayTimer_SetAllParms()}
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="WeekdayTimerset"></a>
|
<a name="WeekdayTimerset"></a>
|
||||||
<b>Set</b> <ul>N/A</ul><br>
|
<b>Set</b>
|
||||||
|
|
||||||
|
<code><b><font size="+1">set <name> <value></font></b></code>
|
||||||
|
<br><br>
|
||||||
|
where <code>value</code> is one of:<br>
|
||||||
|
<pre>
|
||||||
|
<b>disable</b> # disables the Weekday_Timer
|
||||||
|
<b>enable</b> # enables the Weekday_Timer
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<b><font size="+1">Examples</font></b>:
|
||||||
|
<ul>
|
||||||
|
<code>set wd disable</code><br>
|
||||||
|
<code>set wd enable</code><br>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<a name="WeekdayTimerget"></a>
|
<a name="WeekdayTimerget"></a>
|
||||||
<b>Get</b> <ul>N/A</ul><br>
|
<b>Get</b> <ul>N/A</ul><br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user