Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst]Abfrage für Relais Status

    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

    [gelöst]Abfrage für Relais Status

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      meicker last edited by meicker

      Hallo zusammen,

      ich habe eine neue Herausforderung 🙂 und weiß nicht wie ich anfangen soll ...

      Wenn ich folgende URL aufrufe:
      http://192.168.x.x/get/xx-xx-xx-xx-xx-xx/all/ bekomme ich:

      <0;0;0;0;0;0;0;0;0;0;0;0;1;1;0> als Antwort

      Jede Zahl steht für ein bestimmtes Relais welches im Heizkreisverteiler einen Motor öffnet oder schließt. In diesem Beispiel sind 13 und 14 aktiv, das Wohnzimmer wird beheizt.

      Ich möchte jetzt gerne Datenpunkte erstellen mit dem Status 0 oder 1
      FBH_AZ1(01) 0
      ...
      FBH_WZ1(13) 1
      FBH_WZ2(14) 1
      FBH_EZ1(15) 0

      Wie müsste das aussehen ? Wie bekomme ich die einzelnen Kanäle ?

      Vielen Dank vorab 🙂

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @meicker last edited by paul53

        @meicker
        Etwa so (nicht getestet):

        const url = 'http://192.168.x.x/get/xx-xx-xx-xx-xx-xx/all/';
        const dpPath = '0_userdata.0.FBH.Z'; // 15 Datenpunkte Z1 ... Z15, Typ "boolean" 
        
        schedule('* * * * *', function() { // jede Minute
           request(url, function(error, response, result) {
              result = result.substring(1, result.indexOf('>')); // < und > entfernen
              let arr = result.split(';');
              for(let i = 0; i < arr.length; i++) {
                 setState(dpPath + (i + 1), !!parseInt(arr[i]), true);
              }
           });
        });
        

        EDIT: String mit parseInt() in Zahl gewandelt.

        1 Reply Last reply Reply Quote 0
        • M
          meicker last edited by

          Hi Paul,
          nach dem Edit klappte es 🙂 Ich musste nur die states noch vorher anlegen weil es nichts zum reinschreiben gab und habe dabei den Namen noch angepasst.

          createState('javascript.0.Controme.hkv.out-1', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-2', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-3', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-4', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-5', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-6', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-7', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-8', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-9', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-10', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-11', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-12', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-13', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-14', 0, {type: 'boolean', unit: ''});
          createState('javascript.0.Controme.hkv.out-15', 0, {type: 'boolean', unit: ''});
          
          const url = 'http://192.168.xx.xx/get/xx-xx-xx-01-1d-20/all/';
          const dpPath = 'javascript.0.Controme.hkv.out-'; // 15 Datenpunkte Z1 ... Z15, Typ "boolean" 
          
           
          
          schedule('* * * * *', function() { // jede Minute
          
             request(url, function(error, response, result) {
          
                result = result.substring(1, result.indexOf('>')); // < und > entfernen
          
                let arr = result.split(';');
          
                for(let i = 0; i < arr.length; i++) {
          
                   setState(dpPath + (i + 1), !!parseInt(arr[i]), true);
          
                }
          
             });
          
          });
          
          

          Jetzt versuche ich als nächstes mit der Abfrage von den States in drei Räumen die Klimaanlage zum heizen einzuschalten wenn ein state länger als 20 Minuten true ist. Bin mal gespannt ob ich das mit Blocky schaffe 🙂

          Dir schon mal - wie immer - ganz lieben Dank für die schnelle Hilfe !!!

          vg
          Marc

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

          Support us

          ioBroker
          Community Adapters
          Donate

          838
          Online

          31.9k
          Users

          80.1k
          Topics

          1.3m
          Posts

          2
          3
          169
          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