Philips Hue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • pbj
    Automated Home Sr Member
    • Jul 2004
    • 57

    Philips Hue

    Hi all,

    I've just purchased a Philips Hue bridge which allows my three existing Philips LivingColors LED lights to be controlled via REST HTTP calls (and an iPad!). Before setting off on a Christmas project to rustle up a python xAP/Hue interface so I can use them with Cortex, has anyone done this before?

    My alternative is to use a simple command line tool to control the lights which is called from a macro, but that doesn't seem very elegant, any other ideas?
  • Karam
    Automated Home Legend
    • Mar 2005
    • 863

    #2
    Cortex API? But then xAP route might be just as good. If using macro type method might be worth linking to the state of a virtual light object to give some aspects of automation. Of course if someone changes light states via an external application then things will get in a mess.

    Comment

    • Andrew Millne
      Automated Home Ninja
      • Nov 2007
      • 269

      #3
      Did you make any progress with this pbj? I'm looking to do something similar but some native Cortex support for Hue would be great if possible. http://www.developers.meethue.com/tools-and-sdks
      Visit my blog and Follow me on Twitter...

      Comment

      • Andrew Millne
        Automated Home Ninja
        • Nov 2007
        • 269

        #4
        I made a start on this but unfortunately the hue API requires the PUT method to be used and the Cortex API only allows for Get and POST. Also rather than a key/value list would it be possible to get a raw message body area?

        For a post request...

        Sent


        HTTP/1.1 400 Bad request

        PUT requests made outside of cortex are working correctly.

        DELETE method is also used in the hue API but I haven't come across a need for it yet
        Visit my blog and Follow me on Twitter...

        Comment

        • pbj
          Automated Home Sr Member
          • Jul 2004
          • 57

          #5
          Hi Andrew,

          I ended up using powerscript to create a command line. It's not terribly elegant, but does the job. Of course that means there's no possibility of feedback from the light, but I don't think the Hue offers that anyway.

          Peter

          Comment

          • Andrew Millne
            Automated Home Ninja
            • Nov 2007
            • 269

            #6
            The Hue API does feature a JSON response with "success" reported on a successful command.

            Aside from the issue of no PUT/DELETE, I only seem to be encountering one other minor issue with the lights. I've replaced some of the lamps on a QLD circuit with hue bulbs and occasionally they don't want to come on even though I've reset the rates to immediate. No amount of toggling the circuit on/off brings the bulb back to life, I have to take the bulb out of the holder and pop it back in. I don't have this issue with lamps on a relay switched circuit. With API support in Cortex I hope I'll be able to overcome this by leaving the dimmer circuit on all the time and adding a virtual light object to send on/off api commands to the hue lamps to retain the occupancy sensing capabilities of Cortex. This should also allow me to automate some other desk/floor lamps around the house where I neglected to install Idratek switched sockets.

            I'm on hold until if/when we can get PUT/DELETE support in the cortex API however. Karam?
            Visit my blog and Follow me on Twitter...

            Comment

            • Karam
              Automated Home Legend
              • Mar 2005
              • 863

              #7
              Ok we'll look into it. My guess with these things is - never as simple as it sounds

              Comment

              • Andrew Millne
                Automated Home Ninja
                • Nov 2007
                • 269

                #8
                Originally posted by Karam View Post
                Ok we'll look into it. My guess with these things is - never as simple as it sounds
                Thanks, much appreciated.
                Visit my blog and Follow me on Twitter...

                Comment

                • Karam
                  Automated Home Legend
                  • Mar 2005
                  • 863

                  #9
                  Forgot to answer the other question. All I can guess at is it might be due to the current leakage through the output filter capacitors. If, for experimental purposes and you have some soldering capability, you want disconnect these then e-mail me for instructions. LED loads are very different to incandescent so my quick guess is that disconnection will not have a significant effect on the filtering characteristic anyway.

                  Comment

                  • Viv
                    Automated Home Ninja
                    • Dec 2004
                    • 284

                    #10
                    We have a development version which allows the 'PUT' command.
                    Also allows 'Body Text' to be defined as required.
                    Changes have also be made to decode a json array as the first element.

                    Cortex release will be updated soon with the latest changes.

                    Thanks to Andrew for his help testing.

                    Viv

                    Comment

                    • chris_j_hunter
                      Automated Home Legend
                      • Dec 2007
                      • 1713

                      #11
                      Andrew -

                      curious to know ... will your route allow control of both colour & brightness of each bulb, both individually & in groups, with full Cortex integration ?

                      and so, when prices come down, could we be replacing all our existing mix of dimmer- & relay-driven CFLs with Hue bulbs - in existing fittings ?

                      Chris
                      Our self-build - going further with HA...

                      Comment

                      • Andrew Millne
                        Automated Home Ninja
                        • Nov 2007
                        • 269

                        #12
                        Originally posted by chris_j_hunter View Post
                        will your route allow control of both colour & brightness of each bulb, both individually & in groups, with full Cortex integration ?
                        Sort of. Using the web API in Cortex for this is somewhat clunky in that each request requires a web api "action". So if you want to "set living room light on" that would be an individual API request. Likewise for turning it off. You can combine actions with the API so you could have cortex send a request for "turn living room light on, set brightness to 50% and set the colour as blue" but each of these combos would need to be set individually and assigned to connections in other cortex objects such as switches/occupancy outputs etc. Some real life examples might be easier to follow so see below.

                        could we be replacing all our existing mix of dimmer- & relay-driven CFLs with Hue bulbs - in existing fittings ?
                        I'm already most of the way there.

                        Here's a progress update;

                        Thanks to Karam and Vivian the PUT requests are now working. What I've done is add a web client API object for each room with hue lights and then added an API request for on and off for each hue lamp. I've blurred out the API key which forms part of the URL

                        api requests.jpg

                        An individual request looks like this with a json encoded body...

                        individual request.jpgbi

                        I've then added a legacy relay node with 6 connections here so I can set up some "virtual" light objects that aren't under Cortex hardware control. Make sure they are not set as network enabled.

                        Legacy relay node.jpg

                        The light behaviour is now as for any other Cortex controlled light and gives access to the light level and occupancy features

                        light behaviour.jpg

                        Finally I've set up the connections for the virtual light objects so that the on/off output sends the API requests to the hue hub.

                        light connections.jpg

                        The actual physical lamps are connected to a mix of cortex relay controlled, DIN mount dimmers and circuits not under cortex control. All of these are set to always on and in the case of the dimmer circuits at 100%. I'll likely remove the dimmers from the circuit at some point and just hard wire them.

                        So in practice all of the electrical circuits are always on and cortex is sending on/off commands over the software API.

                        Provided they are not totally disconnected from the mains the bulbs retain their last brightness and colour settings with the on/off API requests. If the power is totally disconnected, when it is switched back on the bulbs default to a warm white at 100% brightness (presumably a sort of safety feature).

                        Up to now we're back to the same functionality that cortex offers but without any dimming capability. Setting of colours, dimming and scenes is now handled on the hue side of things and particularly useful is the Apple Siri integration, especially in combination with the Apple watch. I can now have cortex take care of the occupancy and have the lights switch on to the last scene automatically and then press and hold the watch rotary dial and say "set the relax scene" or "turn bookcase purple".

                        I've set button number 8 on the digital panel to toggle all the lights on/off.

                        The next step will be add a scene menu connected to button 9 that mirrors the scenes I've set up in the Hue app that will be connected to new API requests to set those scenes. This will be useful for those that don't have the hue app or siri capabilities.

                        I haven't had any missed requests from Cortex in case anybody is wondering about reliability. The only issues I can forsee are if somebody uses siri or the hue app to toggle the on/off state then Cortex will become out of sync. So long as distinct on and off outputs are used rather than the toggles then it should catch back up on the next request from cortex. For example if I go to bed and have siri "Turn all lights off" they will temporarily be out of sync in Cortex until the room occupancy and light timers cause cortex to resync them into the off state. I've not encountered a real life scenario where it has caused a problem yet.
                        Last edited by Andrew Millne; 27 January 2016, 01:00 AM.
                        Visit my blog and Follow me on Twitter...

                        Comment

                        • Andrew Millne
                          Automated Home Ninja
                          • Nov 2007
                          • 269

                          #13
                          As an added bonus, hue integrates with Logitech harmony remote activities (dimming only, no colour). So selecting watch TV on the remote dims the light group and turning off the TV brings the light level back up to normal.
                          Visit my blog and Follow me on Twitter...

                          Comment

                          • chris_j_hunter
                            Automated Home Legend
                            • Dec 2007
                            • 1713

                            #14
                            thanks for the insight, quite tempted to try a few Hue bulbs, though the available shapes are not really suited to our set-up, so far, anyway - we mostly have bare bulbs, and also they look too large for the few globe & drum fittings we have ...

                            aha, wondered what the Body text segment was for ...

                            BTW, the WebAPI Client is a lot easier to use that we thought it would be - so, if anyone's holding off after a quick look, as we did, it could be worth diving in & giving it a go !
                            Last edited by chris_j_hunter; 27 January 2016, 03:21 PM.
                            Our self-build - going further with HA...

                            Comment

                            Working...
                            X