Hallo zusammen,
ich habe mir gerade auf der IPS View Seite das HowTo für die Kameraeinbindung reingezogen und man kann hier eigentlich nichts falsch machen. Jedoch bekomme ich es nicht zum laufen. Man braucht ja „nur“ die korrekte Adresse für den Pictureabgriff der Cam. Diese Adresse funktioniert per Browser und auch per Stringvariable mit HTML Box. (Nur weiß ich nicht wie ich die HMTL Box aktualisieren kann per Timer, sonst hätte ich die HTML Box verwendet)
<img src=„http://BENUTZER:PASSWORD@192.168.2.73//Streaming/channels/2/picture“ style=„width: 100%; height: 100%;“ >
Hier das Script aus dem How To:
<?
/**
* @file IPSView_CameraImageRefresh.ips.php
* @author brownson
* @version
* Version 1.0, 2015-05-02 brownson: Initiale Version<br/>
*
* Skript um ein MediaImage einer Kamera zu erzeugen und periodisch zu
* aktualisieren
*
* Konfiguration Einstellungen:
* CAM_IMAGE_URL ... URL des Kamera Bildes
* CAM_NAME ... Name der Kamera
* CAM_REFRESH_SEC ... Aktualisierungsinterval in Sekunden
*
*/
/*
* Konfiguration:
* -------------------------------------------------------------------------
*/
define ('CAM_IMAGE_URL', 'http://BENUTZER:PASSWORD@192.168.2.73//Streaming/channels/2/picture');
define ('CAM_NAME', 'vorne');
define ('CAM_REFRESH_SEC', 10);
/*
* Programmlogik:
* -------------------------------------------------------------------------
*/
$scriptID = $_IPS['SELF'];
$sender = $_IPS['SENDER'];
$parentID = IPS_GetParent($scriptID);
$filename = IPS_GetKernelDir().'media/'.CAM_NAME.'.jpg';
$mediaID = CreateMedia ('Image', $parentID, $filename);
CreateTimer_CyclicBySeconds ('RefreshTimer', $scriptID, CAM_REFRESH_SEC);
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL, CAM_IMAGE_URL);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 3);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle, CURLOPT_FAILONERROR, true);
$fileContent = curl_exec($curl_handle);
curl_close($curl_handle);
if ($fileContent===false) {
IPS_LogMessage(__file__, 'File "'.CAM_IMAGE_URL.'" could NOT be found on the Server !!!');
return;
}
$result = file_put_contents($filename, $fileContent);
if ($result===false) {
IPS_Sleep(1000);
$result = file_put_contents($filename, $fileContent);
}
if ($result===false) {
IPS_LogMessage(__file__, 'Error writing File Content to '.$filename);
return;
}
/*
* Funktionen:
* -------------------------------------------------------------------------
*/
function CreateMedia ($Name, $ParentId, $FileName) {
$MediaId = @IPS_GetMediaIDByName($Name, $ParentId);
if ($MediaId === false) {
$MediaId = IPS_CreateMedia(1);
IPS_SetParent($MediaId, $ParentId);
IPS_SetName($MediaId, $Name);
IPS_SetPosition($MediaId, 0);
}
IPS_SetMediaFile($MediaId, $FileName, false);
return $MediaId;
}
function CreateTimer_CyclicBySeconds ($name, $parentId, $seconds) {
$timerId = @IPS_GetObjectIDByIdent($name, $parentId);
if ($timerId === false) {
$timerId = IPS_CreateEvent(1 /*Cyclic Event*/);
IPS_SetParent($timerId, $parentId);
IPS_SetName($timerId, $name);
IPS_SetIdent($timerId, $name);
if (!IPS_SetEventCyclic($timerId, 2 /*Daily*/, 1 /*Int*/,0 /*Days*/,0/*DayInt*/,1/*TimeType Sec*/,$seconds/*Sec*/)) {
die ("IPS_SetEventCyclic failed !!!");
}
IPS_SetEventActive($timerId, true);
echo 'Created Timer '.$name.'='.$timerId."".PHP_EOL;
}
return $timerId;
}
?>
Fehlermeldung:
Jemand eine idee was ich hier flasch mache ?
Meine Cam: Trendnet TV-IP311PI
Gruß
Christian