Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. LePremier

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    L
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 0
    • Groups 0

    LePremier

    @LePremier

    0
    Reputation
    3
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    LePremier Follow

    Latest posts made by LePremier

    • RE: Abfrage mit Axios

      @cash Cool, funktioniert wunderbar! Vielen Dank dafür.

      Als Anpassung habe ich zusätzlich Variablen für <command>, <bright> und <temp> eingeführt.

      In meinem Setup wird Deine Funktion selbst nun ausgelöst, sobald sich bei mir der Wert des ioBroker Objects "CustomDevices.KeyLight.On" ändert. Je nach Wert (true oder false) wird die Funktion dann mit <command> = 1 bzw. <command> = 0 gestartet. Zusätzlich werden auch die gerade in den Objekten "CustomDevices.KeyLight.Brightness" und "CustomDevices.KeyLight.Temperature" hinterlegten Werte ausgelesen, in <bright> bzw. <temp> geschrieben und an Deine (entsprechend erweiterte) Funktion übergeben.

      Im nächsten Schritt werde ich noch die Definition verschiedener Szenen einbauen.

      Mein bisheriger Code (zum Teil in Blockly erstellt) sieht so aus:

      var command, bright, temp;
      
      // Beschreibe diese Funktion …
      async function SwitchLight(command, bright, temp) {
          var logging = false;
          var debugging = false;
          function func_elgato_schalten(){
              const axios = require('axios');
              axios({
                  method: 'put',
                  baseURL: 'http://192.168.178.183:9123/elgato/lights',
                  headers: {'Content-Type':'application/x-www-form-urlencoded'} ,    
                  data: {
                          "lights":[{"brightness":bright,"temperature":temp,"on":command}],
                          "numberOfLights":1
                      },
                  timeout: 4500,
                  responseType: 'json'
               })
               .then((response) => {
                                     
                  if(debugging){
                      console.log('data:' +response.data);
                      console.log('Status: ' +response.status);
                      console.log('Header:' +response.headers);
                  }
                  if(response.status = 200){
                      //Umwandeln in String
                      var data_string = JSON.stringify(response.data)
                      //1. Split
                      var data_split= data_string.split("{");
                      //Unnötige Sachen entfernen
                      var data_replace = data_split[2].replace(/}|,|]|:/gi,'');
                      //mit 2. Split zum Ergebnis
                      var data_final = data_replace.split('"');
                      //Ergebnisse
                      var _Status = parseInt(data_final[2],10);
                      var _Helligkeit = parseInt(data_final[4],10);
                      var _Temperatur = parseInt(data_final[6],10);
                      
                      if(_Status == 1){
                          if(logging){
                              log('Elgato Key light air ist eingeschaltet');
                              log('Helligkeit: '+_Helligkeit +' --- Temperatur: '+_Temperatur);
                          
                          }
                      }
                      else{
                          if(logging){
                              log('Elgato Key light air ist ausgeschaltet');
                              //log('Helligkeit: '+_Helligkeit +' --- Temperatur: '+_Temperatur);
                          }
           
                      }
                      if(debugging){
                          log('Status: '+_Status);
                          log('Helligkeit: '+_Helligkeit);
                          log('Temperatur: '+_Temperatur);
                      
                      }
                  }
                  else{
                      if(logging){
                          log('Hier stimmt etwas nicht. Elgato Key Light air Meldung: '+response.status)
                      }
                  } 
           
                                      
           
              })
              .catch(
                  (error) => {
                      // handle error
                      log('Fehler bei der Abfrage der Elgator Key Light air: '+error,'warn');
                      if (error.response) {
                      // The request was made and the server responded with a status code
                      // that falls out of the range of 2xx
                          log(error.response.data);
                          log(error.response.status);
                          log(error.response.headers);
                      } 
                      else if (error.request) {
                          log('else-if');
                          // The request was made but no response was received
                          // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
                          // http.ClientRequest in node.js
                          console.log(error.request);
                      }
                      else {
                          // Something happened in setting up the request that triggered an Error
                          log('else');
                          log('Error: ' +error);
                     
                      }                    
                  }
              );
           
          }
          func_elgato_schalten();
      }
      
      
      on({id: '0_SmartStation.0.CustomDevices.KeyLight.On', change: "ne"}, async function (obj) {
        var value = obj.state.val;
        var oldValue = obj.oldState.val;
        if ((obj.state ? obj.state.val : "") == true) {
          await SwitchLight(1, getState("0_SmartStation.0.CustomDevices.KeyLight.Brightness").val, getState("0_SmartStation.0.CustomDevices.KeyLight.Temperature").val);
        } else if ((obj.state ? obj.state.val : "") == false) {
          await SwitchLight(0, getState("0_SmartStation.0.CustomDevices.KeyLight.Brightness").val, getState("0_SmartStation.0.CustomDevices.KeyLight.Temperature").val);
        }
      });
      
      posted in JavaScript
      L
      LePremier
    • RE: VIS zeigt nur "No connection" oder "..." an

      Hallo zusammen,

      bei mir taucht das beschriebene Problem leider auch auf. Ich schätze in meinem Fall hat es etwas mit der DNS-Auflösung zu tun.

      Ich nutze ioBroker ausschließlich lokal im LAN. Https ist aktiviert um ioBroker mit einem Login absichern zu können. Um eine saubere Authentifizierung hinzubekommen und Fehlermeldungen in Chrome zu vermeiden habe ich nach folgender Anleitung (sehr empfehlenswert!) ein eigenes Zertifikat generiert:

      SSL und Authentifizierung für den ioBroker Admin

      Schließlich habe ich in meinem DNS Server (Pi-hole) einen Eintrag für ioBroker hinterlegt, anhand dessen auf die lokale IP-Adresse übersetzt wird: iobroker.mydomain.local -> 192.168.178.xxx. Dies ist (nach meinem Verständnis) Voraussetzung um ein gültiges Zertifikat erzeugen zu können, da sich dieses nur auf einen entsprechenden "Klartext-Namen", nicht aber auf eine IP-Adresse beziehen kann.

      Damit lässt sich das Admin-Interface nun frei von Sicherheitswarnungen über https://iobroker.mydomain.local:8081 aufrufen. Soweit so gut.

      Für VIS habe ich das selbst generierte zusätzlich auch im Web-Adapter (Port 8082) und im Soketio-Adapter (Port 8084) hinterlegt.

      Beim Aufruf von VIS (Editor oder Runtime) kommt es nun aber zu dem beschriebenen "no connection" Problem, sobald der Aufruf über den Domain-Name (https://iobroker.mydomain.local:8082) erfolgt. Bei Aufruf über die IP-Adresse (https://192.168.178.xxx:8082) funktioniert zwar die Connection zum VIS-Server. Leider dann aber wieder mit den Sicherheitswarnungen (also ohne Zertifikat).

      Alles wurde x-Mal neugestartet, etc.

      Hat noch jemand das Problem und evtl. eine Lösung gefunden? Ich bin noch relativ neu bei ioBroker und inzwischen mit meinen Ideen ziemlich am Ende 😞

      Vielen Dank auf jeden Fall für euer Feedback 🙂

      Mein Setup:

      • Admin v. 4.2.1.
      • VIS v. 1.3.7.
      • Web Server v. 3.3.0
      • socket.io v. 3.1.4

      Log-Auszug:

      web.0	2021-02-04 22:06:57.334	debug	(119152) system.adapter.admin.0: logging true
      socketio.0	2021-02-04 22:06:57.334	debug	(119180) system.adapter.admin.0: logging true
      socketio.0	2021-02-04 22:06:24.365	info	(119180) <==Disconnect system.user.admin from ::ffff:192.168.178.117 vis.0
      web.0	2021-02-04 22:06:18.940	debug	(119152) system.adapter.admin.0: logging false
      socketio.0	2021-02-04 22:06:18.940	debug	(119180) system.adapter.admin.0: logging false
      host.iobroker	2021-02-04 22:06:07.896	info	instance system.adapter.yr.0 terminated with code 0 (NO_ERROR)
      host.iobroker	2021-02-04 22:06:00.050	info	instance system.adapter.yr.0 started with pid 119240
      socketio.0	2021-02-04 22:05:35.255	debug	(119180) system.adapter.admin.0: logging true
      web.0	2021-02-04 22:05:35.254	debug	(119152) system.adapter.admin.0: logging true
      socketio.0	2021-02-04 22:05:18.006	debug	(119180) Subscribes: *, vis.0.control.instance, vis.0.control.data, vis.0.control.command
      socketio.0	2021-02-04 22:05:17.216	debug	(119180) Subscribes: *
      socketio.0	2021-02-04 22:05:17.201	debug	(119180) 2021-02-04T21:05:17.201Z Request authenticate [system.user.admin]
      socketio.0	2021-02-04 22:05:16.897	debug	(119180) Connection from vis.0
      socketio.0	2021-02-04 22:05:16.640	info	(119180) ==>Connected system.user.admin from ::ffff:192.168.178.117
      socketio.0	2021-02-04 22:05:15.041	info	(119180) Secure socket.io server listening on port 8084
      socketio.0	2021-02-04 22:05:14.835	info	(119180) starting. Version 3.1.4 in /opt/iobroker/node_modules/iobroker.socketio, node: v12.20.0, js-controller: 3.1.6
      socketio.0	2021-02-04 22:05:14.571	debug	(119180) Plugin sentry Initialize Plugin (enabled=true)
      socketio.0	2021-02-04 22:05:14.124	debug	(119180) statesDB connected
      socketio.0	2021-02-04 22:05:14.123	debug	(119180) States connected to redis: 127.0.0.1:9000
      socketio.0	2021-02-04 22:05:14.112	debug	(119180) States create System PubSub Client
      socketio.0	2021-02-04 22:05:14.108	debug	(119180) States create User PubSub Client
      socketio.0	2021-02-04 22:05:14.100	debug	(119180) Redis States: Use Redis connection: 127.0.0.1:9000
      socketio.0	2021-02-04 22:05:14.098	debug	(119180) objectDB connected
      socketio.0	2021-02-04 22:05:14.090	debug	(119180) Objects connected to redis: 127.0.0.1:9001
      socketio.0	2021-02-04 22:05:14.069	debug	(119180) Objects client initialize lua scripts
      socketio.0	2021-02-04 22:05:14.067	debug	(119180) Objects create User PubSub Client
      socketio.0	2021-02-04 22:05:14.065	debug	(119180) Objects create System PubSub Client
      socketio.0	2021-02-04 22:05:14.061	debug	(119180) Objects client ready ... initialize now
      socketio.0	2021-02-04 22:05:14.024	debug	(119180) Redis Objects: Use Redis connection: 127.0.0.1:9001
      host.iobroker	2021-02-04 22:05:13.195	info	instance system.adapter.socketio.0 started with pid 119180
      host.iobroker	2021-02-04 22:05:06.221	info	instance system.adapter.socketio.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
      socketio.0	2021-02-04 22:05:05.669	info	(10151) Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
      socketio.0	2021-02-04 22:05:05.668	info	(10151) terminating
      socketio.0	2021-02-04 22:05:05.661	info	(10151) <==Disconnect system.user.admin from ::ffff:192.168.178.117 vis.0
      socketio.0	2021-02-04 22:05:05.660	info	(10151) terminating https server on port 8084
      socketio.0	2021-02-04 22:05:05.659	info	(10151) Got terminate signal TERMINATE_YOURSELF
      host.iobroker	2021-02-04 22:05:05.656	info	stopInstance system.adapter.socketio.0 send kill signal
      host.iobroker	2021-02-04 22:05:05.654	info	stopInstance system.adapter.socketio.0 (force=false, process=true)
      web.0	2021-02-04 22:05:04.425	info	(119152) https server listening on port 8082
      web.0	2021-02-04 22:05:04.423	debug	(119152) Activating web files from objectDB
      web.0	2021-02-04 22:05:04.422	debug	(119152) Activating extensions
      web.0	2021-02-04 22:05:04.394	debug	(119152) Activating states & socket info
      web.0	2021-02-04 22:05:04.273	info	(119152) starting. Version 3.3.0 in /opt/iobroker/node_modules/iobroker.web, node: v12.20.0, js-controller: 3.1.6
      web.0	2021-02-04 22:05:04.038	debug	(119152) Plugin sentry Initialize Plugin (enabled=true)
      web.0	2021-02-04 22:05:03.827	debug	(119152) statesDB connected
      web.0	2021-02-04 22:05:03.826	debug	(119152) States connected to redis: 127.0.0.1:9000
      web.0	2021-02-04 22:05:03.815	debug	(119152) States create System PubSub Client
      web.0	2021-02-04 22:05:03.811	debug	(119152) States create User PubSub Client
      web.0	2021-02-04 22:05:03.802	debug	(119152) Redis States: Use Redis connection: 127.0.0.1:9000
      web.0	2021-02-04 22:05:03.800	debug	(119152) objectDB connected
      web.0	2021-02-04 22:05:03.793	debug	(119152) Objects connected to redis: 127.0.0.1:9001
      web.0	2021-02-04 22:05:03.777	debug	(119152) Objects client initialize lua scripts
      web.0	2021-02-04 22:05:03.763	debug	(119152) Objects create User PubSub Client
      web.0	2021-02-04 22:05:03.762	debug	(119152) Objects create System PubSub Client
      web.0	2021-02-04 22:05:03.757	debug	(119152) Objects client ready ... initialize now
      web.0	2021-02-04 22:05:03.716	debug	(119152) Redis Objects: Use Redis connection: 127.0.0.1:9001
      host.iobroker	2021-02-04 22:05:02.712	info	instance system.adapter.web.0 started with pid 119152
      host.iobroker	2021-02-04 22:05:00.208	info	instance system.adapter.web.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
      web.0	2021-02-04 22:04:59.665	info	(115528) Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
      web.0	2021-02-04 22:04:59.664	info	(115528) terminating
      web.0	2021-02-04 22:04:59.663	info	(115528) terminated https server on port 8082
      web.0	2021-02-04 22:04:59.657	info	(115528) Got terminate signal TERMINATE_YOURSELF
      
      posted in Error/Bug
      L
      LePremier
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
    The ioBroker Community 2014-2023
    logo