Event Timer erzeugt neuen Integer

Hallo,
seit dem Update auf 4.0 habe ich Probleme mit meinen Event-Timern.
Bei jedem Aufruf wird nun ein neuer Integer erzeugt.
Bei 3.4 war dies nicht.
Jemand eine Lösung?
Danke

Script:


<?

 $max = 60;
 $step = 1; //Schrittgröße

 function on() {
   IPS_LogMessage("Eieruhr", "Aktiviert!");
 }
 function off() {
   IPS_LogMessage("Eieruhr", "Abgelaufen...");
 }

//Ab hier nichts mehr verändern
 $min = 0;
 $suffix = "min";
 $vpn = "EggTimer.".$max.".".$step;
 if($IPS_SENDER == "Execute")
 {
   if(IPS_VariableProfileExists($vpn))
        IPS_DeleteVariableProfile($vpn);
    IPS_CreateVariableProfile($vpn, 1);
    IPS_SetVariableProfileValues($vpn, $min, $max, 0);
    IPS_SetVariableProfileIcon($vpn, "Clock");
    IPS_SetVariableProfileAssociationEx($vpn, $min-2, "Aus", "", 0xFF0000);
    IPS_SetVariableProfileAssociationEx($vpn, $min-1, "-", "", -1);
    IPS_SetVariableProfileAssociationEx($vpn, $min, "%d ".$suffix, "", 0x00FF00);
    IPS_SetVariableProfileAssociationEx($vpn, $max+1, "+", "", -1);
   $vid = CreateParentVariable($IPS_SELF, "Timer", 1);
   IPS_SetVariableCustomProfile($vid, $vpn);
   IPS_SetVariableCustomAction($vid, $IPS_SELF);
   SetValue($vid, $min-2);
 }
 else if($IPS_SENDER == "WebFront")
 {
        switch($IPS_VALUE)
        {
           case $min-2:
              doOff();
              break;
           case $min-1:
              $IPS_VALUE = GetValue($IPS_VARIABLE) - $step;
              if($IPS_VALUE <= 0)
              {
                    $IPS_VALUE = -2;
                    doOff();
              }
              break;
           case $max+1:
              $IPS_VALUE = min($max, max(0, GetValue($IPS_VARIABLE)) + $step);
             doOn();
             break;
            default:
                return;
        }
      SetValue($IPS_VARIABLE, $IPS_VALUE);
 }
 else if($IPS_SENDER == "TimerEvent")
 {
   $vid = CreateParentVariable($IPS_SELF, "Timer", 1);
    $v = GetValue($vid);
    $v--;
    if($v <= 0)
    {
       doOff();
        IPS_SetScriptTimer($IPS_SELF, 0);
        $v = $min-2;
    }
    SetValue($vid, $v);
 }

function doOn()
{
   global $IPS_SELF;
    if(IPS_GetScriptTimer($IPS_SELF) == 0)
    {
        IPS_SetScriptTimer($IPS_SELF, 60);
        on();
    }
}

function doOff()
{
   global $IPS_SELF;
    IPS_SetScriptTimer($IPS_SELF, 0);
    off();
}

function CreateParentVariable($id, $name, $type)
{
    global $IPS_SELF;
    $vid = IPS_GetParent($IPS_SELF);
     if(!IPS_VariableExists($vid))
     {
         $vid = false;
     }
     else
     {
       $v = IPS_GetVariable($vid);
       if($v['VariableValue']['ValueType'] != $type)
          $vid = false;
     }
    if($vid === false)
    {
        $vid = IPS_CreateVariable($type);
        IPS_SetParent($vid, IPS_GetParent($IPS_SELF));
        IPS_SetParent($id, $vid);
        IPS_SetName($vid, $name);
        IPS_SetInfo($vid, "this variable was created by script #$IPS_SELF");
        IPS_SetHidden($id, true);
    }
    return $vid;
}

function IPS_SetVariableProfileAssociationEx($vpn, $av, $an, $ai, $ac)
{
    if(floatval(IPS_GetKernelVersion()) <= 2.3)
    {
        IPS_SetVariableProfileAssociation($vpn, $av, $an, $ai);
    } else {
        IPS_SetVariableProfileAssociation($vpn, $av, $an, $ai, $ac);
    }
}

?>

Alle verwendeten „$IPS_…“ Variablen gibt es seit Jahren nur noch in den Kompatibiliätsfunktionen, du solltest erstmal komplett auch „$_IPS[’…’]“ korrigieren ;). Infos dazu findest du unter Systemvariablenin der Hilfe.

$v[‚VariableValue‘][‚ValueType‘] <-- Das ist nicht mehr aktuell

paresy

Danke :slight_smile:
werd mich gleich mal ans werk machen :banghead:

Hallo,
habe mal geändert.
Keine Änderung :eek:
Wo hänge ich fest? :confused:

Script:

<?

$max = 60;
$step = 1; //Schrittgröße

function on() {
IPS_LogMessage(„Eieruhr“, „Aktiviert!“);
}
function off() {
IPS_LogMessage(„Eieruhr“, „Abgelaufen…“);
}

//Ab hier nichts mehr verändern
$min = 0;
$suffix = „min“;
$vpn = „EggTimer.“.$max.".".$step;
if($_IPS[‚SENDER‘] == „Execute“)
{
if(IPS_VariableProfileExists($vpn))
IPS_DeleteVariableProfile($vpn);
IPS_CreateVariableProfile($vpn, 1);
IPS_SetVariableProfileValues($vpn, $min, $max, 0);
IPS_SetVariableProfileIcon($vpn, „Clock“);
IPS_SetVariableProfileAssociationEx($vpn, $min-2, „Aus“, „“, 0xFF0000);
IPS_SetVariableProfileAssociationEx($vpn, $min-1, „-“, „“, -1);
IPS_SetVariableProfileAssociationEx($vpn, $min, "%d ".$suffix, „“, 0x00FF00);
IPS_SetVariableProfileAssociationEx($vpn, $max+1, „+“, „“, -1);
$vid = CreateParentVariable($_IPS[‚SELF‘], „Timer“, 1);
IPS_SetVariableCustomProfile($vid, $vpn);
IPS_SetVariableCustomAction($vid, $_IPS[‚SELF‘]);
SetValue($vid, $min-2);
}
else if($_IPS[‚SENDER‘] == „WebFront“)
{
switch($_IPS[‚VALUE‘])
{
case $min-2:
doOff();
break;
case $min-1:
$_IPS[‚VALUE‘] = GetValue($_IPS[‚VARIABLE‘]) - $step;
if($_IPS[‚VALUE‘] <= 0)
{
$_IPS[‚VALUE‘] = -2;
doOff();
}
break;
case $max+1:
$_IPS[‚VALUE‘] = min($max, max(0, GetValue($_IPS[‚VARIABLE‘])) + $step);
doOn();
break;
default:
return;
}
SetValue($_IPS[‚VARIABLE‘], $_IPS[‚VALUE‘]);
}
else if($_IPS[‚SENDER‘] == „TimerEvent“)
{
$vid = CreateParentVariable($_IPS[‚SELF‘], „Timer“, 1);
$v = GetValue($vid);
$v–;
if($v <= 0)
{
doOff();
IPS_SetScriptTimer($_IPS[‚SELF‘], 0);
$v = $min-2;
}
SetValue($vid, $v);
}

function doOn()
{
global $_IPS;
if(IPS_GetScriptTimer($_IPS[‚SELF‘]) == 0)
{
IPS_SetScriptTimer($_IPS[‚SELF‘], 60);
on();
}
}

function doOff()
{
global $_IPS;
IPS_SetScriptTimer($_IPS[‚SELF‘], 0);
off();
}

function CreateParentVariable($id, $name, $type)
{
global $_IPS;
$vid = IPS_GetParent($_IPS[‚SELF‘]);
if(!IPS_VariableExists($vid))
{
$vid = false;
}
else
{
$v = IPS_GetVariable($vid);
if($v[‚VariableValue‘][‚ValueType‘] != $type)
$vid = false;
}
if($vid === false)
{
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, IPS_GetParent($_IPS[‚SELF‘]));
IPS_SetParent($id, $vid);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, „this variable was created by script #“ .$_IPS[‚SELF‘]);
IPS_SetHidden($id, true);
}
return $vid;
}

function IPS_SetVariableProfileAssociationEx($vpn, $av, $an, $ai, $ac)
{
if(floatval(IPS_GetKernelVersion()) <= 2.3)
{
IPS_SetVariableProfileAssociation($vpn, $av, $an, $ai);
} else {
IPS_SetVariableProfileAssociation($vpn, $av, $an, $ai, $ac);
}
}

?>

@paresy

Hallo

wo finde ich da eine Erläuterung?

$v[‚VariableValue‘][‚ValueType‘] <-- Das ist nicht mehr aktuell

Steh irgendwie auf der Leitung :confused:
finde keine Lösung :frowning:
Kann mir jemand helfen?
Danke

$v[‚VariableValue‘][‚ValueType‘] <-- Das ist nicht mehr aktuell

Doku lesen ?
IPS_GetVariable — IP-Symcon :: Automatisierungssoftware
Michael

Danke Michael,
aber die Doku habe ich schon 10 mal rauf und runter gelesen. :confused:
Steh hier: $v[‚VariableValue‘][‚ValueType‘]
auf der Leitung :banghead:

Gruß
Werner

Tausch einfach $v[‚VariableValue‘][‚ValueType‘] zu $v[‚VariableType‘] und dann sollte es gehen :slight_smile:

paresy

@paresy

Danke :smiley:
funktioniert jetzt (nachdem ich wieder 4.0 installiert habe).

Gruß aus Aschaffenburg