From 3443359a5c21431dc8e1f461fa77b266b4713d83 Mon Sep 17 00:00:00 2001
From: dietmar63 <>
Date: Thu, 7 Mar 2013 21:25:03 +0000
Subject: [PATCH] 98_Heating_Control.pm - it is now possible to use symbolic
values like on, off, eco or comfort to switch devices
git-svn-id: https://svn.fhem.de/fhem/trunk@2868 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/98_Heating_Control.pm | 103 ++++++++++++++++++--------------
1 file changed, 57 insertions(+), 46 deletions(-)
diff --git a/fhem/FHEM/98_Heating_Control.pm b/fhem/FHEM/98_Heating_Control.pm
index dde4f3874..90aa21c64 100644
--- a/fhem/FHEM/98_Heating_Control.pm
+++ b/fhem/FHEM/98_Heating_Control.pm
@@ -132,18 +132,18 @@ Heating_Control_Define($$)
$dayNumber{$day} = $idx; $idx++;
}
- my (@st, @days, $daylist, $time, $temp, $englisch);
+ my (@st, @days, $daylist, $time, $para, $englisch);
for(my $i=0; $i<@switchingtimes; $i++) {
@st = split(/\|/, $switchingtimes[$i]);
if ( @st == 2) {
$daylist = "1234567"; #jeden Tag/woche ist vordefiniert
$time = $st[0];
- $temp = $st[1];
+ $para = $st[1];
} elsif ( @st == 3) {
$daylist = lc($st[0]);
$time = $st[1];
- $temp = $st[2];
+ $para = $st[2];
}
my %hdays=();
@@ -188,12 +188,12 @@ Heating_Control_Define($$)
return "invalid time in $name <$time> HH:MM"
if(!($time =~ m/^[0-2][0-9]:[0-5][0-9]$/g));
- return "invalid temperature in $name <$temp> 99.9"
- if(!($temp =~ m/^\d{1,2}(\.\d){0,1}$/g));
+ #return "invalid temperature in $name <$para> 99.9"
+ # if(!($para =~ m/^\d{1,2}(\.\d){0,1}$/g));
for (my $d=0; $d<@days; $d++) {
- #Log 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $temp ";
- $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$time} = $temp;
+ #Log 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $para ";
+ $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$time} = $para;
}
}
@@ -217,8 +217,8 @@ Heating_Control_Define($$)
# Profile sortiert aufbauen
for (my $d=1; $d<=7; $d++) {
foreach my $st (sort (keys %{ $hash->{helper}{SWITCHINGTIME}{$d} })) {
- my $temp = $hash->{helper}{SWITCHINGTIME}{$d}{$st};
- $hash->{"PROFILE ".($d).": ".$$rWochentage[$d-1]} .= sprintf("%s: %.1f%s, ", $st, $temp, $unit);
+ my $para = $hash->{helper}{SWITCHINGTIME}{$d}{$st};
+ $hash->{"PROFILE ".($d).": ".$$rWochentage[$d-1]} .= sprintf("%s %s, ", $st, $para);
}
}
@@ -307,8 +307,8 @@ Heating_Control_Update($)
Log $loglevel, "NowSwitch: ".strftime('%d.%m.%Y %H:%M:%S',localtime($nowSwitch))." ; AktDesiredTemp: $AktDesiredTemp ; newDesTemperature: $newDesTemperature";
Log $loglevel, "NextSwitch=".strftime('%d.%m.%Y %H:%M:%S',localtime($nextSwitch));
-
- if ($nowSwitch gt "" && $AktDesiredTemp != $newDesTemperature) {
+
+ if ($nowSwitch gt "" && $AktDesiredTemp ne $newDesTemperature) {
if (defined $hash->{helper}{CONDITION}) {
$command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") if' . $hash->{helper}{CONDITION} . '}';
} elsif (defined $hash->{helper}{COMMAND}) {
@@ -317,7 +317,7 @@ Heating_Control_Update($)
$command = '{ fhem("set @ '.$hash->{helper}{DESIRED_TEMP_READING}.' %") }';
}
}
-
+
if ($command && AttrVal($hash->{NAME}, "disable", 0) == 0) {
$command =~ s/@/$hash->{DEVICE}/g;
$command =~ s/%/$newDesTemperature/g;
@@ -330,8 +330,8 @@ Heating_Control_Update($)
InternalTimer($nextSwitch, "Heating_Control_Update", $hash, 0);
readingsBeginUpdate($hash);
readingsBulkUpdate ($hash, "nextUpdate", strftime("%d.%m.%Y %H:%M:%S",localtime($nextSwitch)));
- readingsBulkUpdate ($hash, "nextValue", $nextDesTemperature . $unit);
- readingsBulkUpdate ($hash, "state", $newDesTemperature . $unit);
+ readingsBulkUpdate ($hash, "nextValue", $nextDesTemperature);
+ readingsBulkUpdate ($hash, "state", $newDesTemperature);
readingsEndUpdate ($hash, defined($hash->{LOCAL} ? 0 : 1));
return 1;
@@ -362,28 +362,34 @@ sub SortNumber {
define <name> Heating_Control <device> <profile> <command>|<condition>
- to set a weekly profile for <device>, eg. a heating sink. You can define different switchingtimes for every day.
- The new temperature is sent to the <device> automaticly with set <device> desired-temp <temp>
- if the device is a heating thermostat (FHT8b, MAX). Have you defined a <condition>
- and this condition is false if the switchingtime has reached, no command will executed.
+ to set a weekly profile for <device>, eg. a heating sink.
+ You can define different switchingtimes for every day.
+
+ The new temperature is sent to the <device> automatically with
+
+ set <device> (desired-temp|desiredTemerature) <temp>
+
+ Because of the fhem-type of structures, a structures of heating sinks is sent "desired-temp":
+ Use an explicit command if you have structures of MAX heating thermostats.
+ If you have defined a <condition> and this condition is false if the switchingtime has reached, no command will executed.
A other case is to define an own perl command with <command>.
The following parameter are defined: -
-
-
-
Example:
define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12
+ define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|eco
+ Mo-Fr are setting the temperature at 05:20 to 21°C, and at 05:25 to comfort.
+ Every day will be set the temperature at 17:20 to 21°C and 17:25 to eco.
define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Tu,Th-Fr|16:00|18.5 20:00|12
{fhem("set dummy on"); fhem("set @ desired-temp %");}
@@ -423,7 +429,7 @@ sub SortNumber {
Get
define <name> Heating_Control <device> <profile> <command>|<condition>
set <device> desired-temp <temp>
- dem Device mitgeteilt. Ist eine <condition> angegeben und ist zum Schaltpunkt der Ausdruck unwahr,
+ Bildet ein Wochenprofil für ein <device>, zb. Heizkörper, ab.set <device> (desired-temp|desiredTemerature) <temp>
Folgende Parameter sind im Define definiert: -
-
-
-
Beispiel:
define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|12 17:20|21 17:25|12
+ define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|eco
+ Mo-Fr wird die Temperatur um 05:20Uhr auf 21°C, und um 05:25Uhr auf comfort gesetzt.
+ Jeden Tag wird die Temperatur um 17:20Uhr auf 21°C und 17:25Uhr auf eco gesetzt.
define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Di,Mi|16:00|18.5 20:00|12
{fhem("set dummy on"); fhem("set @ desired-temp %");}
@@ -511,7 +522,7 @@ sub SortNumber {
Get