Is it possible to set a bulb status manually

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Gast

    #1

    Is it possible to set a bulb status manually

    Hi Guys,

    I also asked Loxone support but they seem not able to answer me.

    Here's my problem:
    I have a Philips Hue bulb which I can control perfectly via a loxone touch. For this I use http commands. I can get the status of the hue bulb also via a http command.
    However, if I turn the lights on via the Hue app, Loxone of course doesn't know the changed status of the hue bulb.

    In order to fix this I would like to set the status of the virtual command manually (this means NOT sending a command but just update the status) so that it shows the correct status in my loxone app. I am going to get the status of the bulb with every motion sensor action such that I do not need to poll every n seconds

    The question is then: does anybody know if it's possible to set the status manually and how to do it?
    Any help is highly appreciated :-)

    Thanks!
    Tom
  • TomekWaw
    LoxBus Spammer
    • 25.07.2019
    • 436

    #2
    Doesn't look like a smart solution to me.
    Any reasons why you stick to Hue app instead of moving to Loxone app?

    I have multiple (>10 hue bulbs) and I control them all from Loxone touch switches and Loxone app only.
    Not using other apps since Loxone allows me to set everything including brightness and color.
    This is done mostly by a PicoC Program block with a script to control Hue bulbs that can be found here.
    I'm using Conbee II stick, but I suppose API is compatible.
    Noch ein oder zwei Jahre mit Loxone und ich werde Deutsch sprechen

    Kommentar


    • maxw
      maxw kommentierte
      Kommentar bearbeiten
      He IS using the Loxone App and he asks for help updating Hue status in the Loxone App after it changed with a Loxone Touch.

    • TomekWaw
      TomekWaw kommentierte
      Kommentar bearbeiten
      "if I turn the lights on via the Hue app"
  • Gast

    #3
    Hi TomekWaw,

    I am using only Loxone to control my hue bulbs but I want a fail safe system. I want to be able to use both hue controls and loxone controls. Also image there is a power cut to the hue bulbs for any reason then Loxone will still think your ligths are on while they are not. I know how to query the status of the hue bulbs. Only thing is missing is how to set the status in Loxone.

    A perfect solution from Loxone would be that for a Virtual Output next to the ON and OFF commands there is a STATUS command where we can enter the command to get the status of a Virtual Command (ie Hue bulbs)

    Regards,

    Kommentar

    • TomekWaw
      LoxBus Spammer
      • 25.07.2019
      • 436

      #4
      @bauwt,

      Yeah, there's no feedback to Miniserver on changes made on the Hue bridge by different API clients.
      I personally don't get that need for fail safe control, but also don't see reason what that shouldn't be possible.
      Actually I'm also using such feedback loops, for instance with my Fibaro Wall Plugs, that can be controlled both with the Loxone App and physical button on the plug. And it's status is always in sync.

      Do you already have the API command to get status of the bulb?
      Are you using Lighting Controller to turn on the bulbs?

      BTW, there is also a solution to have bulb status in Loxone updated every single change made in Hue app,
      but it requires Raspberry Pi board with LoxBerry system and some plugins. Just saying in case you already had one.
      Zuletzt geändert von TomekWaw; 30.11.2019, 17:22.
      Noch ein oder zwei Jahre mit Loxone und ich werde Deutsch sprechen

      Kommentar


      • Gast
        Gast kommentierte
        Kommentar bearbeiten
        Hi TomekWaw, yes I'm using a Lighting Controller and I have the API command to get the status.

        You say you are using fibaro wall plugs and that it's always in sync. So, if you push on the wall plug button, you see it in Loxone app? This is exactly what I need. How did you do it :-)

        I have searched in Loxberry (actually have it running for sonos integration) but I couldn't find anything except in the wanted plugins section. Also looked at OpenHAB but the binding there also doesn't allow for the state to be set.
    • TomekWaw
      LoxBus Spammer
      • 25.07.2019
      • 436

      #5
      Hi @bauwt,

      I will describe it for you briefly in points.

      First, Fibaro Wall Plug loopback:
      1. I'm using FHEM Plugin to manage my Z-wave devices. FHEM has all current readings of wall plug, including "state" (see attachment 1)
      2. I'm using MQTT-Gateway plugin, that includes Mosquito MQTT broker and an engine for pushing new MQTT readings to Loxone Miniserver over UDP or HTTP. I'm using UDP.
      3. In FHEM I could publish only wall plug state to MQTT, but as I have multiple different devices in FHEM with different readings I'm interested in, it's more convenient for me to push ALL FHEM readings to MQTT. For command set to push all FHEM reading to MQTT see attachment 2
      4. So now I have MQTT topic fhem/Fibaro_Wall_Plug_1/state with value on or off depending on real state of the wall plug.
      5. To have it sent to Loxone I need: a) subscribe that topic in MQTT-Gateway plugin and b) convert "off" to value 0 and "on" to value 1, as I'm using UDP. See attachments 3 and 4 for that.
      6. Now I just need to add Virtual Input in Loxone Config. See attachment 5 and 6 for that.
      7. I've used a simple Switch block in Loxone Config that has a Virtual Output connected to control the wall plug (http call to FHEM "/fhem?cmd=set%20Fibaro_Wall_Plug_1%20on" and "...off"). The point is, it also has external input control. See attachment 7. Please note: Push switch block is used here solely to detect edge (it's not used in Visualization!). Since new Loxone Config version >10.3 you've better use new "Edge detection" block instead.
      Easy!

      So you may do exactly the same with Hue Lights.
      1. Install FHEM Plugin in your LoxBerry.
      2. Connect FHEM to HUEBridge with included Hue module. Command set starts with something like define MyBridge HUEBridge HUEbrideIP:HuePort. Read FHEM HUE-module docs for details how to connect it.
      3. After you sync lights from HUE Bridge to FHEM, you will be getting all reading for every Light. See Attachment 8 for readings of one of my Philips bulbs.
      4. Since I push all readings to MQTT, I would have that bulb state under something like fhem/Philips_Bulb_1/state
      5. Then I would subscribe to that topic in MQTT Gateway plugin and push it to Loxone.
      6. Finally, I would create Virtual Input with Philips Bulb 1 state in Loxone Config.
      7. Then you might use Edge detection block out of its input and connect it to O and R inputs of Lighting Controller block.
      8. If you had more than one bulbs/lights used on that Lighting Controller, that's another challenge, but I suppose it is out of the scope of this topic.
      9. A different challenge is to sync back more than just a state (on or off). Think of ct / bri / rgb readings for a full blown RGB(W) bulb. But I suppose it's also possible.
      You will probably figure out all details on your own, if not - just ask me for details on the very specific points of this mini-howto
      Angehängte Dateien
      Zuletzt geändert von TomekWaw; 02.12.2019, 15:27.
      Noch ein oder zwei Jahre mit Loxone und ich werde Deutsch sprechen

      Kommentar


      • Gast
        Gast kommentierte
        Kommentar bearbeiten
        Wow, that's an elaborate answer! Thanks a lot, appreciate it!
        I'll have a look tonight
    • TomekWaw
      LoxBus Spammer
      • 25.07.2019
      • 436

      #6
      Only 5 attachments allowed in single post, so here 3 following
      Angehängte Dateien
      Noch ein oder zwei Jahre mit Loxone und ich werde Deutsch sprechen

      Kommentar

      • Labmaster
        Lox Guru
        • 20.01.2017
        • 2574

        #7
        Ich you need to sync with an external control and you do not need the Lighting Controller for it, then you always could use EIB-Dimmer and EIB-Button. They both have status inputs.

        Kommentar

        • Gast

          #8
          Hi Bauwt

          Did you solve the "problem"? I'm looking for the exact same solution.
          I managed to get my Sonos in sync even the volume control. (UDP)

          How do you get the Hue state of bulbs?

          Regards
          Nik

          Kommentar

          • Gast

            #9
            Hi thekane,

            I'm sorry for not getting back sooner. Hope you solved in meanwhile :-)

            I did solve it. I use a EIV-Button as suggested by Labmaster with a status input which I set using a pico program that checks the status every 3 seconds

            Regards,
            Tom

            Kommentar

            • Gast

              #10
              Hi Tom
              No, actually not. gave up at some point
              Any chance that you share your solution with some screenshots?

              Regards
              Nik

              Kommentar

              • Iksi
                Lox Guru
                • 27.08.2015
                • 1111

                #11
                I think what you could try would be to check if the feedback from the bulb is not equal to the output of the light controller. If it is not equal you could change the state of the light controller via an virtual output which uses the loxone webservices. There you can set the state to the same state as the feedback. It would send the command again to the hue bulb. But if you send an on command while it is on won't be a problem....
                I described it here https://loxwiki.atlassian.net/wiki/s...rt+einschalten
                There I use an Hardware button to switch on a dimmable light with an standardvalue like 40%. It is possible to do with the webservices.....
                Only contra is u have to set the user and password in the virtual output....

                Kommentar

                • Gast

                  #12
                  Hi Nik,

                  Sorry to hear that. I do know the feeling :-) Loxone makes simple tasks very difficult sometimes.

                  I'll share my solution. Hope it helps you.
                  1. Create a virtual input that holds the state of the hue bulbs in a room (defined in hue app)
                  2. Create a EIB push button functional block to control the hue bulbs
                  3. Connect the virtual input to the state input of the EIB push button
                  4. Create (you probably already have it) a virtual output command to send commands to hue
                  5. Connect the Q output to this virtual output command
                  6. Create a Program functional block and put the source code at the bottom of this post in it.

                  This pico program will call the hue bridge api every 6 seconds to get the status of the hue thing you want to control. It will set the status of both the virtual input and virtual output according to what it gets from the api

                  This way, these things are always (or after 60 seconds) in sync even if you use the hue app or any hue hardware device such as the dimmer.


                  Like so:

                  Klicke auf die Grafik für eine vergrößerte Ansicht  Name: Hue.png Ansichten: 0 Größe: 12,8 KB ID: 339575

                  Pico source code:

                  #define BUFF_SIZE 40000
                  #define RD_BLOCK_SIZE 128

                  char* GetStatus(){
                  STREAM* pTcpStream = stream_create("/dev/tcp/<yourhuebridgeip>/80/api/<yourbridgetoken>/groups/1",0,0); // create tcp stream
                  char* pTcpCmd = "GET /api/<yourbridgetoken>/groups/1 HTTP/1.0\r\nHost: <yourhuebridgeip>\r\nUser-Agent: LoxLIVE [en]\r\nContent-Type: application/json; charset=utf-8\r\n\r\n";

                  stream_write(pTcpStream,pTcpCmd,strlen(pTcpCmd)); // write to output buffer
                  stream_flush(pTcpStream); // flush output buffer
                  //printf("%s",pTcpStream);
                  char szBuffer[BUFF_SIZE];
                  char szTmpBuffer[RD_BLOCK_SIZE];
                  int nCnt;
                  int nBytesReceived = 0;
                  // read stream
                  do{
                  nCnt = stream_read(pTcpStream,szTmpBuffer,RD_BLOCK_SIZE,4 000);
                  if (nCnt + nBytesReceived > BUFF_SIZE){
                  nBytesReceived = -1;
                  break; //File is too large
                  } else if(nCnt > 0){
                  strncpy((char*)szBuffer + nBytesReceived, szTmpBuffer, nCnt);
                  nBytesReceived += nCnt;
                  }
                  } while (nCnt > 0);
                  szBuffer[nBytesReceived] = 0;
                  stream_close(pTcpStream);
                  return szBuffer;
                  }

                  while(TRUE){
                  char* status = GetStatus();
                  int pos = strfind(status, ""any_on":true", 0);
                  if (pos > 0){
                  if (getio("thenameofyourvirtualinputthatholdsthehuest ate") != 1){
                  setio("thenameofyourvirtualinputthatholdsthehuesta te", 1);
                  setio("thenameofyourvirtualoutputthatcontrolshuein aroom",1);
                  }
                  } else {
                  if (getio("thenameofyourvirtualinputthatholdsthehuest ate") != 0){
                  setio("thenameofyourvirtualinputthatholdsthehuesta te", 0);
                  setio("thenameofyourvirtualoutputthatcontrolshuein aroom",0);
                  }
                  }
                  int virtualInState = getio("thenameofyourvirtualinputthatholdsthehuesta te");
                  printf("thenameofyourvirtualinputthatholdsthehuest ate status: ");
                  printf("%d", virtualInState);

                  int virtualOutputStatus = getio("thenameofyourvirtualoutputthatcontrolshuein aroom");
                  printf("thenameofyourvirtualoutputthatcontrolshuei naroom status: ");
                  printf("%d", virtualOutputStatus);

                  sleeps(60);
                  }
                  Zuletzt geändert von Gast; 27.02.2022, 17:26.

                  Kommentar

                  • Gast

                    #13
                    Hi all,

                    I revisited my solution again because the above solution doesn't work with the central on/off functionality.

                    To be able let this work, I added a lighting controller and created 2 moods which have id 0 and 1.
                    0 being off (which is default in moods) and 1 which is ON. (I excluded the Bright from the +)

                    Then I created a lighting controller and linked the status virtual input to the AIs input of the controller. The pico program sets the status virtual input to either 0 or 1 thus effectively setting the correct mood.
                    Clicking on the central all lights off function will also turn off this lighting controller's attached lights.

                    Here's my new screenshot of my config

                    Klicke auf die Grafik für eine vergrößerte Ansicht

Name: hue-rev.png
Ansichten: 1349
Größe: 16,0 KB
ID: 340227
                    This solution works well with any moods defined in Hue as it constantly maps the Hue mood to the Loxone mood

                    Kommentar

                    Lädt...