So jetzt läuft alles. Musste die Case Reihenfolge ändern, so wie es auch in der Siemens Logo abläuft. Nutze es für die Pool Dosiersteuerung mit einer Siemens Logo.
<?php
/**********************************************************
*
* Toggle-Button für Lampen
* 1. Integer-Variable anlegen unterhalb des Devices (z.B. Lampe)
* 2. Variablen-Profil anlegen (Integer mit Range 0-1, Schrittweite 1)
* 3. Skript an Integer-Variable verknüpfen (Eigene Aktion)
*
**********************************************************/
// Variablen-ID der Integer-Variable aus 1.
$myIntValID = 10169;
// Names des Variablen-Profils aus 2.
$myVariableProfile = "PhToogleAutomatik";
// ID eines Homematic-Devices, falls dies gleich geschalten werden soll
$myDevice = 21788;
if($_IPS['SENDER'] == "Execute")
{
$value = IPS_GetVariableProfile($myVariableProfile);
switch($value['Associations'][0]['Value'])
{
case 0:
toggleOff($myIntValID, $myVariableProfile, $myDevice);
break;
case 1:
toggleOn($myIntValID, $myVariableProfile, $myDevice);
break;
case 2:
toggleAuto($myIntValID, $myVariableProfile, $myDevice);
break;
}
}
if($_IPS['SENDER'] == "WebFront")
{
switch($_IPS['VALUE'])
{
case 0:
toggleOff($myIntValID, $myVariableProfile, $myDevice);
break;
case 1:
toggleOn($myIntValID, $myVariableProfile, $myDevice);
break;
case 2:
toggleAuto($myIntValID, $myVariableProfile, $myDevice);
break;
}
}
function toggleOff($myIntValID, $myVariableProfile, $myDevice)
{
// Delete VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 0, "", "", -1);
// Set new VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 1, "Ph Dosierung An", "", 0x00FF00);
// Switch Relais
S7_WriteBit(21788 ,FALSE);
S7_WriteBit(21788 ,TRUE);
// Set Value Integer
SetValueInteger($myIntValID , 1);
}
function toggleOn($myIntValID, $myVariableProfile, $myDevice)
{
// Delete VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 1, "", "", -1);
// Set new VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 2, "Ph Dosierung Auto", "", 0x0080ff);
// Switch Relais
S7_WriteBit(21788 ,FALSE);
S7_WriteBit(21788 ,TRUE);
// Set Value Integer
SetValueInteger($myIntValID , 2);
}
function toggleAuto($myIntValID, $myVariableProfile, $myDevice)
{
// Delete VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 2, "", "", -1);
// Set new VariableProfileAssociation
IPS_SetVariableProfileAssociation($myVariableProfile, 0, "Ph Dosierung Aus", "", 0xFF0000);
// Switch Relais
S7_WriteBit(21788 ,FALSE);
S7_WriteBit(21788 ,TRUE);
// Set Value Integer
SetValueInteger($myIntValID ,0);
}
Danke
richimaint