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. JavaScript
  5. Bezug/Einspeisung Vorzeichenwechsel

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    717

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    5.9k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

Bezug/Einspeisung Vorzeichenwechsel

Scheduled Pinned Locked Moved JavaScript
8 Posts 3 Posters 675 Views 1 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.
  • D Offline
    D Offline
    Diamand2k22
    wrote on last edited by
    #1

    Hallo zusammen,

    kann mir bitte jemand helfen.
    Ich greife am Smartmeter per Modbus Bezug/Einspeisung in Watt ab. Bei minus Vorzeichen wird eingespeist, bei plus Vorzeichen bezogen.

    Jetzt würde ich gerne nur die negativen Werte erfassen, sprich wenn der Datenpunkt einen negativen Wert liefert, dass Vorzeichen auf + zu wechseln und wenn positiver Wert > 0 soll einfach 0 Watt angezeigt werden.

    Es handelt sich um diesen Wert:

    const inputRegisters = {
        powerOut: 'modbus.0.holdingRegisters.200.40087_W'/*Total Real Power*/, 
    }
    

    Wie mache ich das am geschicktesten?

    Danke!

    VG

    paul53P 1 Reply Last reply
    0
    • D Diamand2k22

      Hallo zusammen,

      kann mir bitte jemand helfen.
      Ich greife am Smartmeter per Modbus Bezug/Einspeisung in Watt ab. Bei minus Vorzeichen wird eingespeist, bei plus Vorzeichen bezogen.

      Jetzt würde ich gerne nur die negativen Werte erfassen, sprich wenn der Datenpunkt einen negativen Wert liefert, dass Vorzeichen auf + zu wechseln und wenn positiver Wert > 0 soll einfach 0 Watt angezeigt werden.

      Es handelt sich um diesen Wert:

      const inputRegisters = {
          powerOut: 'modbus.0.holdingRegisters.200.40087_W'/*Total Real Power*/, 
      }
      

      Wie mache ich das am geschicktesten?

      Danke!

      VG

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

      @diamand2k22 sagte: Wie mache ich das am geschicktesten?

      Mit einem Alias-Datenpunkt mit Lesekonvertierung:

      val < 0 ? -val : 0
      

      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

      D 1 Reply Last reply
      0
      • paul53P paul53

        @diamand2k22 sagte: Wie mache ich das am geschicktesten?

        Mit einem Alias-Datenpunkt mit Lesekonvertierung:

        val < 0 ? -val : 0
        
        D Offline
        D Offline
        Diamand2k22
        wrote on last edited by
        #3

        @paul53

        danke Paul, geht das auch ohne Alias direkt im Skript in der Zeile?

        powerOut: 'modbus.0.holdingRegisters.200.40087_W'/*Total Real Power*/,
        

        Gruß

        paul53P 1 Reply Last reply
        0
        • D Diamand2k22

          @paul53

          danke Paul, geht das auch ohne Alias direkt im Skript in der Zeile?

          powerOut: 'modbus.0.holdingRegisters.200.40087_W'/*Total Real Power*/,
          

          Gruß

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

          @diamand2k22 sagte: geht das auch ohne Alias direkt im Skript

          on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
              setState('0_userdata.0.zaehler.einspeisung', dp.state.val < 0 ? -dp.state.val : 0, true);
          });
          

          Mit Alias spart man sich die Umsetzung per Skript.

          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

          D 1 Reply Last reply
          0
          • paul53P paul53

            @diamand2k22 sagte: geht das auch ohne Alias direkt im Skript

            on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                setState('0_userdata.0.zaehler.einspeisung', dp.state.val < 0 ? -dp.state.val : 0, true);
            });
            

            Mit Alias spart man sich die Umsetzung per Skript.

            D Offline
            D Offline
            Diamand2k22
            wrote on last edited by
            #5

            @paul53

            Hallo Paul,
            hab das mal so eingebaut, jetzt bekomme ich bei jedem Wert Wechsel eine Warnung.

            var powerOut;
            powerOut = 0;
            on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0);
            
            javascript.0
            2024-02-04 19:27:13.269	warn	State "0" not found
            
            javascript.0
            2024-02-04 19:27:13.271	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1819:20)
            
            javascript.0
            2024-02-04 19:27:13.271	warn	at Object.<anonymous> (script.js.common.Tibber_Test_2.Batterie_Regelung_0_1:35:5)
            
            javascript.0
            2024-02-04 19:27:13.272	warn	at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1269:38)
            
            javascript.0
            2024-02-04 19:27:13.272	warn	at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:641:29)
            
            javascript.0
            2024-02-04 19:27:13.272	warn	at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11200:62)
            
            javascript.0
            2024-02-04 19:27:13.272	warn	at processImmediate (node:internal/timers:476:21)
            
            HomoranH paul53P 2 Replies Last reply
            0
            • D Diamand2k22

              @paul53

              Hallo Paul,
              hab das mal so eingebaut, jetzt bekomme ich bei jedem Wert Wechsel eine Warnung.

              var powerOut;
              powerOut = 0;
              on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                  setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0);
              
              javascript.0
              2024-02-04 19:27:13.269	warn	State "0" not found
              
              javascript.0
              2024-02-04 19:27:13.271	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1819:20)
              
              javascript.0
              2024-02-04 19:27:13.271	warn	at Object.<anonymous> (script.js.common.Tibber_Test_2.Batterie_Regelung_0_1:35:5)
              
              javascript.0
              2024-02-04 19:27:13.272	warn	at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1269:38)
              
              javascript.0
              2024-02-04 19:27:13.272	warn	at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:641:29)
              
              javascript.0
              2024-02-04 19:27:13.272	warn	at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11200:62)
              
              javascript.0
              2024-02-04 19:27:13.272	warn	at processImmediate (node:internal/timers:476:21)
              
              HomoranH Do not disturb
              HomoranH Do not disturb
              Homoran
              Global Moderator Administrators
              wrote on last edited by Homoran
              #6

              @diamand2k22 sagte in Bezug/Einspeisung Vorzeichenwechsel:

              setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0);

              und powerOut ist bei dir 0

              @paul53 sagte in Bezug/Einspeisung Vorzeichenwechsel:

              setState('0_userdata.0.zaehler.einspeisung',

              kein Support per PN! - Fragen im Forum stellen -
              Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
              Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
              der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

              1 Reply Last reply
              0
              • D Diamand2k22

                @paul53

                Hallo Paul,
                hab das mal so eingebaut, jetzt bekomme ich bei jedem Wert Wechsel eine Warnung.

                var powerOut;
                powerOut = 0;
                on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                    setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0);
                
                javascript.0
                2024-02-04 19:27:13.269	warn	State "0" not found
                
                javascript.0
                2024-02-04 19:27:13.271	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1819:20)
                
                javascript.0
                2024-02-04 19:27:13.271	warn	at Object.<anonymous> (script.js.common.Tibber_Test_2.Batterie_Regelung_0_1:35:5)
                
                javascript.0
                2024-02-04 19:27:13.272	warn	at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1269:38)
                
                javascript.0
                2024-02-04 19:27:13.272	warn	at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:641:29)
                
                javascript.0
                2024-02-04 19:27:13.272	warn	at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11200:62)
                
                javascript.0
                2024-02-04 19:27:13.272	warn	at processImmediate (node:internal/timers:476:21)
                
                paul53P Offline
                paul53P Offline
                paul53
                wrote on last edited by paul53
                #7

                @diamand2k22
                powerOut muss die ID eines existierenden Ziel-Datenpunktes enthalten. Beispiel:

                const powerOut = '0_userdata.0.zaehler.einspeisung'; // Typ: Zahl, Einheit: W
                
                on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                    setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0, 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

                D 1 Reply Last reply
                0
                • paul53P paul53

                  @diamand2k22
                  powerOut muss die ID eines existierenden Ziel-Datenpunktes enthalten. Beispiel:

                  const powerOut = '0_userdata.0.zaehler.einspeisung'; // Typ: Zahl, Einheit: W
                  
                  on('modbus.0.holdingRegisters.200.40087_W', function(dp) {
                      setState(powerOut, dp.state.val < 0 ? -dp.state.val : 0, true);
                  });
                  
                  D Offline
                  D Offline
                  Diamand2k22
                  wrote on last edited by
                  #8

                  @paul53

                  Es hat jetzt funktioniert mit dem Datenpunkt!
                  Danke dir!

                  VG

                  1 Reply Last reply
                  0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  388

                  Online

                  32.7k

                  Users

                  82.6k

                  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