Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. [gelöst] common states in eigenem DP ändern

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] common states in eigenem DP ändern

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

      Tag,
      ich erstelle mir einen eigenen DP nach folgendem Prinzip:
      Screenshot 2023-01-31 105434.png

      Funktion:

      createState('0_userdata.0.Diashow.Funktionen.' + id, JSON.parse(common)); 
      

      Der DP "state"s ist ein eigener StringDP.mit folgendem Wert:

       {
            "123": "123",
            "456": "456",
            "789": "789"
          }
      

      Der erstellte DP sieht folgend aus:

      {
        "common": {
          "type": "string",
          "read": true,
          "write": true,
          "role": "text",
          "states": {
            "123": "123",
            "456": "456",
            "789": "789"
          },
          "name": "Mountpointliste"
        },
        "native": {},
        "type": "state",
        "from": "system.adapter.javascript.0",
        "user": "system.user.admin",
        "ts": 1675157146443,
        "_id": "0_userdata.0.Diashow.Funktionen.Mountpoints",
        "acl": {
          "object": 1636,
          "state": 1636,
          "owner": "system.user.admin",
          "ownerGroup": "system.group.administrator"
        }
      }
      

      Der DP "states" ändert sich hin und wieder.:

      Wie kann ich den eigenen DP mit geänderten states schreiben?

      liv-in-sky 1 Reply Last reply Reply Quote 0
      • L
        Lucky_ESA Developer Most Active last edited by

        Versuche es mal so.

        <xml xmlns="https://developers.google.com/blockly/xml">
          <variables>
            <variable id="V$m2bDbl3c1P-8EbWKof">obj</variable>
            <variable id="(r(Ys0=uP1tJ?*fV:(V|">states</variable>
            <variable id="q+I`TzaRF]T=.o@c.f$w">new_states</variable>
          </variables>
          <block type="procedures_defcustomreturn" id="y.v=]UQ;0.MJpnkVJY(`" x="13" y="13">
            <mutation statements="false"></mutation>
            <field name="NAME">read_obj</field>
            <field name="SCRIPT">cmV0dXJuIGF3YWl0IHRoaXMuZ2V0T2JqZWN0QXN5bmMoIjBfdXNlcmRhdGEuMC5leGFtcGxlX3N0YXRlIik7</field>
            <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
          </block>
          <block type="procedures_defcustomnoreturn" id="z_?-Z~-#sh8ExH;C~+L%" x="13" y="63">
            <mutation statements="false">
              <arg name="obj" varid="V$m2bDbl3c1P-8EbWKof"></arg>
              <arg name="states" varid="(r(Ys0=uP1tJ?*fV:(V|"></arg>
            </mutation>
            <field name="NAME">write_obj</field>
            <field name="SCRIPT">ZGVsZXRlIG9iai5jb21tb24uc3RhdGVzOw0Kb2JqLmNvbW1vblsic3RhdGVzIl0gPSBzdGF0ZXM7DQphd2FpdCB0aGlzLnNldE9iamVjdEFzeW5jKCIwX3VzZXJkYXRhLjAuZXhhbXBsZV9zdGF0ZSIsIG9iaik7</field>
            <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
          </block>
          <block type="variables_set" id="j|:r/T9zn!cl#3v(Pas)" x="13" y="113">
            <field name="VAR" id="q+I`TzaRF]T=.o@c.f$w">new_states</field>
            <value name="VALUE">
              <block type="text" id="/iB*Y?MqphAd($qGwe5d">
                <field name="TEXT">{"hallohallo":"hallo","test":"test"}</field>
              </block>
            </value>
            <next>
              <block type="debug" id="0BEZEI/Pd^u)^J0g%-hX">
                <field name="Severity">log</field>
                <value name="TEXT">
                  <shadow type="text" id="YI`(jJ%r.},}%cC=ac?0">
                    <field name="TEXT">test</field>
                  </shadow>
                  <block type="procedures_callcustomreturn" id="#B@Z1mu~Q3jaY}*PnQ!-">
                    <mutation name="read_obj"></mutation>
                  </block>
                </value>
                <next>
                  <block type="procedures_callcustomnoreturn" id="A#V*e#lXe`@zG-9Xb%KD">
                    <mutation name="write_obj">
                      <arg name="obj"></arg>
                      <arg name="states"></arg>
                    </mutation>
                    <value name="ARG0">
                      <block type="procedures_callcustomreturn" id="|u+IFlY@6f|-}vP~Ok~5">
                        <mutation name="read_obj"></mutation>
                      </block>
                    </value>
                    <value name="ARG1">
                      <block type="convert_json2object" id="QwAtbJ5~oCq:D*9oyr1:">
                        <value name="VALUE">
                          <block type="variables_get" id="=(+Z}mT*AA6m`NcXzVaU">
                            <field name="VAR" id="q+I`TzaRF]T=.o@c.f$w">new_states</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="debug" id="S}lFnWJd{t-j`ls#fD#R">
                        <field name="Severity">log</field>
                        <value name="TEXT">
                          <shadow type="text">
                            <field name="TEXT">test</field>
                          </shadow>
                          <block type="procedures_callcustomreturn" id="rAn2N}h.g3p6T*A}MtN2">
                            <mutation name="read_obj"></mutation>
                          </block>
                        </value>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </xml>
        

        Gruß//Lucky

        DJMarc75 1 Reply Last reply Reply Quote 1
        • liv-in-sky
          liv-in-sky @DJMarc75 last edited by

          @djmarc75

          müßte so gehen:

          z.b.

          var obj = getObject("xx.xx.xx.xx");
          obj.common.states= {"123":"123","456":"456" ...}
          setObject("xx.xx.xx.xx", obj);
          

          xx.xx.xx.xx ist datenpunkt

          1 Reply Last reply Reply Quote 0
          • DJMarc75
            DJMarc75 @Lucky_ESA last edited by

            @lucky_esa sagte in common states in eigenem DP ändern:

            Versuche es mal so.

            Besten Dank, so hab ich es umgesetzt 👍

            Danke auch an @liv-in-sky

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

            Support us

            ioBroker
            Community Adapters
            Donate

            844
            Online

            32.0k
            Users

            80.5k
            Topics

            1.3m
            Posts

            3
            4
            115
            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