Philips Hue control from Loxone

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Antti_K
    Azubi
    • 06.11.2015
    • 6

    #1

    Philips Hue control from Loxone

    Hi,

    I was wondering if it could be possible to integrate Philips Hue system to Loxone?
    Are there any suitable extensions awailable on the market? Or can it be done by using Config software?

    And how about the visualization of Hue lights in the Loxone app?

    I saw there was some discussion on german forum...but don't really understand it


    Best regards

    Antti
  • svethi
    Lebende Foren Legende
    • 25.08.2015
    • 6312

    #2
    Well, my English is not so good and it is possible, that you can't understand this also :-)

    In the German discussion you can find an PicoC-Script. Use it in the program-block (16). At the top of the script you have to insert your data (IP of the HUE-Bridge etc.). Also you have to set the type of your lamps and the ID's of your lamps/groups. The output of the light controller has to be connected with the input of your program-block. That's it.

    Because there is no way to set the actual state in the light controller, it doesn't make sense to retrieve the state from the bridge. But it would be possible.

    Greetings Sven
    Miniserver; KNX; Vitogate; EnOcean (EnOceanPi); Loxone Air; Caldav-Kalenderanbindung; RaspberryPi und für keine Frickellösung zu schade :-)

    Kommentar

    • Antti_K
      Azubi
      • 06.11.2015
      • 6

      #3
      Thanks Sven!

      I'll have a look on that and will give it a go.
      Just need to wait few more days for my Hue order to arrive

      Regards

      Antti

      Kommentar

      • Andreas Lackner
        Smart Home'r
        • 12.10.2015
        • 58

        #4
        Don't forget to obtain a user-ID from you bridge. Link to documentation is provided inside the pico-code


        Gesendet von meinem iPhone mit Tapatalk

        Kommentar

        • Antti_K
          Azubi
          • 06.11.2015
          • 6

          #5
          Ok Guys!

          I Think I need some assistance:

          - I created username in my Hue Bridge (2.0) with API Debug tool. (http://www.developers.meethue.com/do...etting-started)
          - I added lighting controller and program module to Loxone config. (http://forum.loxone.com/attachments/...xample.loxplan)
          - I changed the IP address of my bridge to the pico-code. Line 152.
          - I changed the username and IP address to the line 163 inside the code.

          What am I missing since the lights won't lit up?

          I can control the lights with my smartphone app. So they are connected to the bridge..


          Hilfe!



          Best regards

          Antti

          Kommentar

          • Andreas Lackner
            Smart Home'r
            • 12.10.2015
            • 58

            #6
            Antti_K, you're using outdated code...
            the newest code is availabel here: https://www.loxforum.com/forum/faqs-...xone-verwenden

            don't forget to set the type of signal you're sending to the programm (RGB, LUMITECH, 0-100%, ON/OFF) and the which lamp-ID should be connected to the according input.

            Also check the logs for compiler erros... there is also DEBUG-flag in the code to get more detailed logging information.


            I've translated the comments on inputTypes for you, so you can set them more easily:

            // Hier die Funktion des Eingangs definieren:
            // 0 = RGB-Eingang (Eingang LoxoneFormat, 9-stellige Zahl die RGB codiert mit 100100100 für weiß. Ansteuerung der Lampe via Hue/Sat/Bri
            // 1 = Dimmereingang. Eingangswert muss im Bereich DIMMER_MIN / DIMMER_MAX sein. Ansteuerung der Lampe via Bri.
            // 2 = ON/OF - Eingang (z.B. für Steckdosen-Adapter)
            // 3 = RGB-Eingang (wie '0', aber steuert Lampengruppe via Hue/Sat/Bri)
            // 4 = RGB-Eingang (wie '0', aber ansteuerung der Lampe via X/Y/Bri)
            // 5 = Dimmereingang (wie '1', Ansteuerung der Lampe via Bri/Ct, GlŸhlampensimulation)
            // 6 = RGB-Eingang (wie '0', aber steuert Lampengruppe via X/Y/Bri)

            // 0 = RGB-Signal (Loxone foramtted, RGB is encoded using 9 diggist (3 digits red, 3 for green 3 for blue. White is encoded as 100100100, half dimmed blue is 000000050). Lamp will receive an Hue/Sat/Bri command
            // 1 = Dimming Signal (Percentage. Set min/max values in variables DIMMER_MIN / DIMMER_MAX). Lamp will receive "Bri"-Command
            // 2 = ON/OFF Signal (0/1. used for socket adapters)
            // 3 = Like type "0" but sends Hue/Sat/Bri command to a group of lamp
            // 4 = Like type "0" but sends X/Y/Bri command to a single lamp
            // 5 = Like type "1" but sends Bri/Ct command, simulating a classic bulb
            // 6 = Like type "4" but sends Hue/Sat/Bri command to a group of lamp


            ++Luke


            Kommentar

            • Antti_K
              Azubi
              • 06.11.2015
              • 6

              #7
              Hi,

              Getting closer.. I think.
              Lamps are not lit, but now it only says in the log that "Creating Stream failed ", after I try to put them on from Loxone app.

              I have two lamps: Lamp 1 is Hue Bloom and lamp 2 is Hue Iris. These I have configured as "RGB" in the config.

              Here is what I have in my program...Can you see something weird?:

              // Philips HUE Steuerung // Eingang des Programmbausteins wird mit dem Ausgang der Lichtsteuerung (RGB, Dimmer, Ein/Aus) verbunden // // (c) 2013 by Romy Glauser // FÜR LIVING COLORS GEN 2 - MIT HUE! // // (c) 2015 Erweiterung durch Andreas Lackner-Werner um LUMITECH (rgbw) & Gruppenfunktionen sowei generelles Cleanup des Codes // // (c) 2015 Erweiterung durch Sven Thierfelder um cx/cy Farbsteuerung für hue-bulbs sowie Glühlampensimulation // int DEBUG_LEVEL=0; int DIMMER_MIN=15; int DIMMER_MAX=100; int DIMMER_SIMMIN=154; //154 = 6400k int DIMMER_SIMMAX=500; //370 = 2700k // Bitte folgende Website: // http://www.developers.meethue.com/do...etting-started // beachten um einen gültigen User-Namen zu generieren!3e3749c4c65278230abfe8535c04c4 char* IP_ADDRESS = "192.168.0.115"; char* PORT = "80"; char* USERNAME = "3e3749c4c65278230abfe8535c04c4"; int inputType[12]; // Hier die Funktion des Eingangs definieren: // 0 = RGB-Eingang (Eingang LoxoneFormat, 9-stellige Zahl die RGB codiert mit 100100100 für weiß. Ansteuerung der Lampe via Hue/Sat/Bri // 1 = Dimmereingang. Eingangswert muss im Bereich DIMMER_MIN / DIMMER_MAX sein. Ansteuerung der Lampe via Bri. // 2 = ON/OF - Eingang (z.B. für Steckdosen-Adapter) // 3 = RGB-Eingang (wie '0', aber steuert Lampengruppe via Hue/Sat/Bri) // 4 = RGB-Eingang (wie '0', aber ansteuerung der Lampe via X/Y/Bri) // 5 = Dimmereingang (wie '1', Ansteuerung der Lampe via Bri/Ct, GlŸhlampensimulation) // 6 = RGB-Eingang (wie '0', aber steuert Lampengruppe via X/Y/Bri) inputType[0] = 4; // -1=unbenutzt, 0=rgb, 1=dimmer, 2=on/off, 3=gruppe, 4=rgbbulb inputType[1] = 5; inputType[2] = -1; inputType[3] = -1; inputType[4] = -1; inputType[5] = -1; inputType[6] = -1; inputType[7] = -1; inputType[8] = -1; inputType[9] = -1; inputType[10] = -1; inputType[11] = -1; int lightOrGroupID[12]; // Zuweisung der Lampen- oder GruppenIDs. // Definiert welcher Eingang des Bausteins welche Lampe/Gruppe ansteuert: lightOrGroupID[0] = 1; lightOrGroupID[1] = 2; lightOrGroupID[2] = 3; lightOrGroupID[3] = 4; lightOrGroupID[4] = 5; lightOrGroupID[5] = 6; lightOrGroupID[6] = 7; lightOrGroupID[7] = 8; lightOrGroupID[8] = 9; lightOrGroupID[9] = 10; lightOrGroupID[10] = 11; lightOrGroupID[11] = 12; // Ende der Konfiguration... char streamname[100]; sprintf(streamname, "/dev/tcp/%s/%s/", "192.168.0.115", "80"); int nEvents; int LIGHT = 1; int GROUP = 2; void updateLamp(int idx, float value) { if (inputType[idx] == -1) { //ignorieren } else if (inputType[idx] == 0) { if (value < 200000000) { // RGB setColorBHS(lightOrGroupID[idx], value, LIGHT); } else { // LUMITECH setCtBri(lightOrGroupID[idx], value, LIGHT); } } else if (inputType[idx] == 1) { setBrightness(lightOrGroupID[idx], value); } else if (inputType[idx] == 2) { setOnOff(lightOrGroupID[idx], value); } else if (inputType[idx] == 3) { if (value < 200000000) { // RGB setColorBHS(lightOrGroupID[idx], value, GROUP); } else { // LUMITECH setCtBri(lightOrGroupID[idx], value, GROUP); } } else if (inputType[idx] == 4) { setColorXYB(lightOrGroupID[idx], value, LIGHT); } else if (inputType[idx] == 5) { setBrightnessAsBulb(lightOrGroupID[idx], value); } else if (inputType[idx] == 6) { setColorXYB(lightOrGroupID[idx], value, GROUP); } } void setBrightness(int lightID, float bri) { char command[30]; char selector[20]; // Normieren von 35-100 -> 1-255 if (bri > 0) { bri = (bri- DIMMER_MIN )/( DIMMER_MAX - DIMMER_MIN )*254+1; } sprintf(selector,"lights/%d/state", lightID); if (bri == 0) { sprintf(command, "{"on": false}"); if (DEBUG_LEVEL > 0) printf("Light %d OFF", lightID); } else { sprintf(command, "{"on": true, "bri": %d}", (int) (bri)); if (DEBUG_LEVEL > 0) printf("Light %d ON %d%%", lightID, (int) ((bri-1)/2.55)+1); } sendCommand(selector, command); } void setBrightnessAsBulb(int lightID, float bri) { char command[50]; char selector[20]; float ct,cl; // Normieren von 35-100 -> 1-255 if (bri > 0) { bri = (bri- DIMMER_MIN )/( DIMMER_MAX - DIMMER_MIN )*254+1; cl = (DIMMER_SIMMAX - DIMMER_SIMMIN); ct = DIMMER_SIMMAX - (cl * log10(1+((bri-1)/254)*9)); } sprintf(selector,"lights/%d/state", lightID); if (bri == 0) { sprintf(command, "{"on": false}"); if (DEBUG_LEVEL > 0) printf("Light %d OFF", lightID); } else { sprintf(command, "{"on": true, "bri": %d, "ct": %d}", (int) (bri), (int) (ct)); if (DEBUG_LEVEL > 0) printf("Light %d ON %d%% with %d", lightID, (int) ((bri-1)/2.55)+1, (int) (ct)); } sendCommand(selector, command); } void setCtBri(int lightID, float ctbrivalue, int type) { char command[50]; char selector[20]; float bri, ct; int briNorm, miredNorm; bri = floor((ctbrivalue-200000000) / 10000); // 0-100 ct = floor((ctbrivalue-200000000) - (bri * 10000)); // Wert in Kelvin, von 2700 - 6500 briNorm = (int) round(bri*2.55); // 0-255 miredNorm = (int) round(1000000/ct); // Wert von 154 - 370 if (type==LIGHT) { sprintf(selector,"lights/%d/state", lightID); } else if (type==GROUP) { sprintf(selector,"groups/%d/action", lightID); } if (bri == 0) { sprintf(command, "{"on": false}"); if (DEBUG_LEVEL > 0) printf("Light %d OFF", lightID); } else { sprintf(command, "{"on": true, "bri": %d, "ct": %d}", briNorm, miredNorm); if (DEBUG_LEVEL > 0) printf("Light %d ON %d%% %dK", lightID, (int) bri, (int) ct); } sendCommand(selector, command); } void setOnOff(int lightID, float bri) { char command[30]; char selector[20]; sprintf(selector,"lights/%d/state", lightID); if (bri == 0) { sprintf(command, "{"on": false}"); if (DEBUG_LEVEL > 0) printf("Light %d OFF", lightID); } else { sprintf(command, "{"on": true}"); if (DEBUG_LEVEL > 0) printf("Light %d ON", lightID); } sendCommand(selector, command); } void setColorXYB(int lightOrGroupID, float rgbvalue, int type) { char buffer[256]; float red,green,blue; float cx,cy, bri; float X,Y,Z; char command[100]; char selector[50]; blue = floor(rgbvalue/1000000); green = floor((rgbvalue-blue*1000000)/1000); red = rgbvalue-blue*1000000-green*1000; bri = blue; if (bri < green) bri = green; if (bri < red) bri = red; bri = bri * 2.55; blue = blue / 100; green = green / 100; red = red / 100; // Apply gamma correction if (red > 0.04055) { red = pow((red + 0.055) / 1.055, 2.4); } else { red = red / 12.92; } if (green > 0.04055) { green = pow((green + 0.055) / 1.055, 2.4); } else { green = green / 12.92; } if (blue > 0.04055) { blue = pow((blue + 0.055) / 1.055, 2.4); } else { blue = blue / 12.92; } // Convert to XYZ X = red * 0.649926 + green * 0.103455 + blue * 0.197109; Y = red * 0.234327 + green * 0.743075 + blue * 0.022598; Z = red * 0.013932 + green * 0.053077 + blue * 1.035763; // Calculate xy and bri if ((X+Y+Z) == 0){ cx = 0; cy = 0; } else { // round to 4 decimal max (=api max size) cx = X / (X + Y + Z); cy = Y / (X + Y + Z); } if (type==LIGHT) { sprintf(selector,"lights/%d/state", lightOrGroupID); } else if (type==GROUP) { sprintf(selector,"groups/%d/action", lightOrGroupID); } if (bri == 0) { sprintf(command, "{"on": false}"); } else { sprintf(command, "{"xy": [%f,%f],"bri": %d,"on":true}",cx,cy,bri); } if (DEBUG_LEVEL > 1) printf(command); sendCommand(selector,command); } void setColorBHS(int lightOrGroupID, float rgbvalue, int type) { char buffer[256]; float red,green,blue; float hue,sat,bri; char command[100]; char selector[50]; // Hinweis: rgbvalue ist red + green*1000 + blue*1000000 blue = floor(rgbvalue/1000000); green = floor((rgbvalue-blue*1000000)/1000); red = rgbvalue-blue*1000000-green*1000; // nochmal umrechnen nach hue irgendwie, weil die Living Colors Gen2 irgendwie nich gehen mit xy hue = 0; sat = 0; bri = 0; if (blue > 0 || green > 0 || red > 0) { if ((red >= green) && (green >= blue)) { if (red == blue) { hue = 0; } else { hue = 60*(green-blue)/(red-blue); } sat = (red - blue) / red; bri = red; } else if ((green > red) && (red >= blue)) { hue = 60*(2 - (red-blue)/(green-blue)); sat = (green - blue) / green; bri = green; } else if ((green >= blue) && (blue > red)) { hue = 60*(2 + (blue-red)/(green-red)); sat = (green - red) / green; bri = green; } else if ((blue > green) && (green > red)) { hue = 60*(4 - (green-red)/(blue-red)); sat = (blue - red) / blue; bri = blue; } else if ((blue > red) && (red >= green)) { hue = 60*(4 + (red-green)/(blue-green)); sat = (blue - green) / blue; bri = blue; } else if ((red >= blue) && (blue > green)) { hue = 60*(6 - (blue-green)/(red-green)); sat = (red - green) / red; bri = red; } // Werte für HUE normieren (hue = 0-65535, sat 0-255, bri 0-255) hue = hue / 360 * 65535; sat = sat * 255; bri = bri * 2.55; } // Ausgeben ins Log if (DEBUG_LEVEL > 1) printf("value:%09d, b:%d, g:%d, r: %d, hue:%d, sat: %d, bri: %d\n", rgbvalue, blue, green, red, (int)hue, (int)sat, (int)bri); if (bri == 0) { sprintf(command, "{"on": false}"); if (DEBUG_LEVEL > 0 && type==LIGHT ) printf("Light %d OFF", lightOrGroupID); if (DEBUG_LEVEL > 0 && type==GROUP ) printf("Group %d OFF", lightOrGroupID); } else { sprintf(command, "{"bri": %d, "hue": %d, "sat": %d, "on": true}", (int)bri, (int)hue, (int)sat); if (DEBUG_LEVEL > 0 && type==LIGHT ) printf("Light %d ON %d%%, %d° %d%%", lightOrGroupID, (int) ((bri-1)/2.55)+1, (int) (hue / 65535 * 360), (int)(sat/2.55)); if (DEBUG_LEVEL > 0 && type==GROUP ) printf("Group %d ON %d%%, %d° %d%%", lightOrGroupID, (int) ((bri-1)/2.55)+1, (int) (hue / 65535 * 360), (int)(sat/2.55)); } if (type==LIGHT) { sprintf(selector,"lights/%d/state", lightOrGroupID); } else if (type==GROUP) { sprintf(selector,"groups/%d/action", lightOrGroupID); } sendCommand(selector, command); } void sendCommand(char* selector, char* command) { STREAM* TcpStream = stream_create(streamname,0,0); if (TcpStream == NULL) { printf("Creating Stream failed"); stream_close(TcpStream); return; } char buffer[1024]; sprintf(buffer, "PUT /api/%s/%s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\nContent-Length: %d\r\n\r\n%s", USERNAME, selector, IP_ADDRESS, strlen(command), command); if (DEBUG_LEVEL > 1) printf(buffer); stream_write(TcpStream,buffer,sizeof(buffer)); stream_flush(TcpStream); stream_close(TcpStream); } while (1==1) { nEvents = getinputevent(); // Sonderfunkion: AI12 löst ein "ALLES AUSSCHALTEN"-Signal an die HUE-Bridge aus if (nEvents & 0x8 << 12 && getinput(12)==1) { if (DEBUG_LEVEL > 0) printf("All Lights OFF"); sendCommand( "groups/0/action", "{"on":false}"); // Alle anderen Eingänge werden an die HUE laut Konfiguration weitergegeben: } else { int i; for (i = 0; i < 12; i++) { if (nEvents & 0x8 << i) { updateLamp(i, getinput(i)); sleep(150); } } } sleep(100); }
              Thank you for your time!

              -Antti

              Kommentar


              • Andreas Lackner
                Andreas Lackner kommentierte
                Kommentar bearbeiten
                Antti, that's totally unreadable. Post your code as an attachment, so it won't get f*cked up by your editor...
            • Antti_K
              Azubi
              • 06.11.2015
              • 6

              #8
              Sorry about that... I'm such a noob

              Please find my code attached.

              -Antti
              Angehängte Dateien

              Kommentar


              • Andreas Lackner
                Andreas Lackner kommentierte
                Kommentar bearbeiten
                If you feed an RGB-signal (white will bei 100100100), you've to use inputType 0,3,4,6
                If you feed an Percentage-Signal (DIMMER_MIN to DIMMER_MAX), you've to use input type 1,2,5

                So maybe lines 38/39 should be
                inputType[0] = 0;
                inputType[1] = 0;

                Also change Line 13 to
                int DEBUG_LEVEL=2;
                so full log is writen.

                Makes some tests and post log...
            • Antti_K
              Azubi
              • 06.11.2015
              • 6

              #9
              Hi

              Those changes sure made some difference in the log. But was not able to lit those lamps :/
              In the log it is shown when I start my smartphone app, and try to control the lights.

              Antti
              Angehängte Dateien

              Kommentar


              • Andreas Lackner
                Andreas Lackner kommentierte
                Kommentar bearbeiten
                Are you sure about the bridges IP-address? I don't know the structure of your network, but be sure hue bridge can be reached by your loxone server.
            • Gast

              #10
              Hi Andreas Lackner, hi svethi

              I already wrote into the German forum, as I saw a long discussion there. I am not sure, if I done it right, I will try the English forum, maybe it is more suitable.

              I already have working Hue integration with Loxone. I have Loxone miniserver1, I have 25x Hue Bulbs White Ambiance. I am using the most recent version of your script. I am able to turn them on and off as well as dim them to some % of the power. I am using RGB output in Loxone, and 0 as the input config in the script.

              I am trying to change the White temperature with Loxone. from 2200K - 6000K or similar. I set up moods in Loxone Lightscontroler module, but it does not help.
              I have tried a lot of resources, I have tried playing around with different config setup.

              Does anyone of you have a White Ambiance E27 light bulb? Are you able to change the white temperature with Loxone?

              I would be super happy to get this working, as I have already spent countless hours trying. I am a technical person, but I can't solve this one.

              If you may share a little bit of your knowledge, it would be really appreciated.
              Thank you very much in advance.

              Merco

              Kommentar


              • Mighty5nake
                Mighty5nake kommentierte
                Kommentar bearbeiten
                update :

                it looks like i need no help after all , i want to post a update should there be someone having the same issues i had ...

                everything was correct configured, only difference is i am using Markers ... the marker had to be changed from digital to analog , now it works like a charm (with the LUMITECH configuration) , i'm not sure why this made it work and i am more than happy to learn something more about it, if you can explain it to me that would be nice ...

                friendly greetings.

              • Gast
                Gast kommentierte
                Kommentar bearbeiten
                Hello Mighty5nake,

                thank you for your comment. I am sorry I could have not helped earlier. It seems, that your comment may help me.
                I am using Lumitech now and bulbs are White Ambiance. I am able to turn on, off and to change MOOD-white temperature, which is great.
                But now for some reason, I am unable to use dimming function. Do you say switching to Analog may help?

              • Gast
                Gast kommentierte
                Kommentar bearbeiten
                Hi Mighty5nake, i am unable to use dimming. i tried to follow your steps. what are markers please?
            • mbee
              Azubi
              • 17.02.2018
              • 1

              #11
              Thank you very much Mighty5nake for the "markers in analog" trick! I was searching how to use the "tunable white" Hue bulbs with Loxone for months, now everything is working fine.
              Gast : what Mighty5nake calls a marker is a Memory flag. Set them to analog (otherwise they can only put 1 or 0, which explains why you cannot dim your lights).

              Kommentar

              • kazek127
                Azubi
                • 14.04.2024
                • 1

                #12
                Hi all,
                I do not want to open a new thread.
                I prepare pico code as in image. 2 first lights are RBB and last 3 is white. My problem is with turning off the lights. When I use double click the lights RGB go off only and White is still on. When I tap 1 and switch between modes the White lights move to off. I wondering how to off all lights by double-clic.
                The only solution/workaround is to set up the white tube as an RGB and in that case double click works

                Click image for larger version  Name:	image.png Views:	0 Size:	102.6 KB ID:	429500
                Click image for larger version  Name:	image.png Views:	0 Size:	85.7 KB ID:	429501Click image for larger version  Name:	image.png Views:	0 Size:	126.3 KB ID:	429502​​
                Zuletzt geändert von kazek127; 15.04.2024, 11:43.

                Kommentar

                Lädt...