Hallo Fruende …
Probier mal dies hier …
<?
/*
*******************************
IP-SYNCOM Event Scripting
*******************************
*/
//File: GetTemp.ips.php
//
if (!defined(sdefined)){
include_once("scripts/GlobalDefines.ips.php");
}
// ********** USER SETTINGS *******************************************
// see this file for additional explanation
$tempfilepath=__myhome."tempsettings.ini";
// use this switch weather or not to overrule general settings
// the effect is that if IPS-variable "__imhome" = true
// the default + (high) temperature is sent as the result of
// this function
$use_imhome = false;
// ********** END OF USER SETTINGS ************************************
//debug
#$thisinstanz = "vliv_temp";
//END DEBUG
// MODIFIE BEYOND THESE LINE ON OWN RISK
//
$ldebug = GetValueBoolean("__debug");
$handle=fopen("$tempfilepath", "r");
if (!$handle){
// error cannot open file
echo("ERROR : CANNOT OPEN FILE : '$tempfilepath'
");
}
$now = getdate();
$isholiday = false;
$holiday="";
$season = "";
$today="";
$alldays="";
$weekend="";
$imhome=false;
if ($use_imhome) $imhome = GetValueBoolean("__imhome");
while(!feof($handle)) {
$buffer = fgets($handle);
Switch (substr($buffer,0,1)) {
case "@":
//general settings
if (substr($buffer,1,7) == "season=") {
$season = substr($buffer,8,1);
}
if (substr($buffer,1,1) == "H") {
// HOLIDAY SCHEISS compare today with holidays
if (($now["mon"]."/".$now["mday"] == substr($buffer,2,-2)) or ($now["mon"]."/".$now["mday"]."/".$now["year"] == substr($buffer,2,-2))) {
$isholiday = true;
}
}
break;
case "D":
//DEFAULT lines
if (substr($buffer,1,1) == "$season") $default = substr($buffer,27,48);
break;
case "H":
//HOLIDAY table entries
if ($isholiday) {
if (substr($buffer,1,1) == "$season") $holiday = substr($buffer,27,48);
}
break;
case "I":
//Table entries
if (chop(substr($buffer,4,14)) == $thisinstanz) {
if ((substr($buffer,1,1) == "$season") and (substr($buffer,2,1) == "9")) $alldays = substr($buffer,27,48);
if ((substr($buffer,1,1) == "$season") and (substr($buffer,2,1) == "7") and (($now["wday"]+0) > 4)) $weekend = substr($buffer,27,48);
if ((substr($buffer,1,1) == "$season") and (substr($buffer,2,1) == $now["wday"])) $today = substr($buffer,27,48);
}
break;
default:
//only thing to expect are comments '#' and temp settings
if (substr($buffer,0,1) <> "#") {
$temp[substr($buffer,0,1)] = substr($buffer,1,5);
}
}
}
fclose($handle);
if ($ldebug) {
$thisday = $now["wday"];
echo("
RESULT
--------
");
echo("thisinstanz :'$thisinstanz'
");
echo("now :'". $now["hours"] .":". $now["minutes"] . "'
");
echo("today is nr# : $thisday
");
echo("season : $season
");
echo("Is it a holiday : $isholiday
");
echo("Check precendence hereunder
");
echo("holiday : $holiday
");
echo("today : $today
");
echo("weekends : $weekend
");
echo("alldays : $alldays
");
echo("default rule : $default
");
echo("Am I home ? : $imhome
");
if ($holiday == "") {
if ($today == "") {
if ($weekend == "") {
if ($alldays == "") {
$result = $default;
} else {
$result = $alldays;
}
} else {
$result = $weekend;
}
} else {
$result = $today;
}
} else {
$result = $holiday;
}
echo("I did choose : '$result'
");
// here we get the temperature out of string
$pos = $now["hours"]*2 + floor($now["minutes"]/30);
$soll = $temp[substr($result,$pos,1)];
if ($use_imhome and $imhome) {
$soll = $temp["+"];
$status = "OVERRULED set to";
} elseif ($use_imhome) {
$soll = $temp["-"];
$status = "OVERRULED set to";
} else {
$status = substr($result,$pos,1)." : ";
}
echo("SOLLwert $status'". $soll ."'
");
SetValueFloat("vliv_temp_soll",($soll+0));
?>
und weiter diesem datei : $__myhome/tempsettings.ini
# *******************
# * IPS Timetable *
# *******************
#
# by GGGss under GPL license
# 31/07/2005
# used in gettemp.ips.php version 0.1 rev 0
#
#
# lines starting with '#' are not taken into consideration
# these settings use 3 'chapters'
# * settings -> user definable settings
# * holidays -> the dates used to trigger 'H'-lines in timetable
# * timetable -> settings in a 30 min. timeframe
# * temperatures -> the symbols used in timetable get their values here
#
# ************ Settings *************
// season : S (summer) or W (winter)
@season=W
#
# ************* Holidays *****************
#
# Start the line with 'H' and date
# mm/dd for fixed dates (recurring every year)
# or mm/dd/yyyy
#
# BELGIAN HOLIDAYS
@H12/31 # Newyear's eve
@H01/01 # Newyear
@H03/20 # My birthday yihaah
@H05/01 # workers holiday
@H07/11 # Flemish holiday
@H07/21 # National holiday
@H11/01 # All saints
@H11/11 # End of WW1
@H12/25 # Christmasday
@H04/16/2006 # Easter
@H05/25/2006 # Jezus goes up the stairs ;-)
@H06/04/2006 # and orders the appostels to continue his work
@H08/15/2006 # Maria goes up the stairs
#
# ************ Time table *************
#
# Season : W for Winter; S for Summer; H for holiday rules
# Day : 0 to 6 for mo - su
# 7 for weekends (sa & su)
# 9 for everyday
# Sensor : name of the FHT 8(0)b to be triggered
# Use Symbols to fill the timetable
# they switch to corresponding temp. settings - > See #temperatures
# if it can't find an applicable rule it will take the Default 'D' one
# D = Default - ALWAYS USE
# (precedence rule)
# season & holiday -> season & day -> season & weekends -> season & everyday -> season & default
#
#Season T T H 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2
#| day 1 2 O 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
#|| sensor x x U 030303030303030303030303030303030303030303030303
#|| | x x R 000000000000000000000000000000000000000000000000
DS default x x --------------+++++------------------+++++++----
DW default x x -------------++++++----------------+++++++++----
IS9 vliv_temp x x |||||||||||||||OOO||||||||||||||||||XXXXXXXXX|||
IW2 vliv_temp x x OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
HS9 vliv_temp x x ||||||||||||||||XXXXOOOOOOOOOOOOOOOOOOOOXXXXXX||
HW9 vliv_temp x x ||||||||||||||||XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX||
#
# ************ Temperatures *************
#
# Use symbol in table and start the line with that symbol
# DO NOT USE D, W, S, H or T or I symbols
# - default min. temp
# + default max. temp
#
-15.50
+20.00
|15.00
O19.00
X21.00
#
# END WITH BLANK LINE (CR/LF)
Nur noch welche variablen in GlobalDefine-script eingeben aund fixie
- __myhome
- __debug
(Bei bedarf sende ich gerne meine GlobalDefines…)
PS: Beta … habe noch ein macken mit ‚IAmHome‘ (Ich Bin Zuhause).
Brauche eure Inteligenz
PS2: Möchte dies gerne in die ‚Beispiele‘-Forum reingeben … aber lieber erst Ihre Kommentare
Grusse,
Fredtchen (aka gggss)