Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Wo kommt der String her

    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

    Wo kommt der String her

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

      Ich versuche mich gerade daran meinen Stromverbrauch aus diversen Quellen geordnet in kWh zu bringen.
      Sinngemäß, bzw. das was ich in dem Blockly erreichen will:
      Ließ den Zählerstand in Wh aus, vergleiche ihn mit dem alten Wert, rechne die Erhöhung aus und addiere sie zum Zähler. Klappt alles, sicherlich nicht elegant gelöst, aber Java gibt mir folgenden Fehler aus:

      warn: javascript.0 You are assigning a string to the state "javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable" which expects a number. Please fix your code to use a number or change the state type to string. This warning might become an error in future versions.
      

      Blockly Export


      <xml xmlns="http://www.w3.org/1999/xhtml">
      <block type="on_ext" id="A]8VM$ovm+gy:;fOq%9" x="12" y="-51"> <mutation items="1"></mutation> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <value name="OID0"> <shadow type="field_oid" id="_L8Q^7L1WFQkuJebXKx}"> <field name="oid">fritzdect.0.DECT200_087610114581.energy</field> </shadow> </value> <statement name="STATEMENT"> <block type="controls_if" id="io$S+3:RCT5V*/os3oKT"> <mutation elseif="1"></mutation> <value name="IF0"> <block type="logic_compare" id="H?,NFX10V@gR0NNWi-[8"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="K!q003MPHp|)(pt8U@3c"> <field name="ATTR">val</field> <field name="OID">fritzdect.0.DECT200_087610114581.energy</field> </block> </value> <value name="B"> <block type="get_value" id="q;1LV~zsb:xZrhB5|i5$"> <field name="ATTR">val</field> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable</field> </block> </value> </block> </value> <statement name="DO0"> <block type="update" id="Gj=ViOWu*S=~|s(uSmk{"> <mutation delay_input="false"></mutation> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.DesktopWh</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="4EWP$.~r]dz$Zq)wP_*u"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="L(YySAa=x#p9]Zy$KJfq"> <field name="NUM">1</field> </shadow> <block type="get_value" id="zBeX%bBc^.HA8ZS~DLJ5"> <field name="ATTR">val</field> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.DesktopWh</field> </block> </value> <value name="B"> <shadow type="math_number" id="toF|[j$MR|/LY5cL$Xt,"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id=",@^X)xgi^i{9BaawM|O">
      <field name="OP">MINUS</field>
      <value name="A">
      <shadow type="math_number" id="H$a2]QigtUvI6hs}c6Co">
      <field name="NUM">1</field>
      </shadow>
      <block type="get_value" id="NmcfYwqIA@_87t-g3=4J">
      <field name="ATTR">val</field>
      <field name="OID">fritzdect.0.DECT200_087610114581.energy</field>
      </block>
      </value>
      <value name="B">
      <shadow type="math_number" id="P]+;TKxdvsYpq;}HIUR$">
      <field name="NUM">1</field>
      </shadow>
      <block type="get_value" id="Ib|m%qw(vt[2NFnnr/S"> <field name="ATTR">val</field> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable</field> </block> </value> </block> </value> </block> </value> <next> <block type="update" id="A1!]80mB7+|/{Jb@ON8N"> <mutation delay_input="false"></mutation> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="get_value" id="H~$H3:;VK7BIdvJ1b*i]"> <field name="ATTR">val</field> <field name="OID">fritzdect.0.DECT200_087610114581.energy</field> </block> </value> </block> </next> </block> </statement> <value name="IF1"> <block type="logic_compare" id="60Me2gh84YGDJ0)nI9P3"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="utEmQIL89b2Z-tQOmnX,"> <field name="ATTR">val</field> <field name="OID">fritzdect.0.DECT200_087610114581.energy</field> </block> </value> <value name="B"> <block type="get_value" id="}BbI6#5hB_zwQzzD8hGX"> <field name="ATTR">val</field> <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable</field> </block> </value> </block> </value> <statement name="DO1"> <block type="update" id="jd,;YR0hOIp(4L=:*N3">
      <mutation delay_input="false"></mutation>
      <field name="OID">javascript.0.Own.Berechnungsvariablen.Verbrauch.Elektro.Desktopvariable</field>
      <field name="WITH_DELAY">FALSE</field>
      <value name="VALUE">
      <block type="get_value" id="PpTi}KpAp#fi}89Vc=ni">
      <field name="ATTR">val</field>
      <field name="OID">fritzdect.0.DECT200_087610114581.energy</field>
      </block>
      </value>
      </block>
      </statement>
      </block>
      </statement>
      </block>
      </xml>

      Und Bild in schlechter Auflösung...
      536143bc-d26c-4e86-a920-60acbbbbd6cb-image.png
      Nach meinem Verständnis ist hier nichts mehr als String.

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

        @bommel_030:Wo kommt der String her
        Aus einem der Datenpunkte, wahrscheinlich "Switch total energy".

        Test es mal außerhalb des Triggers bei Skriptstart:

        debug output  Typ von  Wert vom Objekt Switch total energy
        
        B 1 Reply Last reply Reply Quote 0
        • B
          bommel_030 @paul53 last edited by

          @paul53 said in Wo kommt der String her:

          debug output Typ von Wert vom Objekt Switch total energy

          javascript.0 script.js.Eigene.Verbruachstest: string

          Danke für den Tip, obwohl ich es nicht verstehe... Der Datenpunkt ist als Zahl definiert... D.h. ich setze einfach ein "konvertiere in Zahl davor"...


          {
          "from": "system.adapter.fritzdect.0",
          "ts": 1542029430318,
          "user": "system.user.admin",
          "common": {
          "name": "Switch total energy",
          "type": "number",
          "unit": "Wh",
          "role": "value.power.consumption",
          "desc": "Switch total energy",
          "min": 0,
          "read": true,
          "write": false,
          "custom": {
          "sql.0": {
          "enabled": true,
          "changesOnly": true,
          "debounce": "1000",
          "retention": 0,
          "changesRelogInterval": "",
          "changesMinDelta": 0,
          "storageType": "",
          "aliasId": ""
          },
          "statistics.0": {
          "enabled": true,
          "logName": "Switch total energy",
          "count": false,
          "sumCount": false,
          "timeCount": false,
          "fiveMin": false,
          "groupFactor": 0.001,
          "impUnit": "",
          "impUnitPerImpulse": "",
          "sumIgnoreMinus": true,
          "sumDelta": true,
          "avg": true,
          "minmax": true,
          "sumGroup": "energy"
          }
          }
          },
          "native": {},
          "acl": {
          "object": 1636,
          "owner": "system.user.admin",
          "ownerGroup": "system.group.administrator",
          "state": 1636
          },
          "_id": "fritzdect.0.DECT200_087610114581.energy",
          "type": "state"
          }

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

          Support us

          ioBroker
          Community Adapters
          Donate

          492
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

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