breadweb / extralife-helper

The Extra Life Helper is a web app that can be used by Extra Life participants and teams to display their fundraising progress. Works in OBS and any modern browser. Features donation alerts, an event countdown timer, a timer for hours played, and multiple themes and display options.
https://breadweb.net/extralife-helper/
MIT License
27 stars 17 forks source link

Light Bridge hook? #2

Closed SturmB closed 6 years ago

SturmB commented 6 years ago

Hey, is there any chance you could share a brief set of instructions on how to set up Philips Hue lights to flash (or change to a random color, or whatever) when you receive a donation? I cannot seem to find a way to do so via IFTTT.

breadweb commented 6 years ago

Hey @SturmB. I have my Hue lights flash by making a direct request to my light bridge. Assuming you are running the Helper on a computer that is connected to the same network as your light bridge, it is really easy if you use the Helper's onNewDonation function in ExtraLifeHelper.html. Here's what mine looks like:

    // If you would like additional things to happen when a new donation is 
    // received, put them in this function.
    function onNewDonation(donorName, donationAmount, message, avatarImageURL, createdOn)
    {
        $.ajax({
            url: 'http://IP-ADDRESS/api/USERNAME/groups/1/action',
            type: 'PUT',
            data: '{ "alert": "lselect" }',
            dataType: 'json',
            cache: false
        });
    }

IP-ADDRESS = The IP address of your light bridge USERNAME = The username you created when connecting to your light bridge as explained here: https://www.developers.meethue.com/documentation/getting-started

SturmB commented 6 years ago

This is pretty awesome. I'll have to explore the API and maybe customize the alert to do something different, like a quick color cycle, ending on a random color or something. Thanks!