Temperaturprofile des HM-CC-RT-DN auslesen

Moin @all,

ich bin ein Newbie in Sachen Homematic und IP-Symcon. Viele Probleme konnte ich zum Glück durch die Hilfe der vielen User hier in diesem Forum lösen. Nun stehe ich jedoch vor einer Aufgabe, bei der ich nicht mehr weiterkomme. Und zwar würde ich gern die Skripte aus diesem Thread (Wandthermostat-Setup-per-WebFront) benutzen, was leider mit dem Thermostat HM-CC-RT-DN nicht funktioniert. Soweit ich das schon herausfinden konnte ist das erste Problem das getParamSet aus der HMXML um die Temperaturprofile auszulesen und anschließend darstellen zu können.
Meine Frage wäre nun, wie ich noch per XMLRPC an diese Profile herankommen könnte?

Im Voraus schon mal vielen Dank für Eure Hilfe!

Gruß
Peter

Moin Peter,
grundsätzlich funktioniert der neue genauso wie der alte Thermostat, nur dass die Profile jetzt in der Hauptinstanz zu finden sind. Ich habe mal qick and dirty die hmxml.inc.php für den neuen Thermostat umgebastelt. Funktioniert bei mir tadellos.


<?
/* HMXML v1.1
 * 2013 by Silberstreifen for the IPS Community
 * neuen Thermostat HM-CC-RT-DN aufgenommen
 * Basis 2011 by Zapp for the IPS Community
 *
 * This  library  is  free  software;  you can redistribute it and/or modify it
 * under  the  terms  of the GNU Library General Public License as published by
 * the  Free  Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This  library 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  Library General Public
 * License for more details.
 *
 * You  should  have  received a copy of the GNU Library General Public License
 * along  with  this  library;  if  not, write to the Free Software Foundation,
 */

	define("HMXML_VERSION", "0.2");

	include "xmlrpc.inc.php" ;

//----------------------------------------------------------------------------
// USAGE:
// The HMXML library requires the xmlrpc library. Copy the library and
// xmlrpc.inc.php in the IPS script directory
// ---------------------------------------------------------------------------
//
// It should automatically detect the BidCos Service and create a XMLRPC client
// for every request.
// If you get an error message from HMXML_init or if you have performance
// problems, please add the following line at the start of your script:
//
// HMXML_init(YOUR_BIDCOS_SERVER_IP);
//
// All functions accept either the IPS Instance ID or the HM Address as parameter
//
// Examples:
//
// -- Get a full list of HM Devices
// $devices = HMXML_DevicesList();
// print_r($devices);
//
// -- Get a full list of HM Interfaces
// $interfaces = HMXML_InterfacesList();
// print_r($interfaces);
//
// -- Get all Parameters for a given HM device using the IPS instance ID
// $HM_Device_Parameters = HMXML_getParamSet($IPS_Instance_ID, 2);
// -- Get the Parameter Description
// $HM_Device_Parameters_Desc = HMXML_getParamSetDesc($IPS_Instance_ID, 2);
// -- Get one specific Parameter
// $TC_Mode = HMXML_getParamSet($IPS_Instance_ID, 2, 'MODE_TEMPERATUR_REGULATOR');
// -- The Mode of a HM Thermostat can also be retrived with
// HMXML_getTCMode($IPS_DeviceID);
// -- To set the Mode
// HMXML_setTCMode($IPS_DeviceID, $Mode);
// where 0 = MANUAL; 1 = AUTO; 2=CENTRAL; 3 = PARTY
//
// -- Get the Tempareature Profile of a Thermostat in a better Human-readable array
// $tempProfile = HMXML_getTempProfile($IPS_Instance_ID);
// print_r($tempProfile);
// -- Setting a temperature for a given Day / Profile Index
// Note: The transfer of data to the TC might take some time (few minutes).
// $tempProfileNew = array();
// $tempProfileNew['MONDAY']['EndTimes'] = array("06:30","08:30","16:30","22:00","24:00");
// $tempProfileNew['MONDAY']['Values'] = array(17.0,20.0,17.0,19.5,17.0);
// HMXML_setTempProfile(29146, $tempProfileNew);
//
// Remarks:
// Init XMLRPC client with address to speed up process
// HMXML_init($BidCosServiceIP);




//
// *************************************************************************
//   HMXML functions
// *************************************************************************

function HMXML_init($BidCosServiceIP = false, $debug = false, $port = "2001") {
	// $BidCosServiceIP: The IP Address of the BidCos Server. If not provided or false, will be detected via IPS

	global $xml_client;

	if ($xml_client !== false) {
		if ($BidCosServiceIP === false) { // We did not provide an IP for the BidCos Service
		   $nbOfHMSockets = 0;
   		foreach ( IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}") as $id ) // HomeMatic Socket
			{
			   if (($nbOfHMSockets++) > 1) {
			      die ("Error: HMXML_init() More than one HM Socket found. Please init XMLRPC Socket manually with HMXML_init(BidCos_Service_IP). <br>
");
			   }
				$HMSocketObject = IPS_GetObject($id);
				//print_r($HMSocketObject);
				if ($HMSocketObject['ObjectSummary'] == "localhost") { // Don't know why the address is in ObjectSummary...
					$IP = gethostbyname('localhost'); // Not an efficient method. Replace if needed. $_SERVER['SERVER_ADDR'] not working
					$BidCosServiceIP = $IP;
				}
				else $BidCosServiceIP = $HMSocketObject['ObjectSummary'];
				if ($debug) echo "Debug: Found HomeMatic Socket (BidCos Service) at IP $BidCosServiceIP
";
			}
	   }
		$xml_client = new xmlrpc_client("http://".$BidCosServiceIP.":".$port);
   	// XMLRPC Debug values: 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
   	if ($debug !== false) $xml_client->setDebug(2);
   	else $xml_client->setDebug(0);

   	if ($xml_client !== false) return true;
   	else return false;
	}

	// Instance of XML_Client already exists
	return false;
}

function HMXML_DevicesList() {

	$request = new xmlrpcmsg('listDevices');
	$devices = HMXML_send($request);

	return $devices;
}

function HMXML_InterfacesList() {

	$request = new xmlrpcmsg('listBidcosInterfaces');
  	$devices = HMXML_send($request);

	return $devices;
}

// Gets the Type of HM device (HM terminology)
function HMXML_getType($IPS_DeviceID) {
   // $IPS_DeviceID: IPS Instance ID

	$HMAddressFull = explode(":", HM_GetAddress($IPS_DeviceID));
   $HMAddress = $HMAddressFull[0];
   $HMAddressChannel = $HMAddressFull[1];

   $devices = HMXML_DevicesList();

   $type = false;

	foreach($devices as $device) {
	   if (strpos($device['ADDRESS'], $HMAddress) !== false) {
			$type = $device['TYPE'];
	   	break;  // We stop at the first one we find
		}
	}

	return $type;
}

function HMXML_getTempProfile($IPS_DeviceID, $day = false, $echo = false) {
	// Gets the Temperature Profile of a Thermostat for a given day or all days
	// Returns the result in an array
   // $IPS_DeviceID: IPS Instance ID
	// $day: STRING - Name of day in english (not case-sensitive) or false for all days
	// $echo: BOOL - if true, the Temperature profiles is output in readable format with time values

   $HMAddressFull 	= explode(":", HM_GetAddress($IPS_DeviceID));
   $HMAddress 			= $HMAddressFull[0];
   $HMAddressChannel = $HMAddressFull[1];

	$dayArray = array("MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY");
	$tempArray = array();

	if ($day != false) {
	   if (!in_array($day, $dayArray)) die("Error: Unknown Day parameter in function HMXML_getTempProfile<br>
"); // HMXML_SetTempProfile
	   $dayArray = array($day);
	}

	$type = HMXML_getType($IPS_DeviceID);

	$params = HMXML_getParamSet($IPS_DeviceID, $HMAddressChannel);

   if ($type == "HM-CC-TC") {

   	foreach($dayArray as $day) {
      	if ($echo) echo "$day
";

      	$thisEndTimesArray 	= array();
      	$thisTempValuesArray	= array();
			$timePrevious = "00:00";
       	for ($index = 1; $index <= 24; $index++) {
         	$keyTemp = "TEMPERATUR_".strtoupper($day)."_".$index;
         	$keyTO 	= "TIMEOUT_".strtoupper($day)."_".$index;
         	$Temp 	= $params[$keyTemp];
         	$TO 		= $params[$keyTO];
       		$Time = date('H:i', mktime(0, $TO)); // $timePassed + TO

         	if ($TO >= 1440) $Time = "24:00";
         	if ($echo) echo "$index: $timePrevious -> $Time = $Temp °C
"; //if ($echo) echo "$index: $timePrevious -> $Time = $Temp °C
";
				$timePrevious = $Time;
         	array_push($thisEndTimesArray,	$Time);
            array_push($thisTempValuesArray,	$Temp);

         	if ($TO >= 1440) break;
   		}
   		$tempArray[$day]['EndTimes'] 	= $thisEndTimesArray;
   		$tempArray[$day]['Values'] 	= $thisTempValuesArray;
		}

		return $tempArray;
   } elseif ($type == "HM-CC-RT-DN") {

   	foreach($dayArray as $day) {
      	if ($echo) echo "$day
";

      	$thisEndTimesArray 	= array();
      	$thisTempValuesArray	= array();
			$timePrevious = "00:00";
       	for ($index = 1; $index <= 13; $index++) {
         	$keyTemp = "TEMPERATURE_".strtoupper($day)."_".$index;
         	$keyTO 	= "ENDTIME_".strtoupper($day)."_".$index;
         	$Temp 	= $params[$keyTemp];
         	$TO 		= $params[$keyTO];
       		$Time = date('H:i', mktime(0, $TO)); // $timePassed + TO

         	if ($TO >= 1440) $Time = "24:00";
         	if ($echo) echo "$index: $timePrevious -> $Time = $Temp °C
"; //if ($echo) echo "$index: $timePrevious -> $Time = $Temp °C
";
				$timePrevious = $Time;
         	array_push($thisEndTimesArray,	$Time);
            array_push($thisTempValuesArray,	$Temp);

         	if ($TO >= 1440) break;
   		}
   		$tempArray[$day]['EndTimes'] 	= $thisEndTimesArray;
   		$tempArray[$day]['Values'] 	= $thisTempValuesArray;
		}

		return $tempArray;
   } else {
      die("Error: TC_getTempProfile() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-xx<br>
");
   }
}


function HMXML_setTempProfile($IPS_DeviceID, $tempProfileArray) {
	// $IPS_DeviceID: IPS Instance ID
	// $tempProfileArray: ARRAY of type returned by HMXML_getTempProfile()

	$HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {

	   $values = new xmlrpcval();

	   foreach ($tempProfileArray as $day => $valuesArray) {

	      $previousTimeEnd = "00:00";

	   	for ($index=1; $index <= count($valuesArray['EndTimes']); $index++) {
	      	$key = "TEMPERATUR_".strtoupper($day)."_".$index;
				$paramTemp = array($key => new xmlrpcval($valuesArray['Values'][$index-1], "double"));
				$values->addStruct($paramTemp);

				$key = "TIMEOUT_".strtoupper($day)."_".$index;

				if ($valuesArray['EndTimes'][$index-1] > $previousTimeEnd) {
			   	// Convert end time to Timeout
			   	$thisDayStart = mktime(0, 0);
	              $timeEndArray = explode(":", $valuesArray['EndTimes'][$index-1]);
			   	if ($timeEndArray[1] % 10) die("Error: Invalid End Time (must be 10mn increments) for $day at index $index in TC_setTempProfile()<br>
");
			   	$timeEndts = mktime($timeEndArray[0], $timeEndArray[1]);
			   	$timeout = ($timeEndts - $thisDayStart)/60; // TODO, works  ?

	              $paramTime = array($key => new xmlrpcval("$timeout", "int")); // i4
	              $values->addStruct($paramTime);
				} else
					die("Error: Invalid End Time for $day at index $index in TC_setTempProfile()<br>
");

	              $previousTimeEnd = $valuesArray['EndTimes'][$index-1];
			}

	   }
	   $content = new xmlrpcmsg("putParamset",
	              array(  new xmlrpcval("$HMAddress:2", "string"),
	                      new xmlrpcval("MASTER", "string"),
	                      $values ) );

		 $result = HMXML_send($content);

		return true;
   }elseif ($type == "HM-CC-RT-DN") {

		$values = new xmlrpcval();

		foreach ($tempProfileArray as $day => $valuesArray) {

		   $previousTimeEnd = "00:00";

			for ($index=1; $index <= count($valuesArray['EndTimes']); $index++) {
		   	$key = "TEMPERATURE_".strtoupper($day)."_".$index;
				$paramTemp = array($key => new xmlrpcval($valuesArray['Values'][$index-1], "double"));
				$values->addStruct($paramTemp);

				$key = "ENDTIME_".strtoupper($day)."_".$index;

				if ($valuesArray['EndTimes'][$index-1] > $previousTimeEnd) {
			   	// Convert end time to Timeout
			   	$thisDayStart = mktime(0, 0);
		           $timeEndArray = explode(":", $valuesArray['EndTimes'][$index-1]);
			   	if ($timeEndArray[1] % 10) die("Error: Invalid End Time (must be 10mn increments) for $day at index $index in RT_setTempProfile()<br>
");
			   	$timeEndts = mktime($timeEndArray[0], $timeEndArray[1]);
			   	$timeout = ($timeEndts - $thisDayStart)/60; // TODO, works  ?

		           $paramTime = array($key => new xmlrpcval("$timeout", "int")); // i4
		           $values->addStruct($paramTime);
				} else
					die("Error: Invalid End Time for $day at index $index in RT_setTempProfile()<br>
");

		           $previousTimeEnd = $valuesArray['EndTimes'][$index-1];
			}

		}
		$content = new xmlrpcmsg("putParamset",
		           array(  new xmlrpcval("$HMAddress", "string"),
		                   new xmlrpcval("MASTER", "string"),
		                   $values ) );
		 $result = HMXML_send($content);
		 return true;
   } else {
      die("Error: TC_setTempProfile() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-TC<br>
");
   }
}

function HMXML_getParamSet($IPS_DeviceID, $channel = null, $param = false) {
	// $IPS_DeviceID: IPS Instance ID
	// $channel: INTEGER - if null the channel is taken from IPS
	// $param: STRING - A specific parameter to return (see HomeMatic Specficiation), returns all if false
	// Output: An array of Parameters for the Device

   $HMAddressFull = explode(":", HM_GetAddress($IPS_DeviceID));
   $HMAddress = $HMAddressFull[0];
   $HMAddressChannel = $HMAddressFull[1];

   $thisChannel = isset($channel) ? $channel : $HMAddressChannel;

	$type = HMXML_getType($IPS_DeviceID);
    if ($type == "HM-CC-TC") {
    	$request = new xmlrpcmsg("getParamset",
   	  array(new xmlrpcval("$HMAddress:$thisChannel", "string"),
   		new xmlrpcval("MASTER", "string")) );
    }elseif ($type == "HM-CC-RT-DN") {
    	$request = new xmlrpcmsg("getParamset",
			array(new xmlrpcval("$HMAddress", "string"),
   		new xmlrpcval("MASTER", "string")) );
    }
	$messages = HMXML_send($request);

	if ($param !== false) return $messages[$param];
	return $messages;
}

function HMXML_getParamSetDesc($IPS_DeviceID, $channel = null, $param = false) {
	// $IPS_DeviceID: IPS Instance ID
	// $channel: INTEGER - default is null. Should already be included in HM Address
	// $param: STRING - A specific parameter to return (see HomeMatic Specficiation), returns all if false
	// Output: Array of Parameter Descriptions for the Device

   $HMAddressFull = explode(":", HM_GetAddress($IPS_DeviceID));
   $HMAddress = $HMAddressFull[0];
   $HMAddressChannel = $HMAddressFull[1];

	$thisChannel = isset($channel) ? $channel : $HMAddressChannel;
	$request = new xmlrpcmsg("getParamsetDescription",
  					array(new xmlrpcval("$HMAddress:$thisChannel", "string"),
           		new xmlrpcval("MASTER", "string")) );

	$messages = HMXML_send($request);

   if ($param !== false) return $messages[$param];
	return $messages;
}

function HMXML_setParamFloat($IPS_DeviceID, $param, $value) {
	// $IPS_DeviceID: IPS Instance ID or HM Address
	// $param: STRING - The parameter to set
	// $value: DOUBLE - The value to set. If not double, will not be set on device
	$HMAddress = IPSid_2_HMAddress($IPS_DeviceID);
   $type = HMXML_getType($IPS_DeviceID);
	$params = array($param => new xmlrpcval("$value", "double"));
	$values = new xmlrpcval();
	$values->addStruct($params);
   if ($type == "HM-CC-TC") {$HMAddress="$HMAddress:2";}
	$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

	$result = HMXML_send($content);
}


function HMXML_setParamInt($IPS_DeviceID, $param, $value) {
	// $IPS_DeviceID: IPS Instance ID or HM Address
	// $param: STRING - The parameter to set
	// $value: DOUBLE - The value to set. If not double, will not be set on device
	$HMAddress = IPSid_2_HMAddress($IPS_DeviceID);
   $type = HMXML_getType($IPS_DeviceID);
	$params = array($param => new xmlrpcval("$value", "string"));
	$values = new xmlrpcval();
	$values->addStruct($params);
   if ($type == "HM-CC-TC") {$HMAddress="$HMAddress:2";}
	$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

	$result = HMXML_send($content);
}

// Gets the Mode of a VD (Valve) Device
function HMXML_getTCValveMode($IPS_DeviceID) {
	// $IPS_DeviceID: IPS Instance ID
	// Output: INTEGER - Mode 0 = AUTO, 1 = CLOSE VALVE, 2 = OPEN VALVE
   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
		$value = HMXML_getParamSet($IPS_DeviceID, 2, 'MODE_TEMPERATUR_VALVE');
		return $value;
	} else {
      die("Error: HMXML_getTCValveMode() Device $IPS_DeviceID is not of Type HM-CC-TC<br>
");
   }
}

// Sets the Mode on a VD (Valve) Device
function HMXML_setTCValveMode($IPS_DeviceID, $nMode) {
	// $IPS_DeviceID: IPS Instance ID
	// $nMode: INTEGER - 0 = AUTO, 1 = CLOSE VALVE, 2 = OPEN VALVE

   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
		$params = array("MODE_TEMPERATUR_VALVE" => new xmlrpcval("$nMode", "i4"));

		$values = new xmlrpcval();
		$values->addStruct($params);

		$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress:2", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

   	$result = HMXML_send($content);

		return $result;
 	} else {
      die("Error: HMXML_setTCValveMode() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-TC<br>
");
   }
}


// Sets the Error Position on a VD (Valve) Device
function HMXML_setVDErrorPos($IPS_DeviceID, $nErrorPosition) {
	// $IPS_DeviceID: IPS Instance ID
	// $nErrorPosition: INTEGER - Position in %, between 0 and 99 included

   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-VD") {
		$params = array("VALVE_ERROR_POSITION" => new xmlrpcval("$nErrorPosition", "i4"));

		$values = new xmlrpcval();
		$values->addStruct($params);

		$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress:2", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

   	$result = HMXML_send($content);

		return $result;
 	} else {
      die("Error: HMXML_setVDErrorPos() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-VD<br>
");
   }
}

// Sets the Error Position on a VD (Valve) Device
function HMXML_setVDOffset($IPS_DeviceID, $nOffset) {
	// $IPS_DeviceID: IPS Instance ID
	// $nOffset: INTEGER - Offset Position in %, between 0 and 25 included

   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-VD") {
		$params = array("VALVE_OFFSET_VALUE" => new xmlrpcval("$nOffset", "i4"));

		$values = new xmlrpcval();
		$values->addStruct($params);

		$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress:2", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

   	$result = HMXML_send($content);

		return $result;
 	} else {
      die("Error: HMXML_setVDOffset() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-VD<br>
");
   }
}

// Gets the Mode on a TC (Thermostat) Device
function HMXML_getTCMode($IPS_DeviceID) {
	// $IPS_DeviceID: IPS Instance ID
	// Output: INTEGER - Mode: 0 = MANUAL, 1 = AUTO, 2=CENTRAL, 3 = PARTY

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
		$value = HMXML_getParamSet($IPS_DeviceID, 2, 'MODE_TEMPERATUR_REGULATOR');
		return $value;
  	} else {
      die("Error: HMXML_getTCMode() Device $IPS_DeviceID is not of Type HM-CC-TC<br>
");
   }
}

// Sets the Mode on a TC (Thermostat) Device
function HMXML_setTCMode($IPS_DeviceID, $nMode) {
	// $IPS_DeviceID: IPS Instance ID
	// $nMode: INTEGER - Mode 0 = MANUAL, 1 = AUTO, 2=CENTRAL, 3 = PARTY

   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

   $type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
		$params = array("MODE_TEMPERATUR_REGULATOR" => new xmlrpcval("$nMode", "i4"));

		$values = new xmlrpcval();
		$values->addStruct($params);

		$content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress:2", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

   	$result = HMXML_send($content);

		return $result;
 	} else {
      die("Error: HMXML_setTCMode() Device $HMAddress ($IPS_DeviceID) is not of Type HM-CC-TC<br>
");
   }
}

// Sets Temperature Comfort Value
function HMXML_setTempComfortValue($IPS_DeviceID, $temp) {
	// $IPS_DeviceID: IPS Instance ID
	// $temp: FLOAT - Temperature Value

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
      $result = HMXML_setParamFloat($IPS_DeviceID, "TEMPERATUR_COMFORT_VALUE", $temp);

		return $result;
 	} elseif ($type == "HM-CC-RT-DN") {
      $result = HMXML_setParamFloat($IPS_DeviceID, "[TEMPERATURE_COMFORT", $temp);

		return $result;
 	} else {
      die("Error: HMXML_SetTempComfortValue() Device $IPS_DeviceID is not of Type HM-CC-xx<br>
");
   }
}

// Sets Temperature Lowering (Absenk) Value
function HMXML_setTempLoweringValue($IPS_DeviceID, $temp) {
	// $IPS_DeviceID: IPS Instance ID
	// $temp: FLOAT - Temperature Value

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
      $result = HMXML_setParamFloat($IPS_DeviceID, "TEMPERATUR_LOWERING_VALUE", $temp);
		return $result;
 	} elseif ($type == "HM-CC-RT-DN") {
      $result = HMXML_setParamFloat($IPS_DeviceID, "TEMPERATURE_LOWERING", $temp);
		return $result;
 	} else {
      die("Error: HMXML_SetTempLoweringValue() Device $IPS_DeviceID is not of Type HM-CC-xx<br>
");
   }
}

// Sets Temperature Lowering (Absenk) Value
function HMXML_setTempPartyValue($IPS_DeviceID, $temp) {
	// $IPS_DeviceID: IPS Instance ID
	// $temp: FLOAT - Temperature Value

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {
      $result = HMXML_setParamFloat($IPS_DeviceID, "TEMPERATUR_PARTY_VALUE", $temp);

		return $result;
 	} else {
      die("Error: HMXML_SetTempPartyValue() Device $IPS_DeviceID is not of Type HM-CC-TC<br>
");
   }
}

// Sets Temperature Offset
function HMXML_setTempOffset($IPS_DeviceID, $temp) {
	// $IPS_DeviceID: IPS Instance ID
	// $temp: FLOAT - Temperature Offset

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-RT-DN") {
		$temp = ($temp+3.5)*2;
	   if (($temp<0)||($temp>14)){die("Error: HMXML_setTempOffset() Temp out of range(+-3.5°C)<br>
");}
      $result = HMXML_setParamInt($IPS_DeviceID, "TEMPERATURE_OFFSET", $temp);
		return $result;
 	} else {
      die("Error: HMXML_setTempOffset() Device $IPS_DeviceID is not of Type HM-CC-RT-DN<br>
");
   }
}

// Sets Temperature Offset
function HMXML_getTempOffset($IPS_DeviceID) {
	// $IPS_DeviceID: IPS Instance ID
	// $temp: FLOAT - Temperature Offset

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-RT-DN") {
      $result = HMXML_getParamSet($IPS_DeviceID,null, "TEMPERATURE_OFFSET");
		if ($result<>""){$result=$result*0.5-3.5;}
		return $result;
 	} else {
      die("Error: HMXML_getTempOffset() Device $IPS_DeviceID is not of Type HM-CC-RT-DN<br>
");
   }
}

// Sets Party Time
function HMXML_setPartyEnd($IPS_DeviceID, $day, $hour, $minute) {
	// $IPS_DeviceID: IPS Instance ID
	// $day: number of days (0 to 200 max)
	// $hour: the hour (0 to 23 included)
	// $minute: 0 = 00, 1 = 30

	if ($day < 0 or $day > 200) 		die("Error: HMXML_SetPartyEnd() Number of Days must be between 0 and 200<br>
");
	if ($hour < 0 or $day > 23) 		die("Error: HMXML_SetPartyEnd() Hour must be between 0 and 23<br>
");
	if ($minute < 0 or $minute > 1) 	die("Error: HMXML_SetPartyEnd() Minute must be 0 (00) or 1 (30)<br>
");

   $HMAddress = IPSid_2_HMAddress($IPS_DeviceID);

	$type = HMXML_getType($IPS_DeviceID);
   if ($type == "HM-CC-TC") {

      $values = new xmlrpcval();

   	$paramDay = array("PARTY_END_DAY" => new xmlrpcval("$day", "double"));
   	$values->addStruct($paramDay);
   	$paramHour = array("PARTY_END_HOUR" => new xmlrpcval("$hour", "i4"));
   	$values->addStruct($paramHour);
   	$paramMinute = array("PARTY_END_MINUTE" => new xmlrpcval("$minute", "i4"));
   	$values->addStruct($paramMinute);

      $content = new xmlrpcmsg("putParamset",
                    array(  new xmlrpcval("$HMAddress:2", "string"),
                            new xmlrpcval("MASTER", "string"),
                            $values ) );

   	$result = HMXML_send($content);

		return $result;
 	} else {
      die("Error: HMXML_SetPartyEnd() Device $IPS_DeviceID is not of Type HM-CC-TC<br>
");
   }
}


// Gets Reception Levels between 2 HM Devices in dbm
function HMXML_getRFLevelsAB($IPS_DeviceID_A, $IPS_DeviceID_B) {
	// $IPS_DeviceID_A: IPS Instance ID of first device
	// $IPS_DeviceID_B: IPS Instance ID of second device
	// Output: Array with Reception Levels in dbm
	// Note: 65536 means unknown level

   $HMAddressA = IPSid_2_HMAddress($IPS_DeviceID_A);
   $HMAddressB = IPSid_2_HMAddress($IPS_DeviceID_B);

	$request = new xmlrpcmsg('rssiInfo');
	$devices = HMXML_send($request);

	//$result = array();

	//array_push($result, $devices[$HMAddressA][$HMAddressB]);
	//array_push($result, $devices[$HMAddressB][$HMAddressA]);

	//return $result;
	return $devices[$HMAddressA][$HMAddressB];
}

// Converts IPS Instance ID to HM Address or leaves Address if provided as such
function IPSid_2_HMAddress($IPS_DeviceID) {
   // $IPS_DeviceID: IPS Instance ID or HM Address
   // output: HM Address

	if (preg_match ("/^[A-Z]{3}[0-9]*/", $IPS_DeviceID)) {
		// The provided ID is a HM Address. Leave as it is.
	 	return $IPS_DeviceID;
	} else {
    	// The provided ID is a IPS Instance ID. Convert and extract HM Address.
	 	$HMAddressFull = HM_GetAddress($IPS_DeviceID);
	 	if ($HMAddressFull === false) echo "Eror: Invalid IPS Instance ID in IPSid_2_HMAddress()";
	 	$HMAddressArray = explode(":", $HMAddressFull);
   	$HMAddress = $HMAddressArray[0];
   	return $HMAddress;
	}
}

// Creates XMLRPC Client Instance and sends request
function HMXML_send($request) {
	global $xml_client, $BidCosServiceIP;

	// If the client does not exist, initialise it here
	if ($xml_client == false) {
      $init_result = HMXML_init();
		if ($init_result !== false) echo "XMLRPC INIT SUCCESS!
"; else "XMLRPC INIT FAILED!
";
		echo "
";
	}

	$response = $xml_client->send($request);
	if ( $response->errno == 0 )
   	$messages = php_xmlrpc_decode($response->value());
	else
		die("Error: HMXML_send() Request to BidCos-Service failed ($BidCosServiceIP) -> $response->errstr<br>
");

	return $messages;
}
?>

Probiers einfach mal aus.
Viel Erfolg
Silberstreifen

Super Arbeit :loveips:

Funktioniert bestens.

@Silberstreifen: Vielen vielen Dank für Deine Arbeit!!! Es funktioniert! :smiley:

Viele Grüße
Peter