# $Id$
##############################################################################
#
# 98_Heating_Control.pm
# written by Dietmar Ortmann
# Maintained by igami since 02-2018
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see
define <name> Heating_Control <device> [<language>] [weekdays] <profile> [<command>|<condition>]
set <device> (desired-temp|desiredTemperature) <temp>
The following parameter are defined:
Examples:
define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|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 $NAME desired-temp $EVENT");}
At the given times and weekdays only(!) the command will be executed.
define HCW Heating_Control WZ_Heizung Sa-Su,We|08:00|21 (ReadingsVal("WeAreThere", "state", "no") eq "yes")
The temperature is only set if the dummy variable WeAreThere is "yes".
define HCW Heating_Control WZ_Heizung en Su-Fr|{sunrise_abs()}|21 Mo-Fr|{sunset_abs()}|16
The device is switched at sunrise/sunset. Language: english.
define HCW Heating_Control WZ_Heizung en Mo-Fr|{myFunction}|night-temp:18 Mo-Fr|{myFunction()}|dayTemp:16
The is switched at time myFunction(). It is sent the Command "night-temp 18" and "dayTemp 16".
If you want to have set all Heating_Controls their current value (after a temperature lowering phase holidays)
you can call the function Heating_Control_SetTemp("HC-device") or Heating_Control_SetAllTemps().
This call can be automatically coupled to a dummy by a notify:
define HeizStatus2 notify Heating:. * {Heating_Control_SetAllTemps()}
Some definitions without comment:
the list of days can be set globaly for the whole Heating_Control:
define hc Heating_Control HeizungKueche de 7|23:35|25 34|23:30|22 23:30|16 23:15|22 8|23:45|16
define hc Heating_Control HeizungKueche de fr,$we|23:35|25 34|23:30|22 23:30|16 23:15|22 12|23:45|16
define hc Heating_Control HeizungKueche de 20:35|25 34|14:30|22 21:30|16 21:15|22 12|23:00|16
define hw Heating_Control HeizungKueche de mo-so, $we|{sunrise_abs_dat($date)}|18 mo-so, $we|{sunset_abs_dat($date)}|22
define ht Heating_Control HeizungKueche de mo-so,!$we|{sunrise_abs_dat($date)}|18 mo-so,!$we|{sunset_abs_dat($date)}|22
define hh Heating_Control HeizungKueche de {sunrise_abs_dat($date)}|19 {sunset_abs_dat($date)}|21
define hx Heating_Control HeizungKueche de 22:35|25 23:00|16
An example to be able to temporarily boost the temperature for one hour:
define HeizungWohnen_an_wt Heating_Control HeizungWohnen de !$we 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de $we 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de 78 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de 57 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de fr,$we 09:00|19 (heizungAnAus("Ein"))
and using a "HeatingBath_Boost" dummy variable:
define hc Heating_Control HeatingBath de !$we|05:00|{HC_WithBoost(23,"HeatingBath")} $we|07:00|{HC_WithBoost(23,"HeatingBath")} 23:00|{HC_WithBoost(20,"HeatingBath")}
and the perl subroutine in 99_myUtils.pm (or the like)
define HeatingBath_Boost dummy
attr HeatingBath_Boost setList state:0,23,24,25
attr HeatingBath_Boost webCmd state
define di_ResetBoostBath DOIF ([HeatingBath_Boost] > 0)
({Heating_Control_SetAllTemps()}, defmod di_ResetBoostBath_Reset at +01:00:00 set HeatingBath_Boost 0)
DOELSE
({Heating_Control_SetAllTemps()})
attr di_ResetBoostBath do always
Now you can set "HeatingBath_Boost" in the web interface for a one-hour boost of 3 degrees in the bath.
(you can trigger that using the PRESENCE function using your girlfriend's device... grin).
Easy to extend this with a vacation timer using another dummy variable, here
sub HC_BathWithBoost {
my $numParams = @_;
my ($degree, $boostPrefix) = @_;
if ($numParams > 1)
{
my $boost = ReadingsVal($boostPrefix . "_Boost", "state", "0");
return $boost if ($boost =~ m/^\d+$/) && ($boost > 0); # boost?
}
return $degree; # otherwise return given temperature
}
VacationTemp
.
Then you can use the command
defmod defVacationEnd at 2016-12-30T00:00:00 set VacationTemp off, {Heating_Control_SetAllTemps()}
to stop the vacation temperature before you return in january 2017 and let the appartment heat up again.
Pray that the device does not restart during your vacation, as the
sub HC_BathWithBoost($) {
my $vacation = ReadingsVal("VacationTemp", "state", "unfortunately not on vacation");
return $vacation if $vacation =~ /^(\d+|eco)$/; # set vacation temperature if given
my $numParams = @_;
my ($degree, $boostPrefix) = @_;
if ($numParams > 1)
{
my $boost = ReadingsVal($boostPrefix . "_Boost", "state", "0");
return $boost if ($boost =~ m/^\d+$/) && ($boost > 0); # boost?
}
}
define defVacationEnd ... at
is volatile and will be lost at restart!
attr hc delayedExecutionCond isDelayed("%HEATING_CONTROL","%WEEKDAYTIMER","%TIME","%NAME","%EVENT")the parameters %HEATING_CONTROL(timer name) %TIME %NAME(device name) %EVENT are replaced at runtime by the correct value.
sub isDelayed($$$$$) { my($hc, $wdt, $tim, $nam, $event ) = @_; my $theSunIsStillshining = ... return ($tim eq "16:30" && $theSunIsStillshining) ; }
define <name> Heating_Control <device> [<language>] <wochentage;] <profile> <command>|<condition>
set <device> (desired-temp|desiredTemperature) <temp>
Folgende Parameter sind im Define definiert:
Beispiele:
define HCW Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|eco
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 $NAME desired-temp $EVENT");}
Zu den definierten Schaltzeiten wird nur(!) der in {} angegebene Perl-Code ausgeführt.
define HCW Heating_Control WZ_Heizung Sa-So,Mi|08:00|21 (ReadingsVal("WeAreThere", "state", "no") eq "yes")
Die zu setzende Temperatur wird nur gesetzt, falls die Dummy Variable WeAreThere = "yes" ist.
define HCW Heating_Control WZ_Heizung en Su-Fr|{sunrise_abs()}|21 Mo-Fr|{sunset_abs()}|16
Das Gerät wird bei Sonnenaufgang und Sonnenuntergang geschaltet. Sprache: Englisch.
define HCW Heating_Control WZ_Heizung en Mo-Fr|{myFunction}|night-temp:18 Mo-Fr|{myFunction()}|dayTemp:16
Das Gerät wird bei myFunction() geschaltet. Es wird das Kommando "night-temp 18" bzw. "dayTemp 16" gesendet.
Wenn du beispielsweise nach einer Temperaturabsenkungsphase erreichen willst, dass alle Heating_Controls ihren aktuellen Wert einstellen sollen, kannst du die Funktion Heating_Control_SetTemp("HC-device") or Heating_Control_SetAllTemps() aufrufen.
Dieser Aufruf kann per notify automatisch an ein dummy gekoppelt werden:
define HeizStatus2 notify Heizung:.* {Heating_Control_SetAllTemps()}
Einige Definitionen ohne weitere Erklärung:
Die Tagesliste kann global für das ganze Heating_Control angegeben werden:
define hc Heating_Control HeizungKueche de 7|23:35|25 34|23:30|22 23:30|16 23:15|22 8|23:45|16
define hc Heating_Control HeizungKueche de fr,$we|23:35|25 34|23:30|22 23:30|16 23:15|22 12|23:45|16
define hc Heating_Control HeizungKueche de 20:35|25 34|14:30|22 21:30|16 21:15|22 12|23:00|16
define hw Heating_Control HeizungKueche de mo-so, $we|{sunrise_abs_dat($date)}|18 mo-so, $we|{sunset_abs_dat($date)}|22
define ht Heating_Control HeizungKueche de mo-so,!$we|{sunrise_abs_dat($date)}|18 mo-so,!$we|{sunset_abs_dat($date)}|22
define hh Heating_Control HeizungKueche de {sunrise_abs_dat($date)}|19 {sunset_abs_dat($date)}|21
define hx Heating_Control HeizungKueche de 22:35|25 23:00|16
es ist möglich den Parameter als Perlcode zu spezifizieren:
define HeizungWohnen_an_wt Heating_Control HeizungWohnen de !$we 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de $we 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de 78 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de 57 09:00|19 (heizungAnAus("Ein"))
define HeizungWohnen_an_we Heating_Control HeizungWohnen de fr,$we 09:00|19 (heizungAnAus("Ein"))
ein detailiertes Beispiel ist in Heating_Control(EN) beschrieben
... 7|23:35|{getParameter(13,"this")} 7|23:36|{getParameter(14,"that")}
set <name> <value>
value
is one of:enable # enables the Heating_Control disable # disables the Heating_ControlExamples:
set hc disable
set hc enable
attr wd delayedExecutionCond isDelayed("$HEATING_CONTROL","$WEEKDAYTIMER","$TIME","$NAME","$EVENT")Die Parameter $HEATING_CONTROL(timer Name) $TIME $NAME(device Name) $EVENT werden zur Laufzeit durch die echten Werte ersetzt.
sub isDelayed($$$$$) { my($hc, $wdt, $tim, $nam, $event ) = @_; my $theSunIsStillshining = ... return ($tim eq "16:30" && $theSunIsStillshining) ; }