Danke Paresy - tatsächlich kommt keine Meldung im Log, wenn ich das in einem separaten Skript laufen lasse. Ich weis nicht weiter und hab das komplette Skript beigefügt in der Hoffnung, das jemand das Problem erkennt? :rolleyes:
<?
include("hue_include.ips.php");
include("IPSInstaller.ips.php");
$json_url = 'http://'.$config['hue_bridge_ip'].'/api/'.$config['hue_key'];
$ch = curl_init( $json_url );
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET', // -X
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
);
curl_setopt_array( $ch, $options );
// Getting results
$json_result = curl_exec($ch);
$result = json_decode($json_result);
$idCatLights = CreateCategory("Lampen",IPS_GetParent($_IPS['SELF']),0);
$idCatGroups = CreateCategory("Lampengruppen",IPS_GetParent($_IPS['SELF']),0);
$idCatScenes = CreateCategory("Szenen",IPS_GetParent($_IPS['SELF']),0);
$id = 0;
foreach ($result->lights as $light) {
$id=$id+1;
$myLight = hue_createLight($id, $idCatLights, utf8_decode ($light->name));
SetValue(IPS_GetVariableIDByName ("Status", $myLight),$light->state->on);
SetValue(IPS_GetVariableIDByName ("Hue", $myLight),$light->state->hue);
SetValue(IPS_GetVariableIDByName ("ModelID", $myLight),$light->modelid);
SetValue(IPS_GetVariableIDByName ("X", $myLight),$light->state->xy[0]);
SetValue(IPS_GetVariableIDByName ("Y", $myLight),$light->state->xy[1]);
//$colors = colorFromXY(new cgpoint($light->state->xy[0],$light->state->xy[1]), $light->modelid);
$colors = colorFromXYsimple(new cgpoint($light->state->xy[0],$light->state->xy[1]), $light->state->bri, $light->modelid);
$colhex = dechex($colors[0]).dechex($colors[1]).dechex($colors[2]);
SetValue(IPS_GetVariableIDByName ("Farbe", $myLight),hexdec($colhex));
if(isset($light->state->ct))
{
SetValue(IPS_GetVariableIDByName ("Temperatur", $myLight),$light->state->ct);
}
SetValue(IPS_GetVariableIDByName ("Helligkeit", $myLight),$light->state->bri);
SetValue(IPS_GetVariableIDByName ("Sättigung", $myLight),$light->state->sat);
SetValue(IPS_GetVariableIDByName ("Erreichbar", $myLight),$light->state->reachable);
If ($light->state->reachable == True){
IPS_SetVariableCustomAction(IPS_GetVariableIDByName("Status", $myLight),19936 /*[Hardware\Hue\hue_Action]*/);
IPS_SetHidden(IPS_GetVariableIDByName("Farbe", $myLight),False);
IPS_SetHidden(IPS_GetVariableIDByName("Helligkeit", $myLight),False);
IPS_SetHidden(IPS_GetVariableIDByName("Sättigung", $myLight),False);
IPS_SetHidden(IPS_GetVariableIDByName("Farbszene", $myLight),False);
} else {
hue_SendLampCommand(IPS_GetVariableIDByName ("ID", $myLight), '"on":false');
// SetValue(IPS_GetVariableIDByName ("Status", $myLight),False);
IPS_SetVariableCustomAction(IPS_GetVariableIDByName("Status", $myLight),1);
IPS_SetHidden(IPS_GetVariableIDByName("Farbe", $myLight),True);
IPS_SetHidden(IPS_GetVariableIDByName("Helligkeit", $myLight),True);
IPS_SetHidden(IPS_GetVariableIDByName("Sättigung", $myLight),True);
IPS_SetHidden(IPS_GetVariableIDByName("Farbszene", $myLight),True);
}
}
$id = 0;
foreach ($result->groups as $group) {
$id=$id+1;
//print_r($group);
$myGroup = hue_createGroup($id, $idCatGroups, utf8_decode ($group->name));
SetValue(IPS_GetVariableIDByName ("Status", $myGroup),$group->action->on);
SetValue(IPS_GetVariableIDByName ("Hue", $myGroup),$group->action->hue);
if(isset($group->action->ct)) SetValue(IPS_GetVariableIDByName ("Temperatur", $myGroup),$group->action->ct);
SetValue(IPS_GetVariableIDByName ("Helligkeit", $myGroup),$group->action->bri);
SetValue(IPS_GetVariableIDByName ("Sättigung", $myGroup),$group->action->sat);
SetValue(IPS_GetVariableIDByName ("X", $myGroup),$group->action->xy[0]);
SetValue(IPS_GetVariableIDByName ("Y", $myGroup),$group->action->xy[1]);
SetValue(IPS_GetVariableIDByName ("Effekt", $myGroup),$group->action->effect);
SetValue(IPS_GetVariableIDByName ("Modus", $myGroup),$group->action->colormode);
//SetValue(IPS_GetVariableIDByName ("Übergangszeit", $myGroup),$group->action->transitiontime);
}
function hue_createLight($id, $parentID, $name){
$action_script = IPS_GetObjectIDByName("hue_Action", IPS_GetParent($parentID));
$item = @CreateInstance($name, $parentID, "{485D0419-BE97-4548-AA9C-C083EB82E61E}", $Position=0);
$id_info = IPS_GetObject($item);
@IPS_SetIdent ($item, $id);
// CreateVariable ($Name, $Type, $Parent, $Position, $Profile, $Action=0, $ValueDefault='', $Icon="")
@CreateVariable("Status", 0, $item, 0, "~Switch", $action_script, false);
@IPS_SetHidden(@CreateVariable("Erreichbar", 0, $item, 0, "~Switch", "", false));
@CreateVariable("Farbe", 1, $item, 1, "~HexColor", $action_script, false);
@CreateVariable("Helligkeit", 1, $item, 2, "~Intensity.255", $action_script,254);
@IPS_SetHidden(CreateVariable("Hue", 1, $item, 0, "hue_Hue", $action_script,254), True);
@IPS_SetHidden(CreateVariable("ID", 1, $item, 0, "", null,$id), True);
@IPS_SetHidden(CreateVariable("ModelID",3, $item, 0, "", null,""), True);
// @IPS_SetHidden(CreateVariable("X", 2, $item, 0, "hue_xy", $action_script,0.1), True);
// @IPS_SetHidden(CreateVariable("Y", 2, $item, 0, "hue_xy", $action_script,0.1), True);
@IPS_SetHidden(CreateVariable("Temperatur", 1, $item, 0, "hue_Temperature", $action_script,500), True);
@CreateVariable("Sättigung", 1, $item, 5, "~Intensity.255", $action_script,254);
return $item;
}
function hue_createGroup($id, $parentID, $name){
$action_script = IPS_GetObjectIDByName("hue_ActionGroup", IPS_GetParent($parentID));
$item = @CreateInstance($name, $parentID, "{485D0419-BE97-4548-AA9C-C083EB82E61E}", $Position=0);
$id_info = IPS_GetObject($item);
@IPS_SetIdent ($item, $id);
@CreateVariable("Status", 0, $item, 0, "~Switch", $action_script, false);
@CreateVariable("Farbe", 1, $item, 1, "~HexColor", $action_script, false);
@CreateVariable("Helligkeit", 1, $item, 2, "~Intensity.255", $action_script,254);
@IPS_SetHidden(CreateVariable("Hue", 1, $item, 3, "hue_Hue", $action_script,254), True);
@IPS_SetHidden(CreateVariable("ID", 1, $item, 0, "", null,$id), True);
@IPS_SetHidden(CreateVariable("Temperatur", 1, $item, 4, "hue_Temperature", $action_script,500), True);
@CreateVariable("Sättigung", 1, $item, 5, "~Intensity.255", $action_script,254);
@IPS_SetHidden(CreateVariable("X", 2, $item, 0, "hue_xy", $action_script,0.1), True);
@IPS_SetHidden(CreateVariable("Y", 2, $item, 0, "hue_xy", $action_script,0.1), True);
@IPS_SetHidden(CreateVariable("Effekt", 3, $item, 0, "hue_effect", $action_script,"none"), True);
@IPS_SetHidden(CreateVariable("Modus", 3, $item, 0, "hue_colormode", $action_script,"xy"), True);
@IPS_SetHidden(CreateVariable("Übergangszeit", 1, $item, 0, "hue_transition", $action_script,4), True);
return $item;
}
?>
Danke & Gruß, Axel