[APP] Philips Hue - Transform the way you experience light

The general description is fine :wink: it wil help me guide in the right direction hopefully :stuck_out_tongue:

OK :slight_smile:

You can activate every scene with an API call with the right scene ID to your Hue hub. The 24-hour scenes are called smartscenes.

To find the IDs of the (smart)scenes, you can use the API debug tool. It takes some effort setting this up and figuring this out. If you GET the “/clip/v2/resource“ url, it produces a json. Copy/paste it for example into an online json viewer. Find the id(s) of your smart_scene(s).

The HUE hub only accepts secure connections. There is some kind of certificate issue between the Homey and the HUE hub which prevents sending the right commands directly. So with the help of an AI, I made a little script running on my NAS which does this for me. Basically I have a Homey flow that asks that script to send the command to the hue bridge.

The flow makes a GET with “http:///hue-scenes.php?scene=940b2bb5-44af-4f39-a32d-8f052553e298“ for example.

The php is:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Hue bridge settings
$hueIp = "<HueHubIp>";
$hueAppKey = "<HueAppID>";

// Get scene ID from query string
if (!isset($_GET['scene'])) {
    http_response_code(400);
    echo json_encode(['error' => 'Missing ?scene= parameter']);
    exit;
}

$sceneId = preg_replace('/[^a-f0-9\-]/i', '', $_GET['scene']); // sanitize input

$url = "https://{$hueIp}/clip/v2/resource/smart_scene/{$sceneId}";

// cURL command
$cmd = 'curl -k -X PUT "' . $url . '" '
     . '-H "hue-application-key: ' . $hueAppKey . '" '
     . '-H "Content-Type: application/json" '
     . '-d \'{"recall": {"action": "activate"}}\'';

// Run the command
exec($cmd, $output, $returnCode);

// Output response
header('Content-Type: application/json');
echo json_encode([
    'scene' => $sceneId,
    'success' => $returnCode === 0,
    'output' => $output,
    'code' => $returnCode
]);

And this works for me. Feel free to ask questions and more details if needed. Perhaps there are simpler solutions, but I could not find one. Good luck!

1 Like

Thanks for the how-to, and thanks for the quick replies. I will dive into this. I also think is have a solution to not need a PHP script on a server. I had a similair certificate issue when requesting a Unifi Protect alarm manager webhook with api header. That webhook is https only an on a local ip.

See below for the code i use for this. I will try this route and post my code here for everyone to enjoy

async function sendUniFiRequest() {
    try {
        const apiUrl = 'url'; 
        const apiKey = 'key';

        const httpsAgent = new https.Agent({
            rejectUnauthorized: false
}       );

        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'X-API-KEY': apiKey
            },
            agent: httpsAgent
        });

        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }

    } catch (error) {
        console.error('Error sending request:', error);
        throw error;
    }
}

return sendUniFiRequest();

I got it working as a standalone script in Homey. below the scrypt i added a flow screenshot

const HUE_IP = "x"; // Replace with your Hue Bridge IP
const HUE_APP_KEY = "x"; // Replace with your Hue App Key
const SCENE_ID = args[0];

// Function to sanitize input (remove non-alphanumeric and non-hyphen characters)
function sanitizeSceneId() {
  return SCENE_ID.replace(/[^a-f0-9\-]/gi, '');
}

// Main function to activate a Hue smart scene
async function activateHueScene() {
  try {
    if (!SCENE_ID) {
      throw new Error('Missing scene parameter');
    }

    sanitizeSceneId();
    const url = `https://${HUE_IP}/clip/v2/resource/smart_scene/${SCENE_ID}`;

     const httpsAgent = new https.Agent({
            rejectUnauthorized: false
}       );
    
    const response = await fetch(url, {
      method: 'PUT',
      headers: {
        'hue-application-key': HUE_APP_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ recall: { action: 'activate' } }),
      agent: httpsAgent
    });
   
   if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }
    
   } catch (error) {
        console.error('Error sending request:', error);
        throw error;
    }
}

return activateHueScene();

Nice work! I am going to play around with this. I don’t know if you have access to the Hue developers API pages, but there are some additional parameters you might want to implement. I believe they are also missing for the normal Homey Hue app when activating non-smart scenes, such as ‘duration’, making a slow transition to the activated scene for example.

recall: (object)
action: (one of active, dynamic_palette, static)
When writing active, the actions in the scene are executed on the target. dynamic_palette starts dynamic scene with colors in the Palette object.

duration: (integer)
transition to the scene within the timeframe given by duration```

And thanks again for sharing your much better solution :)

Thanks. I will check that out.

For now i am mostly using smart scenes. I just want presence being managed bij Homey, when active presence (based om numureus sensors) the smart scenes are used.

The ‘basic’ Hue app is imo an underdeveloped app. They are missing so much features. Home Assisant Hue integration is a completely better experience. I switched to Homey because of the way flows can be built. That is visually much much better within Homey vs the Automations in HA.

I have a problem with my philips hue bridge / Hue gradient light strip, hopefully someone could help me.

I have a lot of philips products in the hue app. All working fine. Except my new gradient light strip.

When adding for the first time in the app, the ledstrips works fine. But when i linked the led strip in the homey app, immediately i get the message in hue app (light isn’t available). After a few seconds the same message in the homey app. I tried to reload the led in the hue app, but it can’t find the led strip anymore. Same problem with homey. I have deleted the light in both apps, cleaned the cache, but still can’t adding the led strip again. (in homey of course not because it isn’t linked anymore with the bridge). Is there a solution for this? I don’t have any wall switch or sensor to reset the light strip. I tried to enable the light for 2 seconds and disable it for 8 seconds (found on the internet for resetting, but this also didn’t help).

There is in homey another app called philips without the bridge, when i adding here a led strip it says a unknown zigbee device is added. (i can control the light again, but without the gradient color.) For me it isn’t a problem to use this app, but i would like to use all options the ledstrip is made for.

I bought a second led strip from philips, same problem. So i now have two led strips i can’t use or add anymore in the philips hue app.

I think you have to factory reset your gradient light strip. If it was add by the homey hue without bridge app to the homey zigbee coordinator the hue bridge won´t see the strip anymore.

Thanks for the reply.

Yes i think a hard reset would maybe work, but all options didn’t work. (to be clear, i added the led strip in the official philips hue app for homey with bridge). After multiple times resetting like the link you send, i added it to the non official philips hue without the bridge, for trying if this would work. So the led didn’t work before adding it to the non official philips without bridge app.

I deleted it completely from homey and hue, and it still doesn’t find the led in the hue app with adding a new light.

FYI: Hue lights can only be found for half a hour after connecting to the power.

Have you seen changing light colors during/after the factory reset? Otherwise they are not reseted. And the reset have to be done within the 30min too after they have power down and power off (not just switch off and on

Yes, I see a quick change in light color, after that the led shows the same color.

I powered off the leds, unplug the power adapter and connect it again to the wall outlet. Direct after that I begin the adding process in the hue app.

Sorry, than I´m out of ideas.
Maybe Signify Support can help

I just switched from my Hue Bridge to a hue Bridge Pro. Sad enough I have to reconnect all lights and stripes.
On Homey I deleted the HUE App and reinstalled it but when I now search for lights nothing is found. Shouldn´t homey ask me now to reconnect to the new bridge?
How can I force this?

@Andre_Scheffknecht

https://community.homey.app/t/the-new-philips-hue-bridge/141769/10?u=mike1233

When i try to add new sensors from my Hue Pro bridge, i get this error messaga;

Anyone an idea what this might be? I want to add my sensors because they don’t work anymore since migrating to the pro bridge.

There seems to be a fix in the latest version.