At the end, an own action script for the „Status“ variable was needed. We made this generic script that can used for all instances of that type of dimmer device.
<?php
$IdentState = 'StatusVariable';
$IdentIntensity = 'IntensityVariable';
If ($_IPS['SENDER'] == 'Variable' || $_IPS['SENDER'] == 'WebFront' || $_IPS['SENDER'] == 'VoiceControl' ) { // execute this script on variable change only
$Sender = $_IPS['VARIABLE']; // What variable trigger this script?
$ParentInstance = IPS_GetParent($Sender); // Who is the parent instance of this variable?
$ChildsOfInstance = IPS_GetChildrenIDs($ParentInstance); // array of all instance childs
If (IPS_GetObject($Sender)['ObjectIdent'] == $IdentState) // if the trigger variable is the state variable
{
If ($_IPS['VALUE']) // boolean true
//If requested action is „on“ and current status is „off“, load intensity value from saved variable.
{
$Intensity = (int)IPS_GetObject($ParentInstance)['ObjectInfo']; // reading the intensity, stored in the instance info area
foreach ($ChildsOfInstance as $Child) //looking for the matching intensity variable, under the instance
{
If (IPS_GetObject($Child)['ObjectIdent'] == $IdentIntensity) //found intensity variable
{
RequestAction($Child, $Intensity); // send the read intensity value the device
}
}
}
else // boolean false
// If requested action is „off“ and current status is „on“, save Intensity value to some variable, when successful change „status“ to „off“
{
foreach ($ChildsOfInstance as $Child) //looking for the matching intensity variable, under the instance
{
If (IPS_GetObject($Child)['ObjectIdent'] == $IdentIntensity) //found intensity variable
{
$Intensity = GetValue($Child); // getting the current value
IPS_SetInfo($ParentInstance,$Intensity); // store the current intensity into the info area of the instance
RequestAction($Child, 0); // send intensity 0 to the device to switch it off
}
}
}
}
}
else
{
IPS_LogMessage($_IPS['SELF'],'Script can executed on variable change only. Sender was: '.$_IPS['SENDER']);
}
Thanks for the good conversation.