Hier ein Skript zum Schalten und Auslesen eines ELV IPIO88.
Lediglich die IP Adresse muss eingetragen werden.
Das Skript erstellt automatisch die 8 Ausgänge.
Zum Auslesen einfach ein zyklisches Ereignis anhängen.
<?
// Anzupassende Variablen
$ip = "192.168.1.1"; // IP Adresse des IPIO88
// Skriptbeginn
// Auslesen
if($_IPS['SENDER'] == "Execute" || $_IPS['SENDER'] == "TimeEvent") {
$html = file_get_contents("http://".$ip."/ipio.cgi");
$exploded = explode('<input name="out', $html);
for ($i = 1; $i <= 8; $i++){
$vid = CreateVariableByIdent($_IPS['SELF'], "A".$i, "Ausgang (".$i.")", 0, "~Switch", $_IPS['SELF']);
if (substr($exploded[$i], 3, 17) == 'checked="checked"'){
if (!GetValueBoolean($vid)) {
SetValueBoolean($vid, true);
}
} else {
if (GetValueBoolean($vid)) {
SetValueBoolean($vid, false);
}
}
}
// Schalten
} else if($_IPS['SENDER'] == "WebFront") {
SetValueBoolean($_IPS['VARIABLE'], $_IPS['VALUE']);
$request = "http://$ip/ipio.cgi?pg=main";
for ($i = 1; $i <= 8; $i++){
$vid = IPS_GetObjectIDByIdent("A".$i, $_IPS['SELF']);
if (GetValueBoolean($vid)){
$request .= "&out$i=on";
}
}
$request .= "&end=main";
file_get_contents($request);
}
// Funktionen
// Variablen erstellen
function CreateVariableByIdent($id, $ident, $name, $type, $profile, $action) {
$vid = @IPS_GetObjectIDByIdent($ident, $id);
if($vid === false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetIdent($vid, $ident);
}
IPS_SetVariableCustomProfile($vid, $profile);
IPS_SetVariableCustomAction($vid, $action);
return $vid;
}
?>
Grüße
Pio