Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Philips Hue Szenen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Philips Hue Szenen

    This topic has been deleted. Only users with topic management privileges can see it.
    • dslraser
      dslraser Forum Testing Most Active last edited by

      Du könntest mit diesem Script alle Hue Szenen auslesen und dann recht einfache Blocklys erstellen für den Cloudadater.

      ! ```
      `/* -- do not edit following lines - START --
      {
      "debug": false,
      "verbose": false
      }
      -- do not edit previous lines - END --*/
      var HueApi = require("node-hue-api").HueApi;
      ! // Replace IP and username!!!
      var host = "192.168.180.xx",
      username = "xxx",
      api = new HueApi(host, username);

      var groups_ = [],
      lights_ = [],
      objects_ = [];

      ! // Log JSON results
      var displayResults = function(result) {
      console.log('Reponse: '+JSON.stringify(result, null, 2));
      };
      ! // Parse Light Group 0 (All Lights)
      var parseGroup0 = function(result) {
      if (!result.lights){return} // Empty group

      var id = result.id,
          lights = result.lights,
          name = "All Lights";
      console.debug('group: '+name+', lights: '+lights);
      groups_[lights] = name;
      

      };

      ! // Parse Light Groups
      var parseGroups = function(result) {
      for (var i = 0; i < result.length; i++) {
      if (!result[i].lights){continue} // Empty group

          var id = result[i].id,
              lights = result[i].lights,
              name = result[i].name;
          console.debug('group: '+name+', lights: '+lights);
          groups_[lights] = name;
      }
      

      };

      ! // Parse Lights
      var parseLights = function(result) {
      for (var i = 0; i < result.length; i++) {
      var id = result[i].id,
      name = result[i].name;
      console.debug('light: '+name+', id: '+id);
      lights_[id] = name;
      }
      };
      ! // Create States in ioBroker
      var createStates = function(result) {
      // Resync button
      createState('PhilipsHue.Scenes.Resync', false, {role: "button", name: 'Resync Philips Hue Groups, Lights and Scenes'});
      ! for (var i = 0; i < result.length; i++) {
      if (!result[i].appdata.data){continue} // skip internal szenes
      ! var id = result[i].id,
      lights = result[i].lights,
      name = result[i].name.replace(/"/g,''),
      pathname = name.replace(/ /g,'_');

          // Get light names
          var light_names = [];
          for (var j = 0; j < lights.length; j++) {
              var light_name = lights_[lights[j]];
              light_names.push(light_name);
          }
      

      ! // Room, group or lights linked with scene
      var group = 'Group: '+groups_[lights] || 'Lights: '+light_names.join(", ");

          // Create States and skip duplicates
          if (!objects_[lights+pathname]){
              console.debug('scene: '+name+', '+group);
              createState('PhilipsHue.Scenes.'+pathname+'.'+id, false, {role: "button", name: 'Scene: '+name+' ('+group+')'});
              objects_[lights+pathname] = true;
          }
      }
      

      };

      ! // Delete States
      function deleteStates(){
      console.log('Deleting current objects for scenes...');
      objects_ = [];
      $('javascript.0.PhilipsHue.Scenes.*').each(function (id) {
      deleteState(id);
      });
      }
      ! // Fetch data from Hue API
      function init(){
      api.getGroup(0, function(err, group0) {
      if (err) throw err;
      console.log('Processing group 0...');
      //displayResults(group0);
      parseGroup0(group0);
      });
      api.groups(function(err, groups) {
      if (err) throw err;
      console.log('Processing ' + groups.length + ' groups...');
      //displayResults(groups);
      parseGroups(groups);
      });
      ! api.lights(function(err, lights) {
      if (err) throw err;
      console.log('Processing ' + lights.lights.length + ' lights...');
      //displayResults(lights);
      parseLights(lights.lights);
      });
      ! api.scenes(function(err, scenes) {
      if (err) throw err;
      console.log('Processing ' + scenes.length + ' scenes...');
      //displayResults(scenes);
      createStates(scenes);
      });
      }
      ! // Init on start
      init();
      ! // Activate scene
      on({id: /^javascript.0.PhilipsHue.Scenes./, val: true}, function (obj) {
      if (obj.id == 'javascript.0.PhilipsHue.Scenes.Resync'){return}
      sceneId = obj.id.split('.').pop();
      console.log('Activating '+obj.name);
      api.activateScene(sceneId, function(err, result) {
      if (err) throw err;
      displayResults(result);
      });
      setState(obj.id, false);
      });
      ! // Resync
      on({id: 'javascript.0.PhilipsHue.Scenes.Resync', val: true}, function (obj) {
      console.log('Resync triggered...');
      groups_ = [];
      lights_ = [];
      deleteStates();
      init();
      });
      ! schedule("0 3 * * *", function () {
      console.log('Resync triggered...');
      groups_ = [];
      lights_ = [];
      deleteStates();
      init();
      });`
      Du musst nur Deine IP Adresse und Benutzer von der HUE Bridge eintragen.
      ! Die Szenen findest Du dann unter javascript.0
      ! Wenn Du Hilfe beim Blockly brauchst sag Bescheid.
      ! PS: Im Javascript Adapter noch diesen Eintrag wie im Bild vornehmen[img]https://uploads.tapatalk-cdn.com/201809 ... c9b6c2.jpg[/img][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]

      1 Reply Last reply Reply Quote 0
      • N
        Nakashi last edited by

        Vielen Dank werde ich morgen Nachmittag ausprobieren und mich dann melden

        Gesendet von iPhone mit Tapatalk

        1 Reply Last reply Reply Quote 0
        • N
          Nakashi last edited by

          Das Script hat super funktioniert danke dafür

          habe auch die einbindung ins homekit wia blockly geschafft muss jetzt nur noch einen anzeigefehler geheben wenn ich direkt von normalem licht auf nachtlicht umschalte und umgekehrt

          1 Reply Last reply Reply Quote 0
          • dslraser
            dslraser Forum Testing Most Active last edited by

            prima, freut mich das ich helfen konnte.

            Ich finde das Script auch gut, weil man so an die Hue Szenen drann kommt.

            1 Reply Last reply Reply Quote 0
            • haselchen
              haselchen Most Active last edited by

              Muss mich mal mit einklinken.

              Danke erstmal fürs Skript.

              Wie verarbeite ich die Szenen in Blockly?

              Mit welchen Bausteinen.

              1 Reply Last reply Reply Quote 0
              • dslraser
                dslraser Forum Testing Most Active last edited by

                @haselchen:

                Muss mich mal mit einklinken.

                Danke erstmal fürs Skript.

                Wie verarbeite ich die Szenen in Blockly?

                Mit welchen Bausteinen. ` ich verstehe die Frage zwar nicht so genau, aber anbei mal ein Beispiel mit einer Standard Szene - Energie tanken. (geht auch mit selbst erstellten Szenen)

                Falls Du das meinst…![](</s><URL url=)<link_text text="https://uploads.tapatalk-cdn.com/201812 ... b462d1.jpg">https://uploads.tapatalk-cdn.com/20181206/55994dcbbe433fe00629fb9f9bb462d1.jpg</link_text>" />

                1 Reply Last reply Reply Quote 0
                • haselchen
                  haselchen Most Active last edited by

                  Genau das meinte ich. Vielen Dank für das Beispiel.

                  1 Reply Last reply Reply Quote 0
                  • A
                    Alex975 last edited by

                    ich hänge mal meine Frage aus nem anderen Unterforum hier an:

                    viewtopic.php?f=20&t=19332

                    1 Reply Last reply Reply Quote 0
                    • siggi85
                      siggi85 last edited by

                      Kann man das Script zum Import der in der Bridge gespeicherten Szenen nicht auch in den Hue Adapter einbauen? Ich denke dass viele Leute so etwas gebrauchen können.

                      1 Reply Last reply Reply Quote 1
                      • A
                        aleks-83 last edited by

                        @siggi85:

                        Kann man das Script zum Import der in der Bridge gespeicherten Szenen nicht auch in den Hue Adapter einbauen? Ich denke dass viele Leute so etwas gebrauchen können. `
                        Das denke ich auch!

                        Ich nutze das Skript auch. Richtig super!

                        Ich schalte damit bestimmte hie Szenen wenn ich an meiner harmony Aktionen starte oder stoppe.

                        Funktioniert auch wie gewünscht.

                        Gibt es eine Möglichkeit, die Szenen langsam über zu blenden?

                        Also aktuell wird die neue Szene einfach eingeschaltet.

                        Ich möchte gerne dass die aktuelle Einstellung in die neue Szene überblendet. Innerhalb z.B. 3 Sekunden.

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        710
                        Online

                        31.9k
                        Users

                        80.2k
                        Topics

                        1.3m
                        Posts

                        7
                        13
                        2292
                        Loading More Posts
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes
                        Reply
                        • Reply as topic
                        Log in to reply
                        Community
                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                        The ioBroker Community 2014-2023
                        logo