Using Device::Hue

So, I found a major lack of documentation for Device::Hue, and chatGPT had some information that I would describe as whimsically wrong.

Here’s what I ended up doing to get a working perl setup controlling my hue lights:

1) Put a valid URL in /etc/environment for the key HUE_BRIDGE
2) Put a key in /etc/environment for the key HUE_KEY
3) The following code sets lights 17 and 19 to red:


my $bridge = Device::Hue->new();
$bridge->config();
foreach $light_id (17, 19) {
my $light = $bridge->light($light_id);

$light->set_state( { hue => 0, sat => 254 });
$light->commit();
}

One Response to “Using Device::Hue”

  1. Swipes Says:

    I, for one, am glad that you figured it out. It’s also always fun watching you work out a project that you know you can solve. I think the setup works rather nicely and we should have tried it awhile ago.

Leave a Reply