Gardena/Husqvarna G3 Webfront Integration

Das Problem ist, dass die Abfrage des Modus über die Status API nicht gleich ist wie der API-Befehl um den Modus zu setzen.

Wenn Du die beiden Variablen Profile vergleichst siehst Du was ich meine.

Ich habe dchon versucht, dass mit einer Variable zu lösen, bin aber leider daran gescheitert.

Lt. Robonect Forum soll sich das aber noch ändern.

Gesendet von meinem D6633 mit Tapatalk

Hallo manni,

noch mal eine andere Frage: Wir wollten heute mal wieder mit dem Programm experimentieren und einen Mähauftrag probieren.
Startzeit einstellen und Endzeit einstellen ist dabei aber leider nicht möglich - ‚Auftrag senden‘ kann wohl deshalb nicht aktiviert werden.

Ist das ein bekanntes Verhalten (bug?)

Gruß
Dieter

@Manni, Danke für die Arbeit!

Hallo,

bei mir läuft das Script / Auswerten etc. einwandfrei, ausser die Timerliste wird in der „html-Box“ nicht angezeigt?!
Auch wenn ich die html-Box auf die View platziere (IPSView) sehe ich keine „css“ Einträge, wie es bei den anderen html-Boxen ist.

Wodran kann das wohl liegen?

111.jpg222.jpg

Der Code aus der „Funktion“ wie folgt:

<?
/*******************************************************************************

    MSC - Version 3.2.1c vom 15.04.2017

********************************************************************************

    SKRIPT ZUM AUSLESEN VON MÄHROBOTER
    AUSGESTATTET MIT DEM
	ROBONECT-MODUL H30x Ver. 0.9c

--------------------------------------------------------------------------------

	Funktionen

********************************************************************************
*******************************************************************************/

// Einlesen der Variablen
function robo_GetVariable($ident, $parentIdent){
Global $parents;

	$vid = IPS_GetObjectIDByIdent($ident, $parents[$parentIdent]);
	if($vid === false) return false;
	else return GetValue($vid);
    }
	
	
// Schreiben der Variablen
function robo_SetVariable($ident, $parentIdent, $newvalue, $check = false, $logging = false){
Global $parents;

	$vid = IPS_GetObjectIDByIdent($ident, $parents[$parentIdent]);
	$oldvalue = GetValue($vid);

    if($logging == true){
		if($newvalue > $oldvalue) SetValue($vid, $newvalue);
		}
	elseif($check == true){
		if($newvalue != $oldvalue) SetValue($vid, $newvalue);
       	}
    else SetValue($vid, $newvalue);
    }


// --------------------------------------------------------------------------------


// Funktion Zeit erstellen
function robo_MakeTime($time){
	$newtime = new DateTime($time);
	return date_format($newtime, "H:i");
	}
	
	
// Funktion Zeitdifferenz prüfen
function robo_TimeCheck($ident, $parentIdent, $diff){
Global $parents;

	$varID = IPS_GetVariable(IPS_GetObjectIDByIdent($ident, $parents[$parentIdent]));

	if((time() - $varID['VariableUpdated']) > $diff) return true;
	else return false;
	}	


// Funktion um gleiche Werte ins Archiv zu schreiben
function robo_CompareACValue($ident, $value){
Global $parents;

	$archivID = IPS_GetInstanceListByModuleID("{43192F0B-135B-4CE7-A0A7-1475603F3060}")[0];
	$varID = IPS_GetObjectIDByIdent($ident, $parents['roboArchivID']);
	$unixtime = time() - 50;
	
	SetValue($varID, 1000);
	IPS_Sleep(1500);
	SetValue($varID, $value);

	$values = AC_GetLoggedValues($archivID, $varID, $unixtime, 0, 0);

	foreach($values as $key => $array){
		if($array['Value'] === 1000){
			$result = AC_DeleteVariableData($archivID, $varID, $array['TimeStamp'], $array['TimeStamp']);
			break;
			}
		}
	return $result;
	}
	
	
// --------------------------------------------------------------------------------

	
// API Kommandos senden
function robo_SendAPICommand($command, $debug = false){
	$content = url_get_contents("/".$command, $debug);

	if($content !== false) return robo_get_xmltojson($content, $debug);
	else return false;
    }


// WEB Kommandos senden
function robo_SendWEBCommand($command, $debug = false){
	$content = url_get_contents("/".$command, $debug);
	
	if($debug == true) echo $content;
	
	if($content !== false){
		//if(preg_match_all("/ok.png/U", $content, $result)) return "ok";
		//elseif(preg_match_all("/err.png/U", $content, $result)) return "err";
		return true;
		}	
	else return false;
    }


// --------------------------------------------------------------------------------
// Buffer auslesen/schreiben
function robo_GetSetBuffer($command, $value = ""){
Global $parents;
	IPS_SemaphoreEnter("rwBuffer", 1000);
	switch($command){
		case "read":
			$result =  json_decode(robo_GetVariable("roboArcBuffer", "roboArchivID"), true);		
		break;
		case "write":
			robo_SetVariable("roboArcBuffer", "roboArchivID", json_encode($value));
			$result = true;
		break;
		default:
			$result = false;
		break;
		}
	IPS_SemaphoreLeave("rwBuffer");
	return $result;
	}


// Kommando Meldungsausgabe
function robo_CreateMessage($text, $hold = false){
Global $parents;

	SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);
	WFC_SendNotification($_IPS['CONFIGURATOR'], robo_GetVariable("roboVarName", "roboVarID"), $text, "HouseRemote", 5);

	if($hold == false) SetValue($_IPS['VARIABLE'], -1);
	}


// Button ändern
function robo_ChangeButton($command = "write"){
 	$data = IPS_GetVariableProfile("_Robo_TimerControl");
	
	if($command === "read"){
		//if($data['Associations'][0]['Value'] == 0){
		@IPS_SetVariableProfileAssociation("_Robo_TimerControl", 0, "", "", -1);
   		IPS_SetVariableProfileAssociation("_Robo_TimerControl", 1, "auslesen", "TurnLeft", 0x3366FF);
		//}
		}
		//elseif($data['Associations'][0]['Value'] == 1){
	elseif($command === "write"){	
		@IPS_SetVariableProfileAssociation("_Robo_TimerControl", 1, "", "", -1);
   		IPS_SetVariableProfileAssociation("_Robo_TimerControl", 0, "speichern", "TurnRight", 0x3366FF);			
		//}
		}
	}


// Variablen initialisieren
function robo_VarInit($sender){
Global $parents;
	switch($sender){
		case "timer":
			robo_SetVariable("roboConTimerControl", "roboControlID", -1);
			robo_SetVariable("roboConTimerSelect", "roboControlID", -1);
			robo_SetVariable("roboConTimerActiv", "roboControlID", false);
			robo_SetVariable("roboConTimerTON_h", "roboControlID", -1);
			robo_SetVariable("roboConTimerTON_m", "roboControlID", -1);
			robo_SetVariable("roboConTimerTOF_h", "roboControlID", -1);
			robo_SetVariable("roboConTimerTOF_m", "roboControlID", -1);
			robo_SetVariable("roboConTimerMo", "roboControlID", false);
			robo_SetVariable("roboConTimerTu", "roboControlID", false);
			robo_SetVariable("roboConTimerWe", "roboControlID", false);
			robo_SetVariable("roboConTimerTh", "roboControlID", false);
			robo_SetVariable("roboConTimerFr", "roboControlID", false);
			robo_SetVariable("roboConTimerSa", "roboControlID", false);
			robo_SetVariable("roboConTimerSu", "roboControlID", false);
		break;
		case "control":
			robo_SetVariable("roboConMoveWayML", "roboControlID", 0);
			robo_SetVariable("roboConMoveWayMR", "roboControlID", 0);
			robo_SetVariable("roboConMoveWayTime", "roboControlID", 1);
			robo_SetVariable("roboConMoveWayControl", "roboControlID", -1);
		break;
		case "job":
			robo_SetVariable("roboConJobTON_h", "roboControlID", 8);
			robo_SetVariable("roboConJobTON_m", "roboControlID", 0);
			robo_SetVariable("roboConJobTOF_h", "roboControlID", 15);
			robo_SetVariable("roboConJobTOF_m", "roboControlID", 0);
			robo_SetVariable("roboConJobRemote", "roboControlID", -1);
			robo_SetVariable("roboConJobMode", "roboControlID", -1);
			robo_SetVariable("roboConJobSet", "roboControlID", -1);
		break;
		}
	}


// Timersetting anzeigen
function robo_TimerDisplay($data){
Global $parents;
	robo_SetVariable("roboConTimerActiv", "roboControlID", $data['enabled']);

	$time = explode(":", $data['start']);
		robo_SetVariable("roboConTimerTON_h", "roboControlID", $time[0]);
		robo_SetVariable("roboConTimerTON_m", "roboControlID", $time[1]);	
	$time = explode(":", $data['end']);
		robo_SetVariable("roboConTimerTOF_h", "roboControlID", $time[0]);
		robo_SetVariable("roboConTimerTOF_m", "roboControlID", $time[1]);
	
	robo_SetVariable("roboConTimerMo", "roboControlID", $data['weekdays']['mo']);
	robo_SetVariable("roboConTimerTu", "roboControlID", $data['weekdays']['tu']);
	robo_SetVariable("roboConTimerWe", "roboControlID", $data['weekdays']['we']);
	robo_SetVariable("roboConTimerTh", "roboControlID", $data['weekdays']['th']);
	robo_SetVariable("roboConTimerFr", "roboControlID", $data['weekdays']['fr']);
	robo_SetVariable("roboConTimerSa", "roboControlID", $data['weekdays']['sa']);
	robo_SetVariable("roboConTimerSu", "roboControlID", $data['weekdays']['su']);
	
	SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);
	}


// --------------------------------------------------------------------------------


// Statusmeldung aufbereiten
function robo_GetStatusLong($mode, $duration){
	$profil = IPS_GetVariableProfile ("_Robo_Status");
	
	if($profil == true){
		// Status ermitteln
		foreach($profil['Associations'] as $key => $value){
			if($value['Value'] == $mode){
				$modetext = $value['Name'];
				break;
				}
			$modetext = "undefiniert";
			}
	
		// Zeit umrechnen (s -> h:m:s)
    	$sec = $duration % 60; 
    	$min = (($duration - $sec) / 60) % 60; 
    	$hrs = (((($duration - $sec) /60) - $min) / 60) % 24;
	
		if(strlen($sec) < 2) $sec = "0".$sec;
    	if(strlen($min) < 2) $min = "0".$min;
		if(strlen($hrs) < 2) $hrs = "0".$hrs;
	
		if($hrs > 0) $time = $hrs.":".$min.":".$sec;
		elseif($min > 0) $time = $min.":".$sec;
		elseif($sec > 0) $time = $sec." s";
		else $time = 0;
	
		// Statusausgabe																																	
		if($time == 0) return $modetext;
		else return $modetext.": ".$time;
		}
	else return false;
	}
	
	
function robo_GetTimerList($number = false){
Global $parents, $conf_timer;
	// Daten aus dem Speicher holen
	IPS_SemaphoreEnter("openBuffer", 3000);
	$buffer = robo_GetSetBuffer("read");
	
	if(array_key_exists("timer", $buffer) === false){
		IPS_SemaphoreLeave("openBuffer");
		robo_SetVariable("roboBoxTimer", "roboBoxID", "noch eine Daten vorhanden, bitte Timer einlesen");
		return;
		}
	elseif(is_array($buffer['timer']) === false){
		IPS_SemaphoreLeave("openBuffer");
		robo_SetVariable("roboBoxTimer", "roboBoxID", "noch eine Daten vorhanden, bitte Timer einlesen");
		return;
		}
	elseif(empty($buffer['timer']) === true){
		IPS_SemaphoreLeave("openBuffer");
		robo_SetVariable("roboBoxTimer", "roboBoxID", "noch eine Daten vorhanden, bitte Timer einlesen");
		return;
		}
		
	
	// Hintergrundfarbe Hauptfenster, Header und Fooder umwandeln (hex -> rgb)
	list($br, $bg, $bb) = sscanf($conf_timer['bground'], "#%02x%02x%02x");
	// Linienfarbe Grid umwandeln (hex -> rgb)
	list($gr, $gg, $gb) = sscanf($conf_timer['bggrid'], "#%02x%02x%02x");
	// Linienfarbe Timerauswahl umwandeln (hex -> rgb)
	list($sr, $sg, $sb) = sscanf($conf_timer['bgselect'], "#%02x%02x%02x");
	// Listenoffset berechnen
	$xpos = floor(($conf_timer['width'] - $conf_timer['twidth']) / 24);
	// Wochentagnamen definieren
	$dayname = array(
			"mo" => "Mo",
			"tu" => "Di",
			"we" => "Mi",
			"th" => "Do",
			"fr" => "Fr",
			"sa" => "Sa",
			"su" => "So"
			);
		
	// Beginn HTML Header	
	$htmlBox = "<style type='text/css'>";
	$htmlBox .= "#bgh {float:left;background:rgba(".$br.",".$bg.",".$bb.",".$conf_timer['bgoca'].");width:".($conf_timer['width'] + $xpos / 2)."px;font-size:".$conf_timer['fsize']."px;margin-left:0px;clear:both;}";
	$htmlBox .= "#bgt {float:left;background:rgba(".$br.",".$bg.",".$bb.",".$conf_timer['bgoca'].");width:".($conf_timer['width'] + $xpos / 2)."px;font-size:".$conf_timer['fsize']."px;margin-left:0px;clear:both;}";
	$htmlBox .= "#bgl {float:left;width:".($conf_timer['width'] + $xpos / 2)."px;font-size:".$conf_timer['fsize']."px;margin-left:0px;clear:both;}";
	$htmlBox .= "#bgf {float:left;background:rgba(".$br.",".$bg.",".$bb.",".$conf_timer['bgoca'].");width:".($conf_timer['width'] + $xpos / 2)."px;font-size:".$conf_timer['fsize']."px;margin-left:0px;clear:both;}";
	$htmlBox .= "#spacer {width:".$conf_timer['width']."px;height:".$conf_timer['spacer']."px;margin:auto;clear:both;}";
	// Header - Zeitleiste
	if($conf_timer['head_on'] == true){
		$htmlBox .= "#btime {position:relative;float:left;width:".($conf_timer['width'] + $xpos / 2)."px;border-bottom:1px dotted;}";
		$htmlBox .= "#ttime {float:left;height:".$conf_timer['hhead']."px;width:".($conf_timer['twidth'] - $xpos / 2)."px;}";
		$htmlBox .= ".time {width:".$xpos."px;height:".$conf_timer['hhead']."px;text-align:center;display:table-cell;vertical-align:middle;}";
		}
	// Grid-Overlay
	if($conf_timer['grid_on'] == true){
		$htmlBox .= "#bhline {position:absolute;float:left;width:".($conf_timer['width'] + $xpos / 2)."px;}";
		$htmlBox .= "#thline {float:left;width:".$conf_timer['twidth']."px;border-right:1px dotted rgba(".$gr.",".$gg.",".$gb.",".$conf_timer['goca'].");}";
		$htmlBox .= ".hline {width:".($xpos - 1)."px;border-right:1px dotted rgba(".$gr.",".$gg.",".$gb.",".$conf_timer['goca'].");}";
		}	
	// Timerspalte
	$htmlBox .= "#timer {position:relative;float:left;width:".$conf_timer['twidth']."px;height:".$conf_timer['thigh']."px;margin-left:0px;}";
	$htmlBox .= "#tbase {position:absolute;width:".$conf_timer['twidth']."px;height:".$conf_timer['thigh']."px;}";
	$htmlBox .= "#ttext {position:relative;width:".$conf_timer['twidth']."px;height:".$conf_timer['thigh']."px;display:table-cell;padding-left:5px;text-align:left;vertical-align:middle;}";
	// Main
	$htmlBox .= "#base {width:".$conf_timer['width']."px;height:".$conf_timer['thigh']."px;margin-left:0px;}";
	// Pause vor Start
	$htmlBox .= "#bb1 {float:left;height:".$conf_timer['thigh']."px;margin:auto;}";
	$htmlBox .= "#b1 {height:".$conf_timer['thigh']."px;}";
	// Mähzeit
	$htmlBox .= "#bmow {float:left;height:".$conf_timer['thigh']."px;margin:auto;}";
	$htmlBox .= "#mow {height:".$conf_timer['thigh']."px;opacity:".$conf_timer['baroca'].";text-align:center;display:table-cell;vertical-align:middle;}";
	// Pause nach Ende
	$htmlBox .= "#bb3 {float:left;height:".$conf_timer['thigh']."px;margin:auto;}";
	$htmlBox .= "#b3 {height:".$conf_timer['thigh']."px;}";
	// Fooder - Timertage
	if($conf_timer['foo_on'] == true){
		$htmlBox .= "#bfoo {float:left;width:".($conf_timer['width'] + $xpos / 2 - 3)."px;height:".$conf_timer['hfoo']."px;margin:auto;border:1px dotted;}";
		$htmlBox .= "#foo {height:".$conf_timer['hfoo']."px;padding-left:15px;text-align:center;display:table-cell;vertical-align:middle;}";
		}
	$htmlBox .= "</style>";
		
	// Zeitleiste - Header
	if($conf_timer['head_on'] == true){
		$htmlBox .= "<div id='bgh'>";
		$htmlBox .= "<div><div id='btime'>";
		$htmlBox .= "<div id='ttime'></div>";
		$htmlBox .= "<div style='float:left;'><div class='time'>0</div></div>";
		for($i = 1; $i <= 23; $i++) $htmlBox .= "<div style='float:left;'><div class='time'>".$i."</div></div>";
		$htmlBox .= "<div><div class='time' style='width:".($xpos - 2)."px;'>24</div></div>";
		$htmlBox .= "</div></div>";
		
		if($conf_timer['grid_on'] == true){
			$htmlBox .= "<div><div id='bhline' style='margin-top:".floor($conf_timer['hhead'] / 4 * 3)."px;'>";
			$htmlBox .= "<div id='thline'>*</div>";
			$htmlBox .= "<div style='float:left;'><div class='hline' style='height:".floor($conf_timer['hhead'] / 4)."px;'>*</div></div>";
			for($i = 0; $i <= 22; $i++) $htmlBox .= "<div style='float:left;'><div class='hline' style='height:".floor($conf_timer['hhead'] / 4)."px;'>*</div></div>";
			$htmlBox .= "</div></div>";
			}
		}
	$htmlBox .= "</div>";
	
	// Hauptbereich
	$htmlBox .= "<div id='bgt'>";

	// Grid-Overlay
	if($conf_timer['foo_on'] == true) $height = count($buffer['timer']) * $conf_timer['thigh'] + count($buffer['timer']) * $conf_timer['spacer'] + $conf_timer['spacer'] * 2 + 1;
	else $height = count($buffer['timer']) * $conf_timer['thigh'] + count($buffer['timer']) * $conf_timer['spacer'] + $conf_timer['spacer'] + 1;
	
	if($conf_timer['grid_on'] == true){
		$htmlBox .= "<div><div id='bhline'>";
		$htmlBox .= "<div id='thline' style='height:".$height."px;'>*</div>";
		$htmlBox .= "<div style='float:left;'><div class='hline' style='height:".$height."px;'>*</div></div>";
		for($i = 0; $i <= 22; $i++) $htmlBox .= "<div style='float:left;'><div class='hline' style='height:".$height."px;'>*</div></div>";
		$htmlBox .= "</div></div>";
		}

	$htmlBox .= "<div id='spacer'></div>";
	
	// Timerarrays abarbeiten
	$count = 1;
	foreach($buffer['timer'] as $key => $value){
		$activ = $buffer['timer'][$key]['enabled'];
		$start = explode(":", $buffer['timer'][$key]['start']);
		$end = explode(":", $buffer['timer'][$key]['end']);
	
		// Startminuten umwandeln
		if($start[1] == 0) $sm = 0;
		elseif($start[1] == 15) $sm = 0.25;
		elseif($start[1] == 30) $sm = 0.5;
		elseif($start[1] == 45) $sm = 0.75;
		// Gesamtstartzeit berechnen
		if($start[0] == "00") $ton = $sm;
		else $ton = $start[0] + $sm;
		
		// Endminuten umwandeln
		if($end[1] == 0) $em = 0;
		elseif($end[1] == 15) $em = 0.25;
		elseif($end[1] == 30) $em = 0.5;
		elseif($end[1] == 45) $em = 0.75;
		// Gesamtendzeit berechnen
		if($end[0] == "00") $tof = $em;
		else $tof = $end[0] + $em;
	
		// Berechnung der Prozentewerte
		$b1 = $ton * 100 / 24;
		$mow = $tof * 100 / 24 - $b1;
		$b2 = 100 - ($b1 + $mow);
		
		// umwandeln der Werte zur Anzeige in "px"
		$b1px = floor(($conf_timer['width'] - $conf_timer['twidth']) * $b1 / 100);
		$mowpx = floor(($conf_timer['width'] - $conf_timer['twidth']) * $mow / 100);
		$b2px = floor(($conf_timer['width'] - $conf_timer['twidth']) * $b2 / 100);

		// zusammenfügen der einzelnen Timerzeilen
		$htmlBox .= "<div id='timer'>";
		if($activ === 0) $htmlBox .= "<div id='tbase' style='background-color:".$conf_timer[$key].";opacity:".$conf_timer['toca'].";'></div>";
		else $htmlBox .= "<div id='tbase' style='background-color:".$conf_timer[$key].";'></div>";
		$htmlBox .= "<div id='ttext'>".str_replace(array("t", "r"), array("T", "r "), $key)."</div>";
		$htmlBox .= "</div>";
			
		// ausgewählten Timer markieren
		if($number == $buffer['timer'][$key]['id']){
			$days = $buffer['timer'][$key]['weekdays'];
			$timer = str_replace(array("t", "r"), array("T", "r "), $key);
			$timerstat = $buffer['timer'][$key]['enabled']; 
			
			if($conf_timer['select'] == true) $htmlBox .= "<div id='base' style='border: 1px solid rgba(".$sr.",".$sg.",".$sb.",".$conf_timer['seloca'].");'>";
			else $htmlBox .= "<div id='base'>";	
			}
		else $htmlBox .= "<div id='base'>";
		
		$htmlBox .= "<div id='bb1' style='width:".$b1px."px;'><div id='b1' width:".$b1px."px;'></div></div>"; 
		$htmlBox .= "<div id='bmow' style='width:".$mowpx."px;'><div id='mow' style='background-color:".$conf_timer[$key].";";
		
		if($conf_timer['ttext'] == true){
			if($mowpx < 80) $htmlBox .= "width:".$mowpx."px;'></div></div>";
			elseif($mowpx < 100) $htmlBox .= "width:".$mowpx."px;'>".$buffer['timer'][$key]['start']." - ".$buffer['timer'][$key]['end']."</div></div>";
			else $htmlBox .= "width:".$mowpx."px;'>".$buffer['timer'][$key]['start']." - ".$buffer['timer'][$key]['end']." Uhr</div></div>";
			}
		else $htmlBox .= "width:".$mowpx."px;'></div></div>";

		$htmlBox .= "<div id='bb3' style='width:".$b2px."px;'><div id='b2' style='width:".$b2px."px;'></div></div>";
		$htmlBox .= "</div>";
		$htmlBox .= "<div id='spacer'></div>";
		}
	$htmlBox .= "</div>";
	
	// Timerleiste am Ende erstellen - Fooder
	if($conf_timer['foo_on'] == true){
		$htmlBox .= "<div id='bgf'>";
		$htmlBox .= "<div id='spacer'></div>";
		$htmlBox .= "<div id='bfoo'>";
	
		if($number !== false){
			$xday = count($days) * 60;
			$xtimer = 80;
			$xend = ($conf_timer['width'] + $xpos / 2) - ($xday + $xtimer);
	
			if($timerstat === 1) $htmlBox .= "<div id='foo' style='width:".$xtimer.";'>".$timer.": <span style='color: green;'>aktiv</span></div>";
			else $htmlBox .= "<div id='foo' style='width:".$xtimer.";'>".$timer.": <span style='color: red;'>deaktiviert</span></div>";
	
			foreach($days as $key => $value){
				if($value === 1) $htmlBox .= "<div id='foo' sytle='width:".$xday.";'>".$dayname[$key].": <span style='color: green;'>aktiv</span></div>";
				else $htmlBox .= "<div id='foo' sytle='width:".$xday.";'>".$dayname[$key].": <span style='color: red;'>inaktiv</span></div>";
				}
		
			$htmlBox .= "<div id='foo' style='width:".$xend.";'></div>";
			}
		else $htmlBox .= "<div id='foo' style='width:100%;'>kein Timer ausgewählt</div>";
	
		$htmlBox .= "</div>";
		}
	$htmlBox .= "</div>";
	
	robo_SetVariable("roboBoxTimer", "roboBoxID", $htmlBox);
	IPS_SemaphoreLeave("openBuffer");
	return $htmlBox;
	}
					    

// Betriebsstunden aufbereiten
function robo_GetTimeStat($content, $debug = false){
Global $conf_time, $timestamp;
	if($content == true){
		// Daten aufbereiten
		preg_match_all( "/>(.*)</U", trim($content, "\x00..\x1F"), $result);
		$array = array_merge(array_filter($result[1]));
		
		if($debug == true) print_r($array);
		
		if(count($array) > 30){
			$data = array();
			$search_time = false;
			$mow_time = false;
	
			foreach($array as $key => $value){
				if($value == "Laufzeit:") $data['h_bst'] = (int)str_replace(" Stunden" , "", $array[$key+1]);
				elseif($value == "Mähzeit:") $data['h_mow'] = (int)str_replace(" Stunden" , "", $array[$key+1]);
				elseif($value == "Suchzeit:") $data['h_search'] = (int)str_replace(" Stunden" , "", $array[$key+1]);
				elseif($value == "Ladezeit:") $data['h_charge'] = (int)str_replace(" Stunden" , "", $array[$key+1]);
				elseif($value == "Vollladungen:") $data['count_c'] = (int)$array[$key+1];
				elseif($value == "Fehler:") $data['error'] = (int)$array[$key+1];
				elseif($value == "Seit:") $data['timestamp'] = $array[$key+1];
				elseif($value == "Suchzeiten") $search_time = true;
				elseif($value == "Mähzeiten") $mow_time = true;
				elseif($value == "Minimale Zeit:"){ $search_time = false; $mow_time = false;}
		
				if($search_time == true) $timearray['search_a'][] = (int)str_replace(" min.", "", $value);
				if($mow_time == true) $timearray['mow_a'][] = (int)str_replace(" min.", "", $value);;
				}
		
			if(is_array($timearray)){
				if(is_array($timearray['search_a'])) array_shift($timearray['search_a']);
				if(is_array($timearray['mow_a'])) array_shift($timearray['mow_a']);
				}
			if($debug === true) print_r($timearray);
			
			if(count($data) === 7){
			//Ausgabe der Daten		
			// CSS - Teil
				// Hintergrundfarbe umwandeln (hex -> rgb)
				if($conf_time['col_bg'] !== "") list($tr, $tg, $tb) = sscanf($conf_time['col_bg'], "#%02x%02x%02x");
				// Hintergrundfarbe Bars umwandeln (hex -> rgb)
				if($conf_time['col_bgb'] !== "") list($br, $bg, $bb) = sscanf($conf_time['col_bgb'], "#%02x%02x%02x");
		
				$htmlBox = "<style type='text/css'>";
				if($conf_time['col_bg'] == "") $bgt = "none";
  				else $bgt = "rgba(".$tr.",".$tg.",".$tb.",".$conf_time['oca_bg'].")";
				$htmlBox .= "#table {position:relative;float:left;background:".$bgt.";width:".($conf_time['width'] + 7)."px;padding: 5px;}";
				if($conf_time['col_bgb'] == "") $bgl = "none";
				else $bgl = "rgba(".$br.",".$bg.",".$bb.",".$conf_time['oca_bgb'].")";
				$htmlBox .= "#list {position:relative;background:".$bgl.";width:".$conf_time['width']."px;padding: 0px;}";
				$htmlBox .= "#q-graph {position:relative;width:".$conf_time['width']."px;height:".$conf_time['height']."px;";
  				$htmlBox .= "margin: 1.1em 0 3.5em; padding: 0;";
				if($conf_time['col_bgb'] == "") $list .= "background: none;";
  				else $htmlBox .= "background:rgba(".$br.",".$bg.",".$bb.",".$conf_time['oca_bgb'].");";
  				$htmlBox .= "border-bottom: 1px solid gray; list-style: none; ";
  				$htmlBox .= "font: 9px Helvetica, Geneva, sans-serif;}";
				$htmlBox .= "#q-graph ul {margin: 0; padding: 0; list-style: none;}";
				$htmlBox .= "#q-graph li {position: absolute; bottom: 0; width: 150px; z-index: 2; margin: 0; padding: 0; text-align: center; list-style: none;}";
				$htmlBox .= "#q-graph li.qtr {height: ".($conf_time['height'] - $conf_time['h_offset'])."px; padding-top: 2px; border-right: none;}";
				$htmlBox .= "#q-graph li.bar {width: 25px; border: 1px solid; border-bottom: none; color: ".$conf_time['col_txt'].";}";
				$htmlBox .= "#q-graph li.bar p {margin: 5px 0 0; padding: 0;}";
				$htmlBox .= "#q-graph li.time {left: 7px; background: ".$conf_time['col_bar']."; border-color: #EDC #BA9 #000 #EDC;}";
				$htmlBox .= "#q-graph #q1 {left: 0;}";
				$htmlBox .= "#q-graph #q2 {left: 32px;}";
				$htmlBox .= "#q-graph #q3 {left: 64px;}";
				$htmlBox .= "#q-graph #q4 {left: 96px;}";
				$htmlBox .= "#q-graph #q5 {left: 128px;}";
				$htmlBox .= "#q-graph #q6 {left: 160px;}";
				$htmlBox .= "#q-graph #q7 {left: 192px;}";
				$htmlBox .= "#q-graph #q8 {left: 224px;}";
				$htmlBox .= "#q-graph #q9 {left: 256px;}";
				$htmlBox .= "#q-graph #q10 {left: 288px;}";
				$htmlBox .= "#q-graph #q11 {left: 320px;}";
				$htmlBox .= "#q-graph #q12 {left: 352px;}";
				$htmlBox .= "#q-graph #q13 {left: 384px;}";
				$htmlBox .= "#q-graph #q14 {left: 416px;}";
				$htmlBox .= "#q-graph #q15 {left: 448px;}";
				$htmlBox .= "#q-graph #q16 {left: 480px;}";
				$htmlBox .= "#q-graph #q17 {left: 512px;}";
				$htmlBox .= "#q-graph #q18 {left: 544px;}";
				$htmlBox .= "#q-graph #q19 {left: 576px;}";
				$htmlBox .= "#q-graph #q20 {left: 608px; border-right: none;}";
				$htmlBox .= "</style>";
	
			// Tabellenerstellung
				$htmlBox .="<body>";
				$htmlBox .= "<div id='table'>";
				$htmlBox .= "<table style='font-size:12px;text-align:left;'>";
        		$htmlBox .= "<tr style='height:5px;'><td></td></tr>";
				$htmlBox .= "<tr><th style='font-size:13px;'>Allgemein</th></tr>";
				$htmlBox .= "<tr><td style='border-top: 1px solid #ffffff;'></td></tr>";	
				$htmlBox .= '<tr><td>';
				$htmlBox .= "<div id='list'><table>";
				$htmlBox .= "<tr><td width=70>Laufzeit:</td><td>".$data['h_bst']." h</td>";
				$htmlBox .= "<td width=30></td>";
				$htmlBox .= "<td width=70>Suchzeit:</td><td>".$data['h_search']." h</td>";
				$htmlBox .= "<td width=30></td>";
				$htmlBox .= "<td width=100>Vollladungen:</td><td>".$data['count_c']."</td></tr>";
				$htmlBox .= "<tr><td>Mähzeit:</td><td>".$data['h_mow']." h</td>";
				$htmlBox .= "<td></td>";
				$htmlBox .= "<td>Ladezeit:</td><td>".$data['h_charge']." h</td>";
				$htmlBox .= "<td></td>";
				$htmlBox .= "<td>Fehler:</td><td>".$data['error']."</td></tr>";
				$htmlBox .= "</table></div></td></tr>";
				$htmlBox .= "<tr style='height:20px;'><td></td></tr>";
			// Suchzeiten
				$htmlBox .= "<tr><th style='font-size:13px;'>Suchzeiten</th></tr>";
				$htmlBox .= "<tr><td style='border-top: 1px solid #ffffff;'></td></tr>";		
				$htmlBox .= "<tr><td>";
				// Bargraph Suchzeiten erzeugen
				$htmlBox .= '<ul id="q-graph">';
				$htmlBox .= "<span><table>";
				$htmlBox .= "<tr><td width=60>Minimale Zeit:</td><td>".min($timearray['search_a'])." min</td></tr>";
				$htmlBox .= "<tr><td>Maximale Zeit:</td><td>".max($timearray['search_a'])." min</td></tr>";
				$htmlBox .= "<tr><td>Durchschnitt:</td><td>".floor((array_sum($timearray['search_a']) / count($timearray['search_a'])))." min</td></tr>";
				$htmlBox .= "</table></span>";
			
				for($i = 1; $i <= count($timearray['search_a']); $i++){
					$htmlBox .= '<li class="qtr" id="q'.$i.'">';
					$htmlBox .= '<ul>';
				
					$high = ((($conf_time['height'] - $conf_time['h_offset']) * $timearray['search_a'][$i-1]) / max($timearray['search_a']));
					if($high > 0) $htmlBox .= '<li class="time bar" style="height: '.$high.'px;"><p>'.$timearray['search_a'][$i-1].' min</p></li>';
					else $htmlBox .= '<li class="time bar" style="height: '.$high.'px;"><p style="margin:-15px 0 0;">'.$timearray['search_a'][$i-1].' min</p></li>';
				
					$htmlBox .= '</ul>';
					$htmlBox .= '</li>';
					}
				$htmlBox .= '</ul>';
				$htmlBox .= "</td></tr>";
			// Mähzeiten
				$htmlBox .= "<tr><th style='font-size:13px;'>Mähzeiten</th></tr>";
				$htmlBox .= "<tr><td style='border-top: 1px solid #ffffff;'></td></tr>";	
				$htmlBox .= "<tr><td>";
				// Bargraph Mähzeiten erzeugen
				$htmlBox .= '<ul id="q-graph">';
				$htmlBox .= "<span><table>";
				$htmlBox .= "<tr><td width=60>Minimale Zeit:</td><td>".min($timearray['mow_a'])." min</td></tr>";
				$htmlBox .= "<tr><td>Maximale Zeit:</td><td>".max($timearray['mow_a'])." min</td></tr>";
				$htmlBox .= "<tr><td>Durchschnitt:</td><td>".floor((array_sum($timearray['mow_a']) / count($timearray['mow_a'])))." min</td></tr>";
				$htmlBox .= "</table></span>";
				
				for($i = 1; $i <= count($timearray['mow_a']); $i++){
					$htmlBox .= '<li class="qtr" id="q'.$i.'">';
					$htmlBox .= '<ul>';
				
					$high = ((($conf_time['height'] - $conf_time['h_offset']) * $timearray['mow_a'][$i-1]) / max($timearray['mow_a']));
					if($high > 0) $htmlBox .= '<li class="time bar" style="height: '.$high.'px;"><p>'.$timearray['mow_a'][$i-1].' min</p></li>';
					else $htmlBox .= '<li class="time bar" style="height: '.$high.'px;"><p style="margin:-15px 0 0;">'.$timearray['mow_a'][$i-1].' min</p></li>';
				
					$htmlBox .= '</ul>';
					$htmlBox .= '</li>';
					}
				$htmlBox .= '</ul>';
				$htmlBox .= "</td></tr>";																																																																	
				if($timestamp == true) $htmlBox .= "<tr style='font-size:10px;text-align:right;'><td>Update: ".date("d.m.Y H:i:s")."</td></tr>";
				$htmlBox .= "</table>";
				$htmlBox .= "</div>";
				$htmlBox .= "<div style='clear:both;'></div>";
				$htmlBox .="</body>";

				$result = array();
				$result['status'] = true;

				// Mäh- und Suchzeiten auswerten
				IPS_SemaphoreEnter("openBufferTimeStat", 3000);
				$buffer = robo_GetSetBuffer("read");

				if(array_key_exists("bst", $buffer) === true){
					// Suchzeiten auswerten
					if(array_key_exists("search", $buffer['bst']) === true){
						// Prüfen ob Arrays gleich
						if($timearray['search_a'] === $buffer['bst']['search']){
							$result['search'] = false;
							}
						// Prüfen ob Arraylänge gleich
						elseif(count($timearray['search_a']) !== count($buffer['bst']['search'])){
							$new = count($timearray['search_a']);
							$old = count($buffer['bst']['search']);
							
							if(($new > $old) and (($new - $old) == 1)){
								$result['search'] = $timearray['search_a'][0];
								array_unshift($buffer['bst']['search'], $timearray['search_a'][0]);
								}
							else $result['search'] = false;
							}
						// Prüfen auf neuen Eintrag im Array
						elseif($timearray['search_a'] !== $buffer['bst']['search']){
							$new = $timearray['search_a'];
							$old = $buffer['bst']['search'];
							
							array_shift($new);
							array_pop($old);
							
							print_r($new);
							print_r($old);

							if($new === $old){
								$buffer['bst']['search'] = $timearray['search_a'];
								$result['search'] =  $timearray['search_a'][0];
								}
							else $result['search'] = false;
							}						
						else{
							$result['search'] = false;
							}
						}
					else{
						$buffer['bst']['search'] = $timearray['search_a'];
						$result['search'] = $timearray['search_a'][0];
						}
					// Mähzeiten auswerten
					if(array_key_exists("mow", $buffer['bst']) === true){
						// Prüfen ob Arrays gleich
						if($timearray['mow_a'] === $buffer['bst']['mow']){
							$result['mow'] = false;
							}
						// Prüfen ob Arraylänge gleich
						elseif(count($timearray['mow_a']) !== count($buffer['bst']['mow'])){
							$new = count($timearray['mow_a']);
							$old = count($buffer['bst']['mow']);
							
							if(($new > $old) and (($new - $old) == 1)){
								$result['mow'] = $timearray['mow_a'][0];
								array_unshift($buffer['bst']['mow'], $timearray['mow_a'][0]);
								}
							else $result['mow'] = false;
							}
						// Prüfen auf neuen Eintrag im Array
						elseif($timearray['mow_a'] !== $buffer['bst']['mow']){
							$new = $timearray['mow_a'];
							$old = $buffer['bst']['mow'];
							
							array_shift($new);
							array_pop($old);

							print_r($new);
							print_r($old);
							
							if($new === $old){
								$buffer['bst']['mow'] = $timearray['mow_a'];
								$result['mow'] =  $timearray['mow_a'][0];
								}
							else $result['mow'] = false;
							}						
						else{
							$result['mow'] = false;
							}
						}
					else{
						$buffer['bst']['mow'] = $timearray['mow_a'];
						$result['mow'] = $timearray['mow_a'][0];
						}
					
					if($result['search'] or $result['mow'] !== false){
						robo_GetSetBuffer("write", $buffer);
						}
					}
				else{
					$buffer['bst']['search'] = $timearray['search_a'];
					$buffer['bst']['mow'] = $timearray['mow_a'];
					$result['search'] = $timearray['search_a'][0];
					$result['mow'] = $timearray['mow_a'][0];
					robo_GetSetBuffer("write", $buffer);
					}			
				IPS_SemaphoreLeave("openBufferTimeStat");

				$result['data'] = $data;
				$result['htmlbox'] = $htmlBox;
				
				return $result;
				}
			else return $result['status'] = false;
			}
		else return $result['status'] = false;
		}
	else return $result['status'] = false;
	}
	

// Batteriedaten aufbereiten
function robo_GetBattery($content){
Global $conf_batt, $timestamp;
	if($content !== false){
		if(array_diff_key($content, $conf_batt['config']) === array_diff_key($conf_batt['config'], $content)){
			// Hintergrundfarbe umwandeln (hex -> rgb)
			if($conf_batt['tbg_true'] == true) list($tr, $tg, $tb) = sscanf($conf_batt['col_tbg'], "#%02x%02x%02x");
		
			$htmlBox = "<style type='text/css'>";
			if($conf_batt['tbg_true'] == false) $bgt = "none";
  			else $bgt = "rgba(".$tr.",".$tg.",".$tb.",".$conf_batt['oca_tbg'].")";
			$htmlBox .= "#btable {position:relative;float:left;background:".$bgt.";font-size:".$conf_batt['fsize']."px;padding:10px;}";
			$htmlBox .= "#bspacer {width:".($conf_batt['bwidth'] + $conf_batt['lwidth'] + $conf_batt['vwidth'] + 6)."px;height:5px;margin:auto;clear:both;}";
			$htmlBox .= "#bcaption {width:".($conf_batt['bwidth'] + $conf_batt['lwidth'] + $conf_batt['vwidth'] + 6)."px;height:15px;font-size:".($conf_batt['fsize'] + 2)."px;border-bottom:1px solid #FFFFFF;padding: 1px;}";
			$htmlBox .= "#blabel {float:left;background:none;width:".$conf_batt['lwidth']."px;height:".$conf_batt['bheight']."px;padding:1px;}";
			$htmlBox .= "#bvalue {float:left;background:none;width:".$conf_batt['vwidth']."px;height:".$conf_batt['bheight']."px;padding:1px;}";							
			$htmlBox .= "#bbase {float:left;width:".$conf_batt['bwidth']."px;height:".($conf_batt['bheight'] + 2)."px;}";
			$htmlBox .= "#bbg {background-color:".$conf_batt['col_bg'].";width:".$conf_batt['bwidth']."px;height:".($conf_batt['bheight'] - 6)."px;border:1px solid ".$conf_batt['col_bg'].";}";
			$htmlBox .= "#bbar {height:".($conf_batt['bheight'] - 6)."px;}";
			$htmlBox .= "</style>";	
			
			$htmlBox .= "<div id='btable'>";
			$htmlBox .= "<div id='bspacer'></div>";
		
			foreach($content as $key => $value){
				$htmlBox .= "<div>"; 				
				$htmlBox .= "<div id='blabel'>".$conf_batt['config'][$key]['name']."</div>";
				$htmlBox .= "<div id='bvalue'>".$value." ".$conf_batt['config'][$key]['unit']."</div>";
				$htmlBox .= "<div id='bbase'>";
				$htmlBox .= "<div id='bbg'>";
				if($value < 0) $htmlBox .= "<div id='bbar' style='float:right;background-color:".$conf_batt['col_minus']."; width:".(floor((abs($value) * 100) / $conf_batt['config'][$key]['factor']))."%;'></div></div>";
				if($value >= 0)$htmlBox .= "<div id='bbar' style='background-color:".$conf_batt['col_plus'].";width:".(floor((abs($value) * 100) / $conf_batt['config'][$key]['factor']))."%;'></div></div>";
				$htmlBox .= "</div></div>";
				$htmlBox .= "<div id='bspacer'></div>";
				}
			
			if($timestamp == true){
				//$htmlBox .= "<div id='bspacer'></div>";
				$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
				}	
			$htmlBox .= "</div>";
			return $htmlBox;
			}
		}
	else return false;
	}


// Motorendaten aufbereiten
function robo_GetDrives($content){
Global $conf_drive, $timestamp;
	if($content !== false){
		if(array_diff_key($content, $conf_drive['config']) === array_diff_key($conf_drive['config'], $content)){
			// Hintergrundfarbe umwandeln (hex -> rgb)
			if($conf_drive['tbg_true'] == true) list($tr, $tg, $tb) = sscanf($conf_drive['col_tbg'], "#%02x%02x%02x");

			$htmlBox = "<style type='text/css'>";
			if($conf_drive['tbg_true'] == false) $bgt = "none";
  			else $bgt = "rgba(".$tr.",".$tg.",".$tb.",".$conf_drive['oca_tbg'].")";
			$htmlBox .= "#dtable {position:relative;float:left;background:".$bgt.";font-size:".$conf_drive['fsize']."px;padding:10px;}";
			$htmlBox .= "#dspacer {width:".($conf_drive['bwidth'] + $conf_drive['lwidth'] + $conf_drive['vwidth'] + 6)."px;height:5px;margin:auto;clear:both;}";
			$htmlBox .= "#dcaption {width:".($conf_drive['bwidth'] + $conf_drive['lwidth'] + $conf_drive['vwidth'] + 6)."px;height:15px;font-size:".($conf_drive['fsize'] + 2)."px;border-bottom:1px solid #FFFFFF;padding: 1px;}";
			$htmlBox .= "#dlabel {float:left;background:none;width:".$conf_drive['lwidth']."px;height:".$conf_drive['bheight']."px;padding:1px;}";
			$htmlBox .= "#dvalue {float:left;background:none;width:".$conf_drive['vwidth']."px;height:".$conf_drive['bheight']."px;padding:1px;}";							
			$htmlBox .= "#dbase {float:left;width:".$conf_drive['bwidth']."px;height:".($conf_drive['bheight'] + 2)."px;}";
			$htmlBox .= "#dbg {background-color:".$conf_drive['col_bg'].";width:".$conf_drive['bwidth']."px;height:".($conf_drive['bheight'] - 6)."px;border:1px solid ".$conf_drive['col_bg'].";}";
			$htmlBox .= "#dbar {height:".($conf_drive['bheight'] - 6)."px;}";
			$htmlBox .= "</style>";	
			
			$htmlBox .= "<div id='dtable'>";
			$htmlBox .= "<div id='dcaption'>Fahrmotoren</div>";
			$htmlBox .= "<div id='dspacer'></div>";
			$htmlBox .= "<div id='dspacer'></div>";
		
			foreach($content as $key => $value){
				if($key == "pcutspeed"){
					$htmlBox .= "<div id='dspacer'></div>";
					$htmlBox .= "<div id='dcaption'>Mähmotor</div>";
					$htmlBox .= "<div id='dspacer'></div>";
					$htmlBox .= "<div id='dspacer'></div>";
					}

				$htmlBox .= "<div>"; 				
				$htmlBox .= "<div id='dlabel'>".$conf_drive['config'][$key]['name']."</div>";
				$htmlBox .= "<div id='dvalue'>".$value." ".$conf_drive['config'][$key]['unit']."</div>";
				$htmlBox .= "<div id='dbase'>";
				$htmlBox .= "<div id='dbg'>";
				if($value < 0) $htmlBox .= "<div id='dbar' style='float:right;background-color:".$conf_drive['col_minus']."; width:".(floor((abs($value) * 100) / $conf_drive['config'][$key]['factor']))."%;'></div></div>";
				if($value >= 0)$htmlBox .= "<div id='dbar' style='background-color:".$conf_drive['col_plus'].";width:".(floor((abs($value) * 100) / $conf_drive['config'][$key]['factor']))."%;'></div></div>";
				$htmlBox .= "</div></div>";
				$htmlBox .= "<div id='dspacer'></div>";
				}
			
			if($timestamp == true){
				//$htmlBox .= "<div id='dspacer'></div>";
				$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
				}	
			$htmlBox .= "</div>";
			return $htmlBox;
			}
		else return false;
		}
	else return false;
	}


// Fehlerspeicher aufbereiten
function robo_GetErrorList($content){
Global $conf_error, $timestamp;
	if($content !== false){
		if($content['successful'] == true){
			// Hintergrundfarbe umwandeln (hex -> rgb)
			if($conf_error['tbg_true'] == true) list($er, $eg, $eb) = sscanf($conf_error['col_tbg'], "#%02x%02x%02x");

			$htmlBox = "<style type='text/css'>";
			if($conf_error['tbg_true'] == false) $bgt = "none";
  			else $bgt = "rgba(".$er.",".$eg.",".$eb.",".$conf_error['oca_tbg'].")";
			$htmlBox .= "#etable {position:relative;float:left;background:".$bgt.";font-size:".$conf_error['fsize']."px;padding:10px;}";
			$htmlBox .= "#espacer {width:".($conf_error['dwidth'] + $conf_error['twidth'] + $conf_error['mwidth'])."px;height:5px;margin:auto;clear:both;}";
			$htmlBox .= "#edate {float:left;width:".$conf_error['dwidth']."px;height:".$conf_error['height']."px;padding:1px;}";
			$htmlBox .= "#etime {float:left;width:".$conf_error['twidth']."px;height:".$conf_error['height']."px;padding:1px;}";
			$htmlBox .= "#etext {float:left;width:".$conf_error['mwidth']."px;height:".$conf_error['height']."px;padding:1px;}";							
			$htmlBox .= "</style>";	

			if(array_key_exists("errors", $content) and array_key_exists("error", $content['errors']) === true){
       			$htmlBox ="<div id='etable'>";
				$htmlBox .= "<div id='espacer'></div>";
           			
				foreach($content['errors'] as $key => $value){
					$htmlBox .= "<div>";
           			$htmlBox .= "<div id='edate'>".$value['date']."</div>";
           			$htmlBox .= "<div id='etime'>".$value['time']."</div>";
           			$htmlBox .= "<div id='etext'> ".$value['error_message']."</div>";
           			$htmlBox .= "</div>";
					$htmlBox .= "<div id='espacer'></div>";
           			}
           			
				if($timestamp == true) $htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
           		$htmlBox .= "</div>";
				}         
           	else{
				$htmlBox .= "<div id='etable'>";
           		$htmlBox .= "<div style='font-size:".($conf_error['fsize'] + 2)."px;'>Fehlerspeicher ist leer</div>";
				if($timestamp == true){
					$htmlBox .= "<div id='espacer'></div>";
					$htmlBox .= "<div id='espacer'></div>";
					$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
					}
				$htmlBox .= "</div>";
				}
			return $htmlBox;
			}
		}
	return false;
	}

	
// Softwareversionen aufbereiten
function robo_GetVersion($api_content, $web_content, $debug = false){
Global $conf_version, $timestamp;
	if($debug == true){
		print_r($api_content)."
";
		print_r($web_content);
		}
		
	if($api_content and $web_content == true){
		// Hintergrundfarbe umwandeln (hex -> rgb)
		if($conf_version['tbg_true'] == true) list($vr, $vg, $vb) = sscanf($conf_version['col_tbg'], "#%02x%02x%02x");
				
		$htmlBox = "<style type='text/css'>";
		if($conf_version['tbg_true'] == false) $bgt = "none";
  		else $bgt = "rgba(".$vr.",".$vg.",".$vb.",".$conf_version['oca_tbg'].")";
		$htmlBox .= "#vtable {position:relative;float:left;background:".$bgt.";font-size:".$conf_version['fsize']."px;padding:10px;}";
		$htmlBox .= "#vspacer {width:".($conf_version['lwidth'] + $conf_version['vwidth'] + 10)."px;height:5px;margin:auto;clear:both;}";
		$htmlBox .= "#vcaption {width:".($conf_version['lwidth'] + $conf_version['vwidth'] + 10)."px;height:18px;font-size:".($conf_version['fsize'] + 2)."px;border-bottom:1px solid #FFFFFF;padding: 1px;}";
		$htmlBox .= "#vlabel {float:left;width:".$conf_version['lwidth']."px;height:".$conf_version['height']."px;padding:1px;}";
		$htmlBox .= "#vvalue {float:left;width:".$conf_version['vwidth']."px;height:".$conf_version['height']."px;padding:1px;}";							
		$htmlBox .= "</style>";		

		$htmlBox .="<div id='vtable'>";
		
		if($web_content == true){
			preg_match_all( "/>(.*)</U", trim($web_content, "\x00..\x1F"), $result);
		
			$array = array_merge(array_filter($result[1]));
			foreach($array as $key => $value){
				if($value == "Seriennummer:") $info['serial'] = $array[$key+1];
				elseif($value == "Produktion:") $info['product'] = $array[$key+1];
				elseif($value == "MSW-Software:") $info['mswsoft'] = preg_replace('{[ 	]+}', '', $array[$key+1]);
				elseif($value == "MSW-Version:") $info['mswver'] = $array[$key+1];
				elseif($value == "MSW-Datum:") $info['mswdate'] = $array[$key+1];
				elseif($value == "SUB-Version:") $info['subver'] = $array[$key+1];
				}
			
			$htmlBox .= "<div id='vcaption'>Gerätekonfiguration</div>";
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div id='vlabel'>Seriennummer:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['serial']."</div>";
			$htmlBox .= "<div><div id='vlabel'>Produktion:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['product']."</div></div>";
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div id='vcaption'>Geräteversion</div>";
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div><div id='vlabel'>MSW-Software:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['mswsoft']."</div></div>";
			$htmlBox .= "<div><div id='vlabel'>MSW-Version:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['mswver']."</div></div>";
			$htmlBox .= "<div><div id='vlabel'>MSW-Datum:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['mswdate']."</div></div>";
			$htmlBox .= "<div><div id='vlabel'>SUB-Version:</div>";
			$htmlBox .= "<div id='vvalue'>".$info['subver']."</div></div>";
			$htmlBox .= "<div id='vspacer'></div>";	
			$htmlBox .= "<div id='vspacer'></div>";
			}

		if($api_content['successful'] == true){
			foreach($api_content as $key => $value){
				if($key == "robonect"){
					$htmlBox .= "<div id='vcaption'>Robonect</div>";
					$htmlBox .= "<div id='vspacer'></div>";
					$htmlBox .= "<div>";
					$htmlBox .= "<div id='vlabel'>Seriennummer:</div>";
					$htmlBox .= "<div id='vvalue'>".$api_content[$key]['serial']."</div>";
					$htmlBox .= "</div>";
					$htmlBox .= "<div id='vspacer2'></div>";
					$htmlBox .= "<div>";
					$htmlBox .= "<div id='vlabel'>Firmware-Version:</div>";
					$htmlBox .= "<div id='vvalue'>".$api_content[$key]['version']."</div>";
					$htmlBox .= "</div>";
					$htmlBox .= "<div id='vspacer2'></div>";
					$htmlBox .= "<div>";
					$htmlBox .= "<div id='vlabel'>Firmware-kompiliert:</div>";
					$htmlBox .= "<div id='vvalue'>".$api_content[$key]['compiled']."</div>";
					$htmlBox .= "</div>";
					$htmlBox .= "<div id='vspacer2'></div>";
					$htmlBox .= "<div>";
					$htmlBox .= "<div id='vlabel'>Firmware-Bemerkung:</div>";
					$htmlBox .= "<div id='vvalue'>".$api_content[$key]['comment']."</div>";
					$htmlBox .= "</div>";
					$htmlBox .= "<div id='vspacer'></div>";	
					}
				}
			}
				
		if($timestamp === true){	
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div id='vspacer'></div>";
			$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
			}
		
		$htmlBox .="</div>";
		return $htmlBox;
		}
	else return false;
	}	
	

// Bild vom Modul laden
function robo_GetPicture($debug = false){
Global $cdata, $parents, $conf_cam, $overlay;

	$conn = robo_GetVariable("roboVarConnState", "roboVarID");
	if($conn == true){
		// Url zum Bild
   		$url = "/cam.jpg";
		
		// Verzeichnis prüfen und bei nicht vorhanden sein anlegen
		$path = IPS_GetKernelDir().join(DIRECTORY_SEPARATOR, array(str_replace(array("\\", "/"), DIRECTORY_SEPARATOR, $conf_cam['path'])));
		if(is_dir($path) == false) mkdir($path);
		
		$media_orig = IPS_GetKernelDir().join(DIRECTORY_SEPARATOR, array(str_replace(array("\\", "/"), DIRECTORY_SEPARATOR, $conf_cam['path']), $conf_cam['oldpic']));
		$media = IPS_GetKernelDir().join(DIRECTORY_SEPARATOR, array(str_replace(array("\\", "/"), DIRECTORY_SEPARATOR, $conf_cam['path']), $conf_cam['newpic']));

   		// Bild laden
		$data = url_get_contents($url, $debug);

   		if($data == true){
       		// Bild Speichern
       		file_put_contents($media_orig, $data);
            
       		// Bild um 180° drehen
       		$source = imagecreatefromjpeg($media_orig);
       		$rotate = imagerotate($source, 180, 0);
       		ImageDestroy($source);
			
			// Bild Overlay erstellen
			if($conf_cam['date'] or $conf_cam['status'] == true){
				$status = robo_GetVariable("roboVarStatLong","roboVarID");
				$color = explode(",", $overlay['color']);
				$col = imagecolorallocate($rotate, $color[0], $color[1], $color[2]);
			
				if($conf_cam['date'] and $conf_cam['status'] == true) imagestring($rotate, 4, 5, 460, date("d.m.Y H:i:s")." | Status: ".utf8_decode($status), $col);
				elseif($conf_cam['date'] == true) imagestring($rotate, 4, 5, 460, date("d.m.Y H:i:s"), $col);
				elseif($conf_cam['status'] == true) imagestring($rotate, 4, 5, 460, utf8_decode($status), $col);
						
				imageline($rotate, 0, 455, 640, 455, $col);
       			}
			imagejpeg($rotate, $media, 100);
			
			// Bild in IPS verknüpfen
       		$result = CreateMediaImage($parents['roboMediaID'], "Bild", "roboPicture", 1, $rotate, $media, 10, false);
       		ImageDestroy($rotate);
       		}
		return $result;
		}
	return $result;
	}
		
/*******************************************************************************
*******************************************************************************/

function url_get_contents($url, $debug = false){
Global $cdata;

	if($url !== ""){
    	$options = array(
    		'http' => array(
           		'method' => "GET",
           		'header' => "Connection: close
". 
		   			"Authorization: Basic ".base64_encode($cdata['user'].":".$cdata['pass'])."
",
           		'timeout' => 3
        		)
    		);
    	
		$context = stream_context_create( $options );
    	$content = @file_get_contents("http://".$cdata['ip'].$url, false, $context);

    	if(!$content){
			if($debug == true) echo "Meldung von \"url_get_contents\": ".error_get_last()['message']."
";
			return false;
			}
    	else{
			if($debug == true) echo $http_response_header[0]."

";
			if($debug == true) echo $content;
			
			if(substr($http_response_header[0], 9, -3) == 200) return $content;
			else return false;
			}
		}
	else{
		if($debug == true) echo "Meldung von \"url_get_contents\": Logindaten falsch - Daten in keinem Array -> array(\"user\"=> \"username\", \"pass\"=> \"passwort\")
";
		return false;
		}
	}


// Funktion - XML-String aufbereiten
function robo_get_xmltojson($content, $debug = false){
	if(trim($content) !== ''){
    	libxml_use_internal_errors(true);
        $xml = simplexml_load_string($content);

        $errors = libxml_get_errors();
        libxml_clear_errors();

		if(empty($errors)){
			$array = objtoArray($xml);
			
			if(array_key_exists("successful", $array)){
				if($array['successful'] === "false") $array['successful'] = false;
				elseif($array['successful'] === "true") $array['successful'] = true;
				}
			if($debug == true) print_r($array);
			return $array;
			}
		else{
			if($debug == true){
				echo "Meldung von \"robo_get_xmlstring\":

";
				print_r($errors)."
";
				}
			return false;
			}								
    	}
	else return false;		
	}


// Funktion - Website prasen	
function robo_json_decode($content, $cutoff, $mixed, $debug = false){
	if($content !== false){
		$data = urldecode($content);
		if($cutoff != ""){
			$data = strstr($data, $cutoff, true);
			$data = substr($data, 0, -1)."}";
			}
		$string = preg_replace(array("/:'/", "/'/", "/{/", "/,/"), array('":"', '"', '{"', ',"'), $data);
		$string = utf8_encode($string);
		if($debug == true) echo $string."
";
	
		$json = json_decode($string, true);
	
		if(json_last_error() === JSON_ERROR_NONE){
			if($mixed == false){
				foreach($json as $key => $value){
					if(strpos($value, ".") === false) $json[$key] = intval(substr(preg_replace('/[^0-9.-]/', '', $value), 3));
					else $json[$key] = floatval(substr(preg_replace('/[^0-9.-]/', '', $value), 3));
					}
				}
			else{
				if(array_key_exists("tjoin", $json)){
					$value = preg_replace(array("/.I/", "/Si/"), array(',I', ',Si'), trim($json['tjoin']));
					$array = explode(",", $value);
					if(count($array) == 3){
						$json['taddress'] = preg_replace('/[^0-9.]/', '', $array[1]);
						$json['tsignal'] = preg_replace('/[^0-9.-]/', '', $array[2]);
						array_shift($json);
						}
					}
				}
			return $json;
			}
		else{
			if($debug == true){
				$constants = get_defined_constants(true);
				$json_errors = array();
				foreach($constants["json"] as $name => $value){
    				if(!strncmp($name, "JSON_ERROR_", 11)) $json_errors[$value] = $name;
					}
				echo "Meldung von \"robo_json_decode\": JSON-Fehler -> ".$json_errors[json_last_error()]."
";
				}
			return false;
			}
		}
	else{
		if($debug == true) echo "Meldung von \"robo_json_decode\": Content ist leer
";
		return false;
		}
	}


// -----------------------------------------------------------------------------
/*******************************************************************************
********************************************************************************

	HILFSFUNKTIONEN

********************************************************************************
*******************************************************************************/

// Funktion - Object in Array konvertieren
function objtoArray($obj){
    if(is_object($obj)) $obj = (array)$obj;
    if(is_array($obj)){
       	$array = array();
       	foreach ($obj as $key => $val) $array[$key] = objtoArray($val);
    	}
	else $array = $obj;
    return $array;
	}
	
// Funktion Zeit berechnen (Array)
function timespanArray($seconds){ 
	$td['total'] = $seconds; 
    $td['sec'] = $seconds % 60; 
    $td['min'] = (($seconds - $td['sec']) / 60) % 60; 
    $td['hrs'] = (((($seconds - $td['sec']) /60) - $td['min']) / 60) % 24; 
    $td['day'] = floor( ((((($seconds - $td['sec']) /60)- $td['min']) / 60) / 24) ); 
	      
    return $td;
    }
 	
/*******************************************************************************
*******************************************************************************/

?>

Schon mal eine Timer-Nummer angewählt und dann den Button Timer auslesen benutzt?
Die Timer müssen einzeln und manuell ausgelesen werden.
Ein Auslesen der Daten bei der Installation würde mehr als 20 Sekunden dauern und es gab bei
meinen Tests diesbezüglich immer wieder Verbindungsabbrüche.

Da man jeden Timer einzeln abfragen muss.
Es gibt keinen API-Befehl um eine komplette Liste mit einer Abfrage zu erhalten.

Mhm, also bei mir gibt es diesbezüglich im Grunde keine Probleme.
Es kommt aber immer wieder mal vor, dass die Antwort von der Robonect API einen Fehler meldet,
obwohl der Auftrag auf der Robonect Website aufscheint.

Und was auch des öfteren vorkommt, man sendet einen Mähauftrag aus IPS und der Mähauftrag
wird auch auf der Robonect Website angezeigt aber den Mäher interessiert das reichlich wenig :smiley:

Der Mäher fährt erst los, wenn ich den gleichen Mähauftrag auf der Robonect Website erneut eingebe.

…da passiert etwas. Danke. Ich bekomme im Moment nur noch eineMeldung "Warning: Instance #0 does not exist in …Robo_Steuern.ips.php on line 282. Ich versuche aber ersteinmal selber weiter, ggf. muss ich dann noch einmal auf dich zurück kommen…

Vielen Dank!

Bei mir ist es das gleich manche Felder bleiben leer.

Betriebstunden/ Tag und Zeit einstellung zB. reste läuf super !
Habt Ihre schon eine Lösung?

Gruß
Thomas

Hallo Manni,

ich habe heute die Preview auf die Ver. 1.0 installiert, läuft so weit ganz gut mit deine Scripten.

Allerdings habe ich mit der Ver. 1.0 wieder das Problem das der Status bei jedem auslesen von schläft auf parkt wechselt und leider der Robi diesen wieder mit piepsen quittiert.

Wenn Du dann so weit bist die Firmware auch auf Deinem Mäher zu installieren würde ich mich über ein Update des Auslese-Scriptes freuen. :smiley:

Na das könnte jetzt aber länger dauern, bin bis Anfang August noch in Südafrika unterwegs.

Gesendet von meinem D6633 mit Tapatalk

Super, was machst Du dort, beruflich oder Urlaub?

Nee macht ja auch nichts ist ja „nur“ eine Preview, evtl. erledigt sich das ja auch von selber :wink:

Freiwillig Urlaub in Südafrika, na mit Sicherheit nicht, da gibt’s besseres.

Beruflich hat man keine Wahl, da geht’s dahin wo man gebraucht wird. Wobei SA immer noch besser ist wie der Rest von dem Kontinent.

Gesendet von meinem D6633 mit Tapatalk

Hi,

entweder ich stehe völlig aufm de Schlauch oder ich werde alt.

Ich benutze dein Modul für die Steuerung meines Rasenroboters, das funktioniert auch wunderbar, danke dafür schonmal.

Nun wollte ich den Roboter per Alexa starten und stoppen, komme allerdings nicht weiter.

Wie kann ich per Script den manuellen Modus aktivieren und auch den Feierabend Modus aktivieren damit ich ihn mit Alexa und „starten“ und „stoppen“ kann.
Kann ich deine Script irgendwie dafür benutzen?

Danke

Hi Mani
ich gehe davon aus, dass hier die XML to Array Umwandlung schuld ist.
Das XML sieht so aus:

<?xml version="1.0" encoding="UTF-8" ?>
	<robonect>
		<errors>
			<error>
				<error_code>1</error_code>
				<error_message>Nummer3 hat Arbeitsbereich überschritten</error_message>
				<date>27.07.2017</date>
				<time>09:04:39</time>
				<unix>1501146279</unix>
			</error>
			<error>
				<error_code>1</error_code>
				<error_message>Nummer3 hat Arbeitsbereich überschritten</error_message>
				<date>10.07.2017</date>
				<time>09:04:35</time>
				<unix>1499677475</unix>
			</error>
...

Ich habe bei mir die Umwandlung XmlToArray rausgenommen und das XML direkt verwendet. So kann der Fehlerspeicher ausgelesen werden.
Durch die Anpassung im Auslese Script musste ich die Funktion robo_GetErrorList ändern.
Anbei die Anpassungen.
Auslesescript:


		// *****************************************************************************	
		// API - Fehlerspeicher
		if ((robo_TimeCheck("roboBoxErrorList", "roboBoxID", $getDataTime['apierror'])
			or $stopped
			or $forced_update == true)
			and (!$sleep))
		{
			IPS_LogMessage ("RobiAusleseScript", "Fehlerspeicher auslesen");
			$api_content = url_get_contents($getDataUrl['apierror'], $debug);
			$xml_Error = new SimpleXMLElement($api_content);
			if ($xml_Error->successful == "true")
				robo_SetVariable("roboBoxErrorList", "roboBoxID", robo_GetErrorList($xml_Error));
/*			$api_error = robo_get_xmltojson($api_content, $debug);	
			if($api_error['successful'] == true)
				robo_SetVariable("roboBoxErrorList", "roboBoxID", robo_GetErrorList($api_error));
*/
		}

Funktionen:


// Fehlerspeicher aufbereiten
function robo_GetErrorList($content)
{
	Global $conf_error, $timestamp;
	if($content !== false)
	{
		if($content->successful == "true")
		{
			// Hintergrundfarbe umwandeln (hex -> rgb)
			if($conf_error['tbg_true'] == true)
				list($er, $eg, $eb) = sscanf($conf_error['col_tbg'], "#%02x%02x%02x");
			$htmlBox = "<style type='text/css'>";
			if($conf_error['tbg_true'] == false)
				$bgt = "none";
  			else
				$bgt = "rgba(".$er.",".$eg.",".$eb.",".$conf_error['oca_tbg'].")";
			$htmlBox .= "#etable {position:relative;float:left;background:".$bgt.";font-size:".$conf_error['fsize']."px;padding:10px;}";
			$htmlBox .= "#espacer {width:".($conf_error['dwidth'] + $conf_error['twidth'] + $conf_error['mwidth'])."px;height:5px;margin:auto;clear:both;}";
			$htmlBox .= "#edate {float:left;width:".$conf_error['dwidth']."px;height:".$conf_error['height']."px;padding:1px;}";
			$htmlBox .= "#etime {float:left;width:".$conf_error['twidth']."px;height:".$conf_error['height']."px;padding:1px;}";
			$htmlBox .= "#etext {float:left;width:".$conf_error['mwidth']."px;height:".$conf_error['height']."px;padding:1px;}";							
			$htmlBox .= "</style>";	
			if (($content->error != null) and ($content->errors->error != null))
			{
       			$htmlBox ="<div id='etable'>";
				$htmlBox .= "<div id='espacer'></div>";
           		foreach($content->errors->error as $value)
				{
					$htmlBox .= "<div>";
           			$htmlBox .= "<div id='edate'>".$value->date."</div>";
           			$htmlBox .= "<div id='etime'>".$value->time."</div>";
           			$htmlBox .= "<div id='etext'>".$value->error_message."</div>";
           			$htmlBox .= "</div>";
					$htmlBox .= "<div id='espacer'></div>";
           		}
				if($timestamp == true)
					$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
           		$htmlBox .= "</div>";
			}         
           	else
			{
				$htmlBox .= "<div id='etable'>";
           		$htmlBox .= "<div style='font-size:".($conf_error['fsize'] + 2)."px;'>Fehlerspeicher ist leer</div>";
				if($timestamp == true)
				{
					$htmlBox .= "<div id='espacer'></div>";
					$htmlBox .= "<div id='espacer'></div>";
					$htmlBox .= "<div style='font-size:10px;text-align:right;'>Update: ".date("d.m.Y H:i:s")."</div>";
				}
				$htmlBox .= "</div>";
			}
			return $htmlBox;
		}
	}
	return false;
}

Da ich erst seit zwei Tagen mich mit PHP befasse ist der Code sicher noch nicht optimal.

Hallo,

mir wurde gerade im Robonect Forum berichtet, dass das Auslesen per API Request das „Schlafen“ des Mähers verhindern (kann).

Wenn ich es richtig verstehe schläft der Mäher aber trotzdem ein, oder? Dieses entnehme ich auch der Statusmeldung aus de IPS Konsole die sich jedoch alle 15 Sekunden aktualisiert? Ich blicke nicht durch den komplette Code durch muss ich sagen :banghead:. Wie ist das genau???

Hintergrund meiner Nachfrage im Robonect Forum war auch, warum meine Alarmanlage nicht mehr funktioniert (s. link unten) da ist auch der IPS - API Request der „Böse“… Wie habt ihr das geregelt?

http://www.robonect.de/viewtopic.php?f=29&t=1162

1.jpg

Hallo,
an alle habt ihr schon eine Lösung für das aufwecken bei der Version 1.0 ?
Wenn ja könnt ihr das bitte teilen ?!

Danke schon mal an alle im Voraus
Gruß
Thomas

Hallo, ich nochmal keiner eine Lösung ?

Wäre für jede Hilfe dankbar !
Thomas

Ist die 1.0 mittlerweile offiziell?

Gesendet von meinem D6633 mit Tapatalk

Nein, ist noch nicht offiziell.

Gesendet von meinem SM-T805 mit Tapatalk

Hallo,
offiziell ist sie noch nicht aber für die 4 Rad Modelle besser weil mehr einstell Möglichkeiten vorhanden sind!
@manni hast du schon Lösung oder Idee ?

Thomas