Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Benötige Hilfe bei der Script Erstellung

    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

    Benötige Hilfe bei der Script Erstellung

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

      Hallo Zusammen,

      da meine Programmier Kenntnisse noch in den Anfängen stecken brauche ich etwas Hilfe.

      Ich möchte meinen Wasserstand errechen. 😉

      Ich habe bekomme von einem NodeMCU einen Wert übergeben "sonoff.0.nodeMCU_10.SR04_Distance"

      Wie kann ich eine Variable mit dem errechneten Wert füllen ?

      Variable = 1000 * (1- ( 1,20,8 sonoff.0.nodeMCU_10.SR04_Distance ))

      ?????

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

        @2hot4you:

        Wie kann ich eine Variable mit dem errechneten Wert füllen ? `
        Meinst Du damit eine Skriptvariable oder einen Datenpunkt ? Mit Datenpunkt:

        const idSrc = "sonoff.0.nodeMCU_10.SR04_Distance";
        const idDst = "Wasserstand";
        
        // Datenpunkt erzeugen
        createState(idDst, 1000 * (1 - 0.96 * getState(idSrc).val), {type: 'number', unit: 'mm'}); 
        
        on(idSrc, function(dp) { // Triggern bei Wertänderung
           setState(idDst, 1000 * (1 - 0.96 * dp.state.val), true);
        });
        

        https://github.com/ioBroker/ioBroker.javascript/blob/master/doc/en/javascript.md

        1 Reply Last reply Reply Quote 0
        • 2
          2hot4you last edited by

          @paul53:

          @2hot4you:

          Wie kann ich eine Variable mit dem errechneten Wert füllen ? `
          Meinst Du damit eine Skriptvariable oder einen Datenpunkt ? Mit Datenpunkt:

          const idSrc = "sonoff.0.nodeMCU_10.SR04_Distance";
          const idDst = "Wasserstand";
          
          // Datenpunkt erzeugen
          createState(idDst, 1000 * (1 - 0.96 * getState(idSrc).val), {type: 'number', unit: 'mm'}); 
          
          on(idSrc, function(dp) { // Triggern bei Wertänderung
             setState(idDst, 1000 * (1 - 0.96 * dp.state.val), true);
          });
          

          https://github.com/ioBroker/ioBroker.javascript/blob/master/doc/en/javascript.md `

          Danke, klappt super !!! 😄 😄 jetzt muss es nur noch Regnen !

          4872_regen.png

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

          Support us

          ioBroker
          Community Adapters
          Donate

          791
          Online

          31.7k
          Users

          79.9k
          Topics

          1.3m
          Posts

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