Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Vorlage] LightControl

    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

    [Vorlage] LightControl

    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Dirk @Pittini last edited by

      @pittini sagte in [Vorlage] LightControl:

      @dirk Ja is klar dass da Fehler kommen, Du hast ja nach power alles gelöscht statt nur oid leerzu lassen. Das kann so nicht gehen. Hier mal ein Beispiel (was in der Basiskonfig eigentlich ja schon drin ist, hättest nur abkupfern müssen) für sone Ein/Aus Lampe:

      2: {
                      description: "Stehlampe Couch",
                      power: { oid: "sonoff.0.Sonoff20.POWER", onVal: true, offVal: false },
                      bri: { oid: "", minVal: null, maxVal: null, defaultVal: null },
                      ct: { oid: "", minVal: null, maxVal: null },
                      sat: { oid: "", minVal: null, maxVal: null },
                      modeswitch: { oid: "", whiteModeVal: false, colorModeVal: true },
                      color: { oid: "", type: "", default: "" }
                  },
      

      Alles Klar --> Sorry da habe ich die Beispiele nicht gründlich genug durchgeschaut und mich von diesem Satz aus der Doku --> Nachdem ihr das Skript in ein neues Js Projekt kopiert habt, müßt ihr dem Skript Eure Leuchtmittel bekannt machen, es wird mindestens ein Schaltdatenpunkt (an/aus) erwartet. <-- verwirren lassen.

      Ich ändere das und teste weiter.

      Danke für die schnelle Antwort
      Dirk

      1 Reply Last reply Reply Quote 0
      • P
        passuff last edited by passuff

        Vielen Dank für dieses tolle Skript. Leider habe ich ein paar Probleme damit:

        2022-01-18 23:32:43.694 - info: javascript.0 (32839) script.js.common.Licht.LightControl: adaptiveCtLinear=0 adaptiveCtSolar=0 adaptiveCtSolarInterpolated=0 adaptiveCtTimed=0
        2022-01-18 23:32:50.285 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Triggered linked Sensor mihome.0.devices.sensor_motion_aq2_158d0004aca6b9.state new value is true
        2022-01-18 23:32:50.286 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Reaching SummarizeSensors, Group=0
        2022-01-18 23:32:50.286 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Gruppe=0 Sensor 2 with target mihome.0.devices.sensor_motion_aq2_158d0004aca6b9.state has value true
        2022-01-18 23:32:50.287 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Summarized IsMotion for Group 0 = true
        2022-01-18 23:32:50.287 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Reaching Controller, Group=0 Property1=isMotion NewVal=true OldVal=false
        2022-01-18 23:32:50.287 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Motion for Group 0 (Flur ) detected, switching on
        2022-01-18 23:32:50.288 - info: javascript.0 (32839) script.js.common.Licht.LightControl: Reaching GroupPowerOnOff for Group 0 (Flur), OnOff=true rampOn=false - {"enabled":false,"time":10,"switchOutletsLast":true} rampOff=false - {"enabled":false,"time":10,"switchOutletsLast":false}
        2022-01-18 23:32:50.288 - info: javascript.0 (32839) script.js.common.Licht.LightControl: SimpleGroupPowerOnOff: Normales anschalten ohne Ramping für Flur
        2022-01-18 23:32:50.312 - error: javascript.0 (32839) script.js.common.Licht.LightControl: TypeError: Cannot read property 'val' of null
        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at SimpleGroupPowerOnOff (script.js.common.Licht.LightControl:707:83)
        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at GroupPowerOnOff (script.js.common.Licht.LightControl:736:9)
        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at AutoOnMotion (script.js.common.Licht.LightControl:965:9)
        2022-01-18 23:32:50.316 - error: javascript.0 (32839) at Controller (script.js.common.Licht.LightControl:1166:17)
        

        Ich kann die Fehlermeldungen nicht nachvollziehen und würde mich freuen, wenn mir jemand dabei helfen könnte.
        Ich habe lediglich zwei Shelly Dimmer und drei mihome BWM in Betrieb:

        const praefix = "0_userdata.0.LightControl2" // Skriptordner
        const LuxSensor = 'wiffi-wz.0.root.192_168_1_155.w_lux'; // Datenpunkt des globalen Luxsensors, wird verwendet wenn in der Gruppe kein gesonderter definiert wird
        const IsPresenceDp = ""; // Datenpunkt für Anwesenheit (true/false)
        const PresenceCountDp = ""; // Datenpunkt für Anwesenheitszähler
        const logging = true; // Logging an/aus
        const RampSteps = 10; //Wieviele Schritte zum dimmen? Bitte nicht zu hoch setzen, wird zwar smoother, kann aber zu timing Problemen führen wenn gleichzeitig eine kurze Zeit in den Objekten gewählt.
        
        const minCt = 2700; //Regelbereich für Farbtemperatur in Kelvin für Adaptive Ct
        const maxCt = 6500;//Regelbereich für Farbtemperatur in Kelvin für Adaptive Ct
        const minBri = 10; //Mindesthelligkeit für AdaptiveBri
        
        const LightGroups = {
            0: {
                description: "Flur",
                lights: {
                    0: {
                        description: "StrahlerOG1",
                        power: { oid: "shelly.0.SHDM-2#C45BBE5645E3#1.lights.Switch", onVal: true, offVal: false },
                        bri: { oid: "shelly.0.SHDM-2#C45BBE5645E3#1.lights.brightness", minVal: 0, maxVal: 100, defaultVal: 100 },
                        ct: { oid: "", minVal: null, maxVal: null },
                        sat: { oid: "", minVal: null, maxVal: null },
                        modeswitch: { oid: "", whiteModeVal: false, colorModeVal: true },
                        color: { oid: "", type: "", default: "" }
                    },
                    1: {
                        description: "StrahlerEG",
                        power: { oid: "shelly.0.SHDM-2#E0980694DB0C#1.lights.Switch", onVal: true, offVal: false },
                        bri: { oid: "shelly.0.SHDM-2#E0980694DB0C#1.lights.brightness", minVal: 0, maxVal: 100, defaultVal: 100 },
                        ct: { oid: "", minVal: null, maxVal: null },
                        sat: { oid: "", minVal: null, maxVal: null },
                        modeswitch: { oid: "", whiteModeVal: false, colorModeVal: true },
                        color: { oid: "", type: "", default: "" }
                    },
                },
                sensors: {
                    0: { id: 'mihome.0.devices.sensor_motion_aq2_158d0002ea1b58.state', motionVal: true, noMotionVal: false },
                    1: { id: 'mihome.0.devices.sensor_motion_aq2_158d0002ebffca.state', motionVal: true, noMotionVal: false },
                    2: { id: 'mihome.0.devices.sensor_motion_aq2_158d0004aca6b9.state', motionVal: true, noMotionVal: false }
                }
            }, 
        };
        

        folgend noch das vollständige Skript:

        LightControl_20220119.txt

        Schmakus 1 Reply Last reply Reply Quote 0
        • Schmakus
          Schmakus Developer @passuff last edited by

          @passuff Zeig mal die Datenpunkte "Switch" von deinen 2 Shelly Dimmern.

          P 1 Reply Last reply Reply Quote 0
          • P
            passuff @Schmakus last edited by

            @schmakus sagte in [Vorlage] LightControl:

            @passuff Zeig mal die Datenpunkte "Switch" von deinen 2 Shelly Dimmern.

            {
              "type": "state",
              "common": {
                "type": "boolean",
                "read": true,
                "write": true,
                "name": "Switch",
                "role": "switch",
                "def": false
              },
              "native": {},
              "from": "system.adapter.shelly.0",
              "user": "system.user.admin",
              "ts": 1641885787418,
              "_id": "shelly.0.SHDM-2#C45BBE5645E3#1.lights.Switch",
              "acl": {
                "object": 0,
                "state": 0,
                "owner": "system.user.admin",
                "ownerGroup": "system.group.administrator"
              }
            }
            
            Schmakus 1 Reply Last reply Reply Quote 0
            • ?
              A Former User last edited by

              Hallo, ich habe das Skript erfolgreich eingefügt und meine Lampen eingetragen. Es funktioniert alles super BWM etc. funktioniert alles. Mir ist aber eine Sache aufgefallen, wenn ich über Google Home sage: Wohnzimmer Decke auf 80% dann wird zwar der Wert bei bri geändert aber die Lampen gehen nicht mit an. Sonst (vor dem Skript) war es so, dass das Licht bei bri Änderung angegangen ist. Gibt es da eine Funktion in dem Skript? Jetzt muss ich immer zwei Befehle absetzen, einmal Lichthelligkeit und Licht anschalten.

              P 1 Reply Last reply Reply Quote 0
              • P
                Pittini Developer @Guest last edited by

                @kilian-z Its not a bug, its a feature. Hintergrund ist der, das bei der adaptiven Helligkeit, permanent die Helligkeit gesetzt wird damit das beim einschalten passt. Und wäre es so, wie Du es gern hättest, dann würde alle paar Sekunden das Licht angehen ;).

                ? 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @Pittini last edited by

                  @pittini Danke @pittini. Ja das macht Sinn. Nutze bis jetzt noch nicht die adaptive Helligkeit.

                  Schmakus 1 Reply Last reply Reply Quote 0
                  • Schmakus
                    Schmakus Developer @Guest last edited by

                    @kilian-z said in [Vorlage] LightControl:

                    @pittini Danke @pittini. Ja das macht Sinn. Nutze bis jetzt noch nicht die adaptive Helligkeit.

                    Du vielleicht nicht, aber das Script intern.
                    Wie hast du GoogleHome eingebunden? Per iot? Wenn ja, einfach beide Datenpunkte, Power und Bri als ein Gerät anlegen.

                    ? 1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User @Schmakus last edited by

                      @schmakus Danke für die Antwort. Ich habe alle drei Datenpunkte in einem Gerät über iot eingebunden.

                      Schmakus 1 Reply Last reply Reply Quote 0
                      • Schmakus
                        Schmakus Developer @passuff last edited by Schmakus

                        @Pittini Die Fehlermeldung im log von @passuff deutet doch darauf hin, dass der Wert des Switch nicht gelesen werden kann, weil entweder kein Wert vorhanden ist, oder der Pfad zum DP nicht stimmt, oder?

                        2022-01-18 23:32:50.312 - error: javascript.0 (32839) script.js.common.Licht.LightControl: TypeError: Cannot read property 'val' of null
                        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at SimpleGroupPowerOnOff (script.js.common.Licht.LightControl:707:83)
                        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at GroupPowerOnOff (script.js.common.Licht.LightControl:736:9)
                        2022-01-18 23:32:50.315 - error: javascript.0 (32839) at AutoOnMotion (script.js.common.Licht.LightControl:965:9)
                        2022-01-18 23:32:50.316 - error: javascript.0 (32839) at Controller (script.js.common.Licht.LightControl:1166:17)
                        
                        1 Reply Last reply Reply Quote 0
                        • Schmakus
                          Schmakus Developer @Guest last edited by

                          @kilian-z said in [Vorlage] LightControl:

                          @schmakus Danke für die Antwort. Ich habe alle drei Datenpunkte in einem Gerät über iot eingebunden.

                          👍 Ich habe immer Power, Bri, ct und color eingebunden.

                          ? 1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User @Schmakus last edited by

                            @schmakus Du musst aber trotzdem zwei Befehle absenden oder? Wenn Lampe aus ist: Helligkeit einstellen und dann Lampe anschalten. Habe ich das richtig verstanden?

                            Schmakus 1 Reply Last reply Reply Quote 0
                            • D
                              Dragon last edited by

                              In deinem Skript muss ein Datenpunkt mit einer Anzahl an anwesenden Personen angegeben werden. Darf ich fragen wofür er benötigt wird? Ich habe tatsächlich keinen Datenpunkt, da ich auch andere Geräte auf Presence checke...

                              Schmakus 1 Reply Last reply Reply Quote 0
                              • Schmakus
                                Schmakus Developer @Guest last edited by

                                @kilian-z said in [Vorlage] LightControl:

                                @schmakus Du musst aber trotzdem zwei Befehle absenden oder? Wenn Lampe aus ist: Helligkeit einstellen und dann Lampe anschalten. Habe ich das richtig verstanden?

                                Genau. Beim schalten per "power" Datenpunkt wird die Helligkeit, welche zuvor bei "bri" gesetzt ist an die Lampe gesendet.

                                1 Reply Last reply Reply Quote 0
                                • Schmakus
                                  Schmakus Developer @Dragon last edited by

                                  @dragon said in [Vorlage] LightControl:

                                  In deinem Skript muss ein Datenpunkt mit einer Anzahl an anwesenden Personen angegeben werden. Darf ich fragen wofür er benötigt wird? Ich habe tatsächlich keinen Datenpunkt, da ich auch andere Geräte auf Presence checke...

                                  Es gibt ja quasi 2 Variablen dafür. Einmal An- und Abwesenheit und dann den von dir beschriebenen.
                                  Dieser wird benötigt, wenn du auch "AutoOn bei Anwesenheitszählererhöhung ab bestimmter Helligkeit (Begrüßungslicht bei heimkommen)" verwenden möchtest. einfach leer lassen, wenn du keinen Zähler hast.

                                  1 Reply Last reply Reply Quote 0
                                  • R
                                    Rudi-Ment last edited by

                                    Hallo.

                                    Auch ich habe das Script zum Laufen gebracht und schon ein paar Lampen eingebunden.

                                    Nun habe ich aber mehrere RGBWW LED Streifen in der Stube, die ich gerne gruppieren möchte.

                                    Da gibt es aber zwei mal Power und zwei mal Dimmer. Außerdem haben die Colorwerte mit #00000000 bis #FFFFFFFF. Wie binde ich die ein ?

                                    Schmakus 1 Reply Last reply Reply Quote 0
                                    • Schmakus
                                      Schmakus Developer @Rudi-Ment last edited by

                                      @rudi-ment Um welche LED Streifen handelt es sich genau? Ich habe z.b. Shelly RGBW2 eingebunden. Das mit dem Hex klappt jedoch nur für die RGB Farben. Den Weißkanal steuere ich über die Farbtemperatur.

                                      R 1 Reply Last reply Reply Quote 0
                                      • R
                                        Rudi-Ment @Schmakus last edited by

                                        @schmakus Das ist eine gute Idee. Bei den Shelly kann ich das so machen.
                                        Bei den mit Tasmota geflashten LED Treibern gibt es aber zwei mal Power. Einmal bunt und einmal weiß.
                                        Da weiß ich nicht weiter.
                                        Aber in der nächsten Zeit werden die Tasmota-Teile wohl eh rausfliegen.
                                        Die Verbindung ist so unzuverlässig...
                                        Vielleicht hat sich das damit schon erledigt.

                                        1 Reply Last reply Reply Quote 0
                                        • R
                                          Rudi-Ment last edited by

                                          Das mit dem Weissabgleich bekomme ich nicht hin.
                                          Magst du mir vielleicht mal ein Beispiel zeigen ?

                                          1 Reply Last reply Reply Quote 0
                                          • fischi87
                                            fischi87 @Pittini last edited by

                                            @pittini hallo, wird es davon mal einen Adapter geben oder wird es lediglich als Skript bleiben?

                                            grüße

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            875
                                            Online

                                            31.8k
                                            Users

                                            79.9k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript template
                                            25
                                            224
                                            26501
                                            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