Looked in to it and created a PHP script since I know that better. If you edit and scene the old one remains in the bridge. So you search for the name in the bridge make sure you call always the last one (if there are more than one scenes with the same name).
for now i can:
if X then $hueScene = "paars/roze"
which triggers:
if $hueScene gets updated then execute "curl http://server.local/hue.php?scene=$hueScene >/dev/null 2>&1 || true"
My simple and dirty script:
<?php
$ip = "192.168.1.204";
$username = "1c206fbd13c228ea15b36dd66c89a1e0";
$requestedScene = $_GET['scene'];
$scenes = json_decode(file_get_contents("http://$ip/api/$username/scenes"), true); // Get the scenes
if(!$requestedScene){
foreach($scenes as $scene => $value){
if (strpos($value['name'], " on ") !== false) {
$name = substr($value['name'], 0, strpos($value['name'], " on "));
}
echo "<a href='?scene=$scene&id=true'>$name</a><br/>";
}
} else {
$found = false;
if($_GET['id']){
callScene($requestedScene);
} else {
foreach($scenes as $scene => $value){
if (strpos(strtolower($value['name']), strtolower($requestedScene)) !== false) {
$sceneID = $scene;
$found = true;
}
}
if(!$found){
echo("Could not find scene $requestedScene");
} else {
callScene($sceneID);
}
}
}
function callScene($id){
global $ip;
global $username;
$url = "http://$ip/api/$username/groups/0/action";
$data = array(
"scene" => $id,
);
$data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
));
$output = curl_exec($ch);
curl_close($ch);
//header('location: hue.php');
}
?>