Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. verschiedene Datenpunkte in eine Tabelle schreiben

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.8k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    2.2k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    16
    1
    3.3k

verschiedene Datenpunkte in eine Tabelle schreiben

Scheduled Pinned Locked Moved Skripten / Logik
blocklyjavascriptmonitoring
14 Posts 2 Posters 2.0k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Basti97B Offline
    Basti97B Offline
    Basti97
    Most Active
    wrote on last edited by Basti97
    #1

    Wie kann ich von verschiedenen Zustände die Datenpunkte in einen Datenpunkt (Zeichenkette) für eine Json Tabelle schreiben. Wär hat für mich ein kleines Beispiel damit ich die Aufteilung verstehe.
    Zum Beispiel
    Wohnzimmer: 25°C
    Schlafzimmer:12°C
    usw.
    Danke

    Update
    großen Dank an @paul53 für deine Hilfe. :blush:

    Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

    paul53P 1 Reply Last reply
    0
    • Basti97B Basti97

      Wie kann ich von verschiedenen Zustände die Datenpunkte in einen Datenpunkt (Zeichenkette) für eine Json Tabelle schreiben. Wär hat für mich ein kleines Beispiel damit ich die Aufteilung verstehe.
      Zum Beispiel
      Wohnzimmer: 25°C
      Schlafzimmer:12°C
      usw.
      Danke

      Update
      großen Dank an @paul53 für deine Hilfe. :blush:

      paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by
      #2

      @Basti97 sagte:

      eine Json Tabelle schreiben.
      Zum Beispiel
      Wohnzimmer: 25°C
      Schlafzimmer:12°C

      Vorschlag:

      const idTable = '...'; // ID JSON-Tabelle
      const idsTemp = ['...','...','...']; // Datenpunkt-IDs eintragen
      const rooms = ['Wohnen','Schlafen','Küche'];
      
      var table = [];
      for(let i = 0; i < rooms.length; i++) {
          table[i] = {};
          table[i].Raum = rooms[i];
          table[i].Temp = getState(idsTemp[i]).val;
      }
      setState(idTable, JSON.stringify(table), true);
      
      on(idsTemp, function(dp) {
          let idx = idsTemp.indexOf(dp.id);
          table[idx].Temp = dp.state.val;
          setState(idTable, JSON.stringify(table), true);
      });
      

      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
      Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

      Basti97B 1 Reply Last reply
      0
      • paul53P paul53

        @Basti97 sagte:

        eine Json Tabelle schreiben.
        Zum Beispiel
        Wohnzimmer: 25°C
        Schlafzimmer:12°C

        Vorschlag:

        const idTable = '...'; // ID JSON-Tabelle
        const idsTemp = ['...','...','...']; // Datenpunkt-IDs eintragen
        const rooms = ['Wohnen','Schlafen','Küche'];
        
        var table = [];
        for(let i = 0; i < rooms.length; i++) {
            table[i] = {};
            table[i].Raum = rooms[i];
            table[i].Temp = getState(idsTemp[i]).val;
        }
        setState(idTable, JSON.stringify(table), true);
        
        on(idsTemp, function(dp) {
            let idx = idsTemp.indexOf(dp.id);
            table[idx].Temp = dp.state.val;
            setState(idTable, JSON.stringify(table), true);
        });
        
        Basti97B Offline
        Basti97B Offline
        Basti97
        Most Active
        wrote on last edited by Basti97
        #3

        @paul53 Danke für deine Hilfe werde es probieren. Wie kann ich in das Script noch die Grad nach den Zahlen einfügen.

        Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

        paul53P 1 Reply Last reply
        0
        • Basti97B Basti97

          @paul53 Danke für deine Hilfe werde es probieren. Wie kann ich in das Script noch die Grad nach den Zahlen einfügen.

          paul53P Offline
          paul53P Offline
          paul53
          wrote on last edited by
          #4

          @Basti97 sagte:

          noch die Grad nach den Zahlen einfügen.

              table[idx].Temp = dp.state.val + ' °C';
          

          Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
          Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

          Basti97B 1 Reply Last reply
          0
          • paul53P paul53

            @Basti97 sagte:

            noch die Grad nach den Zahlen einfügen.

                table[idx].Temp = dp.state.val + ' °C';
            
            Basti97B Offline
            Basti97B Offline
            Basti97
            Most Active
            wrote on last edited by
            #5

            @paul53 Danke langsam verstehe ich das ganze Script. Hatte bis jetzt nur mi Blockly alles gemacht aber ich sehe mit Java kann man viel mehr machen. :)

            Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

            paul53P 1 Reply Last reply
            0
            • Basti97B Basti97

              @paul53 Danke langsam verstehe ich das ganze Script. Hatte bis jetzt nur mi Blockly alles gemacht aber ich sehe mit Java kann man viel mehr machen. :)

              paul53P Offline
              paul53P Offline
              paul53
              wrote on last edited by
              #6

              @Basti97 sagte:

              aber ich sehe mit Java kann man viel mehr machen.

              Blockly enthält nur eine Teilmenge von Javascript.

              Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
              Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

              Basti97B 1 Reply Last reply
              0
              • paul53P paul53

                @Basti97 sagte:

                aber ich sehe mit Java kann man viel mehr machen.

                Blockly enthält nur eine Teilmenge von Javascript.

                Basti97B Offline
                Basti97B Offline
                Basti97
                Most Active
                wrote on last edited by
                #7

                @paul53 Ja das merke ich jetzt auch mit Blockly hätte man so etwas nicht hinbekommen. Wie oft wird eigentlich der Datenpunkt aktualisiert? Kann man das auch noch einstellen.

                Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                paul53P 1 Reply Last reply
                0
                • Basti97B Basti97

                  @paul53 Ja das merke ich jetzt auch mit Blockly hätte man so etwas nicht hinbekommen. Wie oft wird eigentlich der Datenpunkt aktualisiert? Kann man das auch noch einstellen.

                  paul53P Offline
                  paul53P Offline
                  paul53
                  wrote on last edited by paul53
                  #8

                  @Basti97 sagte:

                  Wie oft wird eigentlich der Datenpunkt aktualisiert?

                  Bei jeder Änderung eines Temperaturwertes der im Array idsTemp angelegten Datenpunkte, also in Echtzeit.

                  Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
                  Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

                  Basti97B 2 Replies Last reply
                  0
                  • paul53P paul53

                    @Basti97 sagte:

                    Wie oft wird eigentlich der Datenpunkt aktualisiert?

                    Bei jeder Änderung eines Temperaturwertes der im Array idsTemp angelegten Datenpunkte, also in Echtzeit.

                    Basti97B Offline
                    Basti97B Offline
                    Basti97
                    Most Active
                    wrote on last edited by
                    #9

                    @paul53 Ok Der Datenpunkt wird an sich aktualisiert aber die Werte irgendwie bleiben stehen. Die werden erst bei einem Neustart des Adapters aktualisiert.

                    Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                    1 Reply Last reply
                    0
                    • paul53P paul53

                      @Basti97 sagte:

                      Wie oft wird eigentlich der Datenpunkt aktualisiert?

                      Bei jeder Änderung eines Temperaturwertes der im Array idsTemp angelegten Datenpunkte, also in Echtzeit.

                      Basti97B Offline
                      Basti97B Offline
                      Basti97
                      Most Active
                      wrote on last edited by
                      #10

                      @paul53
                      Hier ist mein Script ich verstehe nicht warum der Status nicht aktualisiert wird. :angry:
                      Ich hoffe ich habe es richtig eingefügt.


                      const idTable = 'javascript.0.virtuelle_Datenpunkte.Temperaturauswertung'; // ID JSON-Tabelle

                      //Temperatur
                      const idsTemp = [
                      'zigbee.0.00158d03035bf62e.temperature',
                      'zigbee.0.00158d03045bf62e.temperature',
                      'zigbee.0.00158d03065bf62e.temperature',
                      'zigbee.0.00158d03046bf62e.temperature',

                      ]; // Luftfeuchtigkeit

                      const idsLuftf = [
                      'zigbee.0.00158d03035bf62e.humidity',
                      'zigbee.0.00158d03045bf62e.humidity',
                      'zigbee.0.00158d03065bf62e.humidity',
                      'zigbee.0.00158d03046bf62e.humidity',

                      ];// Temperatur Status (true oder false)

                      const idsStatus = [
                      'zigbee.0.00158d03035bf62e.available',
                      'zigbee.0.00158d03045bf62e.available',
                      'zigbee.0.00158d03065bf62e.available',
                      'zigbee.0.00158d03046bf62e.available',

                      ]; // Datenpunkt-IDs von Adaptern

                      const rooms = [
                      'Wohnen','Schlafen','Küche',
                      'Bad','Kinderzimmer'
                      ];

                      var table = [];

                      for(let i = 0; i < rooms.length; i++) {

                      // Tabellen Spalten und Überschrift

                      table[i] = {};
                      
                      table[i].Raum = rooms[i];
                      
                      table[i].Temperatur = getState(idsTemp[i]).val + ' °C';
                      table[i].Luftfeuchtigkeit = getState(idsLuftf[i]).val;
                          table[i].Status = getState(idsStatus[i]).val;
                      

                      }

                      setState(idTable, JSON.stringify(table), true);

                      on(idsTemp, function(dp) {

                      let idx = idsTemp.indexOf(dp.id);
                      
                      table[idx].Temp = dp.state.val;
                      
                      setState(idTable, JSON.stringify(table), true);
                      
                      });
                      

                      Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                      paul53P 1 Reply Last reply
                      0
                      • Basti97B Basti97

                        @paul53
                        Hier ist mein Script ich verstehe nicht warum der Status nicht aktualisiert wird. :angry:
                        Ich hoffe ich habe es richtig eingefügt.


                        const idTable = 'javascript.0.virtuelle_Datenpunkte.Temperaturauswertung'; // ID JSON-Tabelle

                        //Temperatur
                        const idsTemp = [
                        'zigbee.0.00158d03035bf62e.temperature',
                        'zigbee.0.00158d03045bf62e.temperature',
                        'zigbee.0.00158d03065bf62e.temperature',
                        'zigbee.0.00158d03046bf62e.temperature',

                        ]; // Luftfeuchtigkeit

                        const idsLuftf = [
                        'zigbee.0.00158d03035bf62e.humidity',
                        'zigbee.0.00158d03045bf62e.humidity',
                        'zigbee.0.00158d03065bf62e.humidity',
                        'zigbee.0.00158d03046bf62e.humidity',

                        ];// Temperatur Status (true oder false)

                        const idsStatus = [
                        'zigbee.0.00158d03035bf62e.available',
                        'zigbee.0.00158d03045bf62e.available',
                        'zigbee.0.00158d03065bf62e.available',
                        'zigbee.0.00158d03046bf62e.available',

                        ]; // Datenpunkt-IDs von Adaptern

                        const rooms = [
                        'Wohnen','Schlafen','Küche',
                        'Bad','Kinderzimmer'
                        ];

                        var table = [];

                        for(let i = 0; i < rooms.length; i++) {

                        // Tabellen Spalten und Überschrift

                        table[i] = {};
                        
                        table[i].Raum = rooms[i];
                        
                        table[i].Temperatur = getState(idsTemp[i]).val + ' °C';
                        table[i].Luftfeuchtigkeit = getState(idsLuftf[i]).val;
                            table[i].Status = getState(idsStatus[i]).val;
                        

                        }

                        setState(idTable, JSON.stringify(table), true);

                        on(idsTemp, function(dp) {

                        let idx = idsTemp.indexOf(dp.id);
                        
                        table[idx].Temp = dp.state.val;
                        
                        setState(idTable, JSON.stringify(table), true);
                        
                        });
                        

                        paul53P Offline
                        paul53P Offline
                        paul53
                        wrote on last edited by paul53
                        #11

                        @Basti97
                        Du hast pro Messgröße 4 Datenpunkte, aber 5 Räume.
                        Für die Aktualisierung aller Messgrößen braucht es 3 Trigger.

                        on(idsTemp, function(dp) {
                           let idx = idsTemp.indexOf(dp.id);
                           table[idx].Temperatur = dp.state.val + ' °C';
                           setState(idTable, JSON.stringify(table), true);
                        });
                        on(idsLuftf, function(dp) {
                           let idx = idsLuftf.indexOf(dp.id);
                           table[idx].Luftfeuchtigkeit = dp.state.val + ' %';
                           setState(idTable, JSON.stringify(table), true);
                        });
                        on(idsStatus, function(dp) {
                           let idx = idsStatus.indexOf(dp.id);
                           table[idx].Status = dp.state.val;
                           setState(idTable, JSON.stringify(table), true);
                        });
                        

                        Bitte den gesamten Javascript-Code immer in Code tags </> posten.

                        Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
                        Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

                        Basti97B 1 Reply Last reply
                        0
                        • paul53P paul53

                          @Basti97
                          Du hast pro Messgröße 4 Datenpunkte, aber 5 Räume.
                          Für die Aktualisierung aller Messgrößen braucht es 3 Trigger.

                          on(idsTemp, function(dp) {
                             let idx = idsTemp.indexOf(dp.id);
                             table[idx].Temperatur = dp.state.val + ' °C';
                             setState(idTable, JSON.stringify(table), true);
                          });
                          on(idsLuftf, function(dp) {
                             let idx = idsLuftf.indexOf(dp.id);
                             table[idx].Luftfeuchtigkeit = dp.state.val + ' %';
                             setState(idTable, JSON.stringify(table), true);
                          });
                          on(idsStatus, function(dp) {
                             let idx = idsStatus.indexOf(dp.id);
                             table[idx].Status = dp.state.val;
                             setState(idTable, JSON.stringify(table), true);
                          });
                          

                          Bitte den gesamten Javascript-Code immer in Code tags </> posten.

                          Basti97B Offline
                          Basti97B Offline
                          Basti97
                          Most Active
                          wrote on last edited by Basti97
                          #12

                          Danke für deine Hilfe.

                          Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                          1 Reply Last reply
                          0
                          • Basti97B Offline
                            Basti97B Offline
                            Basti97
                            Most Active
                            wrote on last edited by
                            #13

                            Ich habe in meiner Tabelle als Status einzelne False und True (siehe Bild).
                            Wie kann ich nun Definieren das bei True die Text Farbe Grün ist und bei False rot.
                            Der Status kommt von den einzelnen Datenpunkte.
                            Zweite Frage kann man Anstatt true bzw False auch jeweils ein Symbol in Javascript einfügen.

                            Unbenannt.JPG

                            Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                            Basti97B 1 Reply Last reply
                            0
                            • Basti97B Basti97

                              Ich habe in meiner Tabelle als Status einzelne False und True (siehe Bild).
                              Wie kann ich nun Definieren das bei True die Text Farbe Grün ist und bei False rot.
                              Der Status kommt von den einzelnen Datenpunkte.
                              Zweite Frage kann man Anstatt true bzw False auch jeweils ein Symbol in Javascript einfügen.

                              Unbenannt.JPG

                              Basti97B Offline
                              Basti97B Offline
                              Basti97
                              Most Active
                              wrote on last edited by
                              #14

                              Hat jemand eine Lösung um die true und false "Datenpunkte" in grün und rot umzuwandeln. Was muss man im JavaScript dafür ändern.

                              Iobroker läuft als VM auf Proxmoxserver x folgende Hersteller im Einsatz Sonoff, Gosund, Siemens x Aofo über Tasmota x Zigbee x das Smarthome wächst und wächst

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              Support us

                              ioBroker
                              Community Adapters
                              Donate

                              425

                              Online

                              32.4k

                              Users

                              81.5k

                              Topics

                              1.3m

                              Posts
                              Community
                              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                              ioBroker Community 2014-2025
                              logo
                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Home
                              • Recent
                              • Tags
                              • Unread 0
                              • Categories
                              • Unreplied
                              • Popular
                              • GitHub
                              • Docu
                              • Hilfe