- ioBroker Community Home
- Deutsch
- Skripten / Logik
- Blockly
- [gelöst] Aufzählung gleicher Werte aus Datenpunkt
NEWS
[gelöst] Aufzählung gleicher Werte aus Datenpunkt
-
-
wenn mir jetzt noch jemand von Euch "zeigen" kann wie ich die Titel (kommen erstmal in einem StringDP an) in ein (wachsendes) Array schreibe dann wäre ich so ziemlich happy :dancer:
Lehrling seit 1975 !!!
Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge -
wenn mir jetzt noch jemand von Euch "zeigen" kann wie ich die Titel (kommen erstmal in einem StringDP an) in ein (wachsendes) Array schreibe dann wäre ich so ziemlich happy :dancer:
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
wenn mir jetzt noch jemand von Euch "zeigen" kann wie ich die Titel (kommen erstmal in einem StringDP an) in ein (wachsendes) Array schreibe dann wäre ich so ziemlich happy :dancer:
Na dass ich Dir nochmal puzzlen beibringen muss, überrascht mich aber. :grin:

Wenn du es gleich als Array machst - hast Du auch mit Kommas kein Problem.
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.
-
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
wenn mir jetzt noch jemand von Euch "zeigen" kann wie ich die Titel (kommen erstmal in einem StringDP an) in ein (wachsendes) Array schreibe dann wäre ich so ziemlich happy :dancer:
Na dass ich Dir nochmal puzzlen beibringen muss, überrascht mich aber. :grin:

Wenn du es gleich als Array machst - hast Du auch mit Kommas kein Problem.
-
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym bin grad am Testen :+1:
So und damit die Hässlichkeit des Puzzlen ganz zu Tage tritt hier noch die Ergänzung, wie man das ganze dann Auswerten kann. ;)

<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Q-{K{g^u8=SJ~bbJx1L2">neu</variable> <variable id="?+jUzr1AE!BT%ndErB?h">String</variable> <variable id="r2|O7xSSn}R]WP0Guw3#">Array</variable> <variable id="$-_m{u5(Dz83eo?3;{%[">Objekt</variable> <variable id="J?Di1B/ibZyz:%[nd_$1">Suche</variable> </variables> <block type="variables_set" id="2`xXRHf8dv/I7RRVQ9uP" x="-462" y="-187"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> <value name="VALUE"> <block type="text" id=":}kd79(jelVZP+`h)Q-G"> <field name="TEXT">S.O.S</field> </block> </value> <next> <block type="variables_set" id="//8bilRq!Q*Oo;YNFP0i"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> <value name="VALUE"> <block type="text" id="b;/knyEwB)g{AZ|(e4U;"> <field name="TEXT">a,b,b,a,c,d,a,b,c</field> </block> </value> <next> <block type="variables_set" id="jgNS,;m/}/6kEs:32$23"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> <value name="VALUE"> <block type="lists_split" id="4VgevC}Aug,7,$``$e2~"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="3OkVXfnD1V1{15oC}j0#"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> </block> </value> <value name="DELIM"> <shadow type="text" id="`^2^nlc|*0tZnVb/]MU0"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="lists_setIndex" id="^1a;jzhbYsZ3.(=%^3:o"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="Yc!NOY.mpz;*MQ4a.3cc"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <value name="TO"> <block type="variables_get" id="JN(3pS60Y)^Y=(.]j~4B"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> </block> </value> <next> <block type="debug" id="7Qj!rB9T*1u^?q*%grBj"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="X9Y@-Dl7gm/@@A1LA|rJ"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="(swR*aLu~G@PD}zgOnL+"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <next> <block type="variables_set" id="a75e#*Xc#m)nG`veslBd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="|P_BHOAk`P/_AfD`5I`Y"> <value name="EXPRESSION"> <shadow type="text" id=":Vas?]P#E6aU7]6b,~_q"> <field name="TEXT">$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="5t:`o,RyQ=/bO+x?(-kv"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> </block> </value> <next> <block type="debug" id="WJhIun5xunahKl@GICu}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="YQ7^n5qnxbu(/f6Uffd^"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="-,0VHv#EdBGI4Upg~~ZA"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="Hg9/:p^,/%Kf2tC;y-]W"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> <value name="VALUE"> <block type="text" id="m;o(c)D=jz_JWVJv@X8E"> <field name="TEXT">a</field> </block> </value> <next> <block type="debug" id="O9J+UurMn7PA^TKo,BHw"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p.m1Jo/[,,D8:FMicn0U"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="q,:sJ5DPG[Unp42nmwf4"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id=":+E?yRv@7u8_xlN?;!|Y"> <field name="TEXT">Lied </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="iiTxfl.#MUB;EfaFO/q;"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="JcTfv$r?$F7=m2$QWNgG"> <field name="TEXT"> wurde </field> </block> </value> <value name="ADD3"> <block type="convert_jsonata" id="^cI{f1Cedv)iL5xFEsa@"> <value name="EXPRESSION"> <shadow type="text" id="XolzYVS:6f[}CY%{=CtN"> <field name="TEXT">*</field> </shadow> <block type="text_join" id="jZb*`=0yOdkQuGQPKyJ="> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="kZDkEfIR!ngV#w|Mx=/J"> <field name="TEXT">$.'</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="e;xWF[am$/jUvuQxCb:["> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="=l{vI?{uIxzWwOzn0Rll"> <field name="TEXT">'</field> </block> </value> </block> </value> <value name="TARGET"> <block type="variables_get" id="KtR^h,d+F=uC4,3.tEZz"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="z8nN;k_ep!x_9cd^+BB!"> <field name="TEXT"> mal gespielt.</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>Für Leute, die solche Dinge mit einem anderen Logikmaschine umsetzen wollen:
[ { "id": "1b8a9b7ff23e2b72", "type": "comment", "z": "29617fbe487e9c69", "name": "Elemente in einem Array zählen und als Objekt ausgeben", "info": "", "x": 270, "y": 1720, "wires": [] }, { "id": "db03a7ae6baec159", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\"]", "payloadType": "json", "x": 180, "y": 1800, "wires": [ [ "eee0fd1bbc1c7591" ] ] }, { "id": "eee0fd1bbc1c7591", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 1800, "wires": [ [ "db6b52e1b383fa3c", "f9376b9bca6163b6" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "db6b52e1b383fa3c", "type": "debug", "z": "29617fbe487e9c69", "name": "Array-Analyse", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 620, "y": 1800, "wires": [] }, { "id": "f9376b9bca6163b6", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "search", "pt": "msg", "to": "Schöne Maid, hast Du heut für mich Zeit", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 1860, "wires": [ [ "cda6bb4b435f80bb" ] ] }, { "id": "cda6bb4b435f80bb", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 870, "y": 1860, "wires": [ [ "251eea7ce5c8efe0" ] ] }, { "id": "251eea7ce5c8efe0", "type": "debug", "z": "29617fbe487e9c69", "name": "Suche Vorkommen von search ", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1130, "y": 1860, "wires": [] }, { "id": "4a0fb478973bae57", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern und Ausgabe von search in einem", "props": [ { "p": "payload" }, { "p": "search", "v": "Dancing Queen", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\",\"Dancing Queen\",\"Dancing Queen\"]", "payloadType": "json", "x": 290, "y": 1960, "wires": [ [ "48f9fec07b2dac6a" ] ] }, { "id": "48f9fec07b2dac6a", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 1960, "wires": [ [ "969a1f62b4b01026" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "969a1f62b4b01026", "type": "debug", "z": "29617fbe487e9c69", "name": "Vorkommen von search in Array", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 850, "y": 1960, "wires": [] } ]Auch JS Programmierer können JSONATA nutzen, da das im Adapter enthalten ist:
var titel = [ "Schöne Maid, hast Du heut für mich Zeit", "Jump", "Jump", "Blauer Enzian", "Dancing Queen", "Yellow Submarine", "Blauer Enzian", "Jump", "Dancing Queen", "S.O.S", "Schöne Maid, hast Du heut für mich Zeit" ]; var analyse = jsonataExpression(titel,'$distinct($).{"titel": $, "count" : $map($$,function($v){$[$=$v]}) ~> $count()}'); console.log(analyse); var suche = "Dancing Queen"; var ergebnis = jsonataExpression(analyse,'$[titel="'+ suche +'"].count'); console.log("Der Titel "+ suche + " ergab "+ ergebnis + " Treffer.");
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.
-
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym bin grad am Testen :+1:
So und damit die Hässlichkeit des Puzzlen ganz zu Tage tritt hier noch die Ergänzung, wie man das ganze dann Auswerten kann. ;)

<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Q-{K{g^u8=SJ~bbJx1L2">neu</variable> <variable id="?+jUzr1AE!BT%ndErB?h">String</variable> <variable id="r2|O7xSSn}R]WP0Guw3#">Array</variable> <variable id="$-_m{u5(Dz83eo?3;{%[">Objekt</variable> <variable id="J?Di1B/ibZyz:%[nd_$1">Suche</variable> </variables> <block type="variables_set" id="2`xXRHf8dv/I7RRVQ9uP" x="-462" y="-187"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> <value name="VALUE"> <block type="text" id=":}kd79(jelVZP+`h)Q-G"> <field name="TEXT">S.O.S</field> </block> </value> <next> <block type="variables_set" id="//8bilRq!Q*Oo;YNFP0i"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> <value name="VALUE"> <block type="text" id="b;/knyEwB)g{AZ|(e4U;"> <field name="TEXT">a,b,b,a,c,d,a,b,c</field> </block> </value> <next> <block type="variables_set" id="jgNS,;m/}/6kEs:32$23"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> <value name="VALUE"> <block type="lists_split" id="4VgevC}Aug,7,$``$e2~"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="3OkVXfnD1V1{15oC}j0#"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> </block> </value> <value name="DELIM"> <shadow type="text" id="`^2^nlc|*0tZnVb/]MU0"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="lists_setIndex" id="^1a;jzhbYsZ3.(=%^3:o"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="Yc!NOY.mpz;*MQ4a.3cc"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <value name="TO"> <block type="variables_get" id="JN(3pS60Y)^Y=(.]j~4B"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> </block> </value> <next> <block type="debug" id="7Qj!rB9T*1u^?q*%grBj"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="X9Y@-Dl7gm/@@A1LA|rJ"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="(swR*aLu~G@PD}zgOnL+"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <next> <block type="variables_set" id="a75e#*Xc#m)nG`veslBd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="|P_BHOAk`P/_AfD`5I`Y"> <value name="EXPRESSION"> <shadow type="text" id=":Vas?]P#E6aU7]6b,~_q"> <field name="TEXT">$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="5t:`o,RyQ=/bO+x?(-kv"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> </block> </value> <next> <block type="debug" id="WJhIun5xunahKl@GICu}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="YQ7^n5qnxbu(/f6Uffd^"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="-,0VHv#EdBGI4Upg~~ZA"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="Hg9/:p^,/%Kf2tC;y-]W"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> <value name="VALUE"> <block type="text" id="m;o(c)D=jz_JWVJv@X8E"> <field name="TEXT">a</field> </block> </value> <next> <block type="debug" id="O9J+UurMn7PA^TKo,BHw"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p.m1Jo/[,,D8:FMicn0U"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="q,:sJ5DPG[Unp42nmwf4"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id=":+E?yRv@7u8_xlN?;!|Y"> <field name="TEXT">Lied </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="iiTxfl.#MUB;EfaFO/q;"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="JcTfv$r?$F7=m2$QWNgG"> <field name="TEXT"> wurde </field> </block> </value> <value name="ADD3"> <block type="convert_jsonata" id="^cI{f1Cedv)iL5xFEsa@"> <value name="EXPRESSION"> <shadow type="text" id="XolzYVS:6f[}CY%{=CtN"> <field name="TEXT">*</field> </shadow> <block type="text_join" id="jZb*`=0yOdkQuGQPKyJ="> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="kZDkEfIR!ngV#w|Mx=/J"> <field name="TEXT">$.'</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="e;xWF[am$/jUvuQxCb:["> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="=l{vI?{uIxzWwOzn0Rll"> <field name="TEXT">'</field> </block> </value> </block> </value> <value name="TARGET"> <block type="variables_get" id="KtR^h,d+F=uC4,3.tEZz"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="z8nN;k_ep!x_9cd^+BB!"> <field name="TEXT"> mal gespielt.</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>Für Leute, die solche Dinge mit einem anderen Logikmaschine umsetzen wollen:
[ { "id": "1b8a9b7ff23e2b72", "type": "comment", "z": "29617fbe487e9c69", "name": "Elemente in einem Array zählen und als Objekt ausgeben", "info": "", "x": 270, "y": 1720, "wires": [] }, { "id": "db03a7ae6baec159", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\"]", "payloadType": "json", "x": 180, "y": 1800, "wires": [ [ "eee0fd1bbc1c7591" ] ] }, { "id": "eee0fd1bbc1c7591", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 1800, "wires": [ [ "db6b52e1b383fa3c", "f9376b9bca6163b6" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "db6b52e1b383fa3c", "type": "debug", "z": "29617fbe487e9c69", "name": "Array-Analyse", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 620, "y": 1800, "wires": [] }, { "id": "f9376b9bca6163b6", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "search", "pt": "msg", "to": "Schöne Maid, hast Du heut für mich Zeit", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 1860, "wires": [ [ "cda6bb4b435f80bb" ] ] }, { "id": "cda6bb4b435f80bb", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 870, "y": 1860, "wires": [ [ "251eea7ce5c8efe0" ] ] }, { "id": "251eea7ce5c8efe0", "type": "debug", "z": "29617fbe487e9c69", "name": "Suche Vorkommen von search ", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1130, "y": 1860, "wires": [] }, { "id": "4a0fb478973bae57", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern und Ausgabe von search in einem", "props": [ { "p": "payload" }, { "p": "search", "v": "Dancing Queen", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\",\"Dancing Queen\",\"Dancing Queen\"]", "payloadType": "json", "x": 290, "y": 1960, "wires": [ [ "48f9fec07b2dac6a" ] ] }, { "id": "48f9fec07b2dac6a", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 1960, "wires": [ [ "969a1f62b4b01026" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "969a1f62b4b01026", "type": "debug", "z": "29617fbe487e9c69", "name": "Vorkommen von search in Array", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 850, "y": 1960, "wires": [] } ]Auch JS Programmierer können JSONATA nutzen, da das im Adapter enthalten ist:
var titel = [ "Schöne Maid, hast Du heut für mich Zeit", "Jump", "Jump", "Blauer Enzian", "Dancing Queen", "Yellow Submarine", "Blauer Enzian", "Jump", "Dancing Queen", "S.O.S", "Schöne Maid, hast Du heut für mich Zeit" ]; var analyse = jsonataExpression(titel,'$distinct($).{"titel": $, "count" : $map($$,function($v){$[$=$v]}) ~> $count()}'); console.log(analyse); var suche = "Dancing Queen"; var ergebnis = jsonataExpression(analyse,'$[titel="'+ suche +'"].count'); console.log("Der Titel "+ suche + " ergab "+ ergebnis + " Treffer.");
@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
damit die Hässlichkeit des Puzzlen ganz zu Tage tritt
:grin:
Ich lass das jetzt mal ne Weile laufen und mit Musiktitel befüllen um etwaige Sonderzeichenprobleme gänzlich auszuschliessen :nerd_face:Lehrling seit 1975 !!!
Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge -
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym bin grad am Testen :+1:
So und damit die Hässlichkeit des Puzzlen ganz zu Tage tritt hier noch die Ergänzung, wie man das ganze dann Auswerten kann. ;)

<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Q-{K{g^u8=SJ~bbJx1L2">neu</variable> <variable id="?+jUzr1AE!BT%ndErB?h">String</variable> <variable id="r2|O7xSSn}R]WP0Guw3#">Array</variable> <variable id="$-_m{u5(Dz83eo?3;{%[">Objekt</variable> <variable id="J?Di1B/ibZyz:%[nd_$1">Suche</variable> </variables> <block type="variables_set" id="2`xXRHf8dv/I7RRVQ9uP" x="-462" y="-187"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> <value name="VALUE"> <block type="text" id=":}kd79(jelVZP+`h)Q-G"> <field name="TEXT">S.O.S</field> </block> </value> <next> <block type="variables_set" id="//8bilRq!Q*Oo;YNFP0i"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> <value name="VALUE"> <block type="text" id="b;/knyEwB)g{AZ|(e4U;"> <field name="TEXT">a,b,b,a,c,d,a,b,c</field> </block> </value> <next> <block type="variables_set" id="jgNS,;m/}/6kEs:32$23"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> <value name="VALUE"> <block type="lists_split" id="4VgevC}Aug,7,$``$e2~"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="3OkVXfnD1V1{15oC}j0#"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> </block> </value> <value name="DELIM"> <shadow type="text" id="`^2^nlc|*0tZnVb/]MU0"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="lists_setIndex" id="^1a;jzhbYsZ3.(=%^3:o"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="Yc!NOY.mpz;*MQ4a.3cc"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <value name="TO"> <block type="variables_get" id="JN(3pS60Y)^Y=(.]j~4B"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> </block> </value> <next> <block type="debug" id="7Qj!rB9T*1u^?q*%grBj"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="X9Y@-Dl7gm/@@A1LA|rJ"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="(swR*aLu~G@PD}zgOnL+"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <next> <block type="variables_set" id="a75e#*Xc#m)nG`veslBd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="|P_BHOAk`P/_AfD`5I`Y"> <value name="EXPRESSION"> <shadow type="text" id=":Vas?]P#E6aU7]6b,~_q"> <field name="TEXT">$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="5t:`o,RyQ=/bO+x?(-kv"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> </block> </value> <next> <block type="debug" id="WJhIun5xunahKl@GICu}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="YQ7^n5qnxbu(/f6Uffd^"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="-,0VHv#EdBGI4Upg~~ZA"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="Hg9/:p^,/%Kf2tC;y-]W"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> <value name="VALUE"> <block type="text" id="m;o(c)D=jz_JWVJv@X8E"> <field name="TEXT">a</field> </block> </value> <next> <block type="debug" id="O9J+UurMn7PA^TKo,BHw"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p.m1Jo/[,,D8:FMicn0U"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="q,:sJ5DPG[Unp42nmwf4"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id=":+E?yRv@7u8_xlN?;!|Y"> <field name="TEXT">Lied </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="iiTxfl.#MUB;EfaFO/q;"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="JcTfv$r?$F7=m2$QWNgG"> <field name="TEXT"> wurde </field> </block> </value> <value name="ADD3"> <block type="convert_jsonata" id="^cI{f1Cedv)iL5xFEsa@"> <value name="EXPRESSION"> <shadow type="text" id="XolzYVS:6f[}CY%{=CtN"> <field name="TEXT">*</field> </shadow> <block type="text_join" id="jZb*`=0yOdkQuGQPKyJ="> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="kZDkEfIR!ngV#w|Mx=/J"> <field name="TEXT">$.'</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="e;xWF[am$/jUvuQxCb:["> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="=l{vI?{uIxzWwOzn0Rll"> <field name="TEXT">'</field> </block> </value> </block> </value> <value name="TARGET"> <block type="variables_get" id="KtR^h,d+F=uC4,3.tEZz"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="z8nN;k_ep!x_9cd^+BB!"> <field name="TEXT"> mal gespielt.</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>Für Leute, die solche Dinge mit einem anderen Logikmaschine umsetzen wollen:
[ { "id": "1b8a9b7ff23e2b72", "type": "comment", "z": "29617fbe487e9c69", "name": "Elemente in einem Array zählen und als Objekt ausgeben", "info": "", "x": 270, "y": 1720, "wires": [] }, { "id": "db03a7ae6baec159", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\"]", "payloadType": "json", "x": 180, "y": 1800, "wires": [ [ "eee0fd1bbc1c7591" ] ] }, { "id": "eee0fd1bbc1c7591", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 1800, "wires": [ [ "db6b52e1b383fa3c", "f9376b9bca6163b6" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "db6b52e1b383fa3c", "type": "debug", "z": "29617fbe487e9c69", "name": "Array-Analyse", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 620, "y": 1800, "wires": [] }, { "id": "f9376b9bca6163b6", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "search", "pt": "msg", "to": "Schöne Maid, hast Du heut für mich Zeit", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 1860, "wires": [ [ "cda6bb4b435f80bb" ] ] }, { "id": "cda6bb4b435f80bb", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 870, "y": 1860, "wires": [ [ "251eea7ce5c8efe0" ] ] }, { "id": "251eea7ce5c8efe0", "type": "debug", "z": "29617fbe487e9c69", "name": "Suche Vorkommen von search ", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1130, "y": 1860, "wires": [] }, { "id": "4a0fb478973bae57", "type": "inject", "z": "29617fbe487e9c69", "name": "Array mit Liedern und Ausgabe von search in einem", "props": [ { "p": "payload" }, { "p": "search", "v": "Dancing Queen", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "[\"Schöne Maid, hast Du heut für mich Zeit\",\"Jump\",\"Jump\",\"Blauer Enzian\",\"Dancing Queen\",\"Yellow Submarine\",\"Blauer Enzian\",\"Jump\",\"Dancing Queen\",\"S.O.S\",\"Schöne Maid, hast Du heut für mich Zeit\",\"Dancing Queen\",\"Dancing Queen\"]", "payloadType": "json", "x": 290, "y": 1960, "wires": [ [ "48f9fec07b2dac6a" ] ] }, { "id": "48f9fec07b2dac6a", "type": "change", "z": "29617fbe487e9c69", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$distinct(payload).{$: $map($$.payload,function($v){$[$=$v]})~>$count()}.$sift(function($v,$k){$k = $$.search}).*", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 1960, "wires": [ [ "969a1f62b4b01026" ] ], "info": "# Objekt mit Häufigkeit des Auftretens in Array\r\n\r\nmuss noch auf payload übertragen werden.\r\n\r\n`$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}`" }, { "id": "969a1f62b4b01026", "type": "debug", "z": "29617fbe487e9c69", "name": "Vorkommen von search in Array", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 850, "y": 1960, "wires": [] } ]Auch JS Programmierer können JSONATA nutzen, da das im Adapter enthalten ist:
var titel = [ "Schöne Maid, hast Du heut für mich Zeit", "Jump", "Jump", "Blauer Enzian", "Dancing Queen", "Yellow Submarine", "Blauer Enzian", "Jump", "Dancing Queen", "S.O.S", "Schöne Maid, hast Du heut für mich Zeit" ]; var analyse = jsonataExpression(titel,'$distinct($).{"titel": $, "count" : $map($$,function($v){$[$=$v]}) ~> $count()}'); console.log(analyse); var suche = "Dancing Queen"; var ergebnis = jsonataExpression(analyse,'$[titel="'+ suche +'"].count'); console.log("Der Titel "+ suche + " ergab "+ ergebnis + " Treffer.");
@mickym ob ich nochmals nachfragen darf wie ich nun aus
[{"a":3},{"b":3} ...ein
[{"titel":"a","count":"3"},{"titel":"b","count":"3"} ...machen kann um das ganze dann schön in VIS darzustellen ?
Ich bin da grad am verzweifeln :mask:
Lehrling seit 1975 !!!
Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge -
@mickym ob ich nochmals nachfragen darf wie ich nun aus
[{"a":3},{"b":3} ...ein
[{"titel":"a","count":"3"},{"titel":"b","count":"3"} ...machen kann um das ganze dann schön in VIS darzustellen ?
Ich bin da grad am verzweifeln :mask:
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
[{"a":3},{"b":3} ...
Ich machs mal nur quick and dirty - da die Objekte ja klar definiert sind.
$.{"titel" : $keys(),"count": *}
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Q-{K{g^u8=SJ~bbJx1L2">neu</variable> <variable id="?+jUzr1AE!BT%ndErB?h">String</variable> <variable id="r2|O7xSSn}R]WP0Guw3#">Array</variable> <variable id="$-_m{u5(Dz83eo?3;{%[">Objekt</variable> <variable id="J?Di1B/ibZyz:%[nd_$1">Suche</variable> </variables> <block type="variables_set" id="2`xXRHf8dv/I7RRVQ9uP" x="-462" y="-187"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> <value name="VALUE"> <block type="text" id=":}kd79(jelVZP+`h)Q-G"> <field name="TEXT">S.O.S</field> </block> </value> <next> <block type="variables_set" id="//8bilRq!Q*Oo;YNFP0i"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> <value name="VALUE"> <block type="text" id="b;/knyEwB)g{AZ|(e4U;"> <field name="TEXT">a,b,b,a,c,d,a,b,c</field> </block> </value> <next> <block type="variables_set" id="jgNS,;m/}/6kEs:32$23"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> <value name="VALUE"> <block type="lists_split" id="4VgevC}Aug,7,$``$e2~"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="3OkVXfnD1V1{15oC}j0#"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> </block> </value> <value name="DELIM"> <shadow type="text" id="`^2^nlc|*0tZnVb/]MU0"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="lists_setIndex" id="^1a;jzhbYsZ3.(=%^3:o"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="Yc!NOY.mpz;*MQ4a.3cc"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <value name="TO"> <block type="variables_get" id="JN(3pS60Y)^Y=(.]j~4B"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> </block> </value> <next> <block type="debug" id="7Qj!rB9T*1u^?q*%grBj"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="X9Y@-Dl7gm/@@A1LA|rJ"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="(swR*aLu~G@PD}zgOnL+"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <next> <block type="variables_set" id="a75e#*Xc#m)nG`veslBd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="|P_BHOAk`P/_AfD`5I`Y"> <value name="EXPRESSION"> <shadow type="text" id=":Vas?]P#E6aU7]6b,~_q"> <field name="TEXT">$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="5t:`o,RyQ=/bO+x?(-kv"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> </block> </value> <next> <block type="debug" id="WJhIun5xunahKl@GICu}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="YQ7^n5qnxbu(/f6Uffd^"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="-,0VHv#EdBGI4Upg~~ZA"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="Hg9/:p^,/%Kf2tC;y-]W"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> <value name="VALUE"> <block type="text" id="m;o(c)D=jz_JWVJv@X8E"> <field name="TEXT">a</field> </block> </value> <next> <block type="debug" id="O9J+UurMn7PA^TKo,BHw"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p.m1Jo/[,,D8:FMicn0U"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="q,:sJ5DPG[Unp42nmwf4"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id=":+E?yRv@7u8_xlN?;!|Y"> <field name="TEXT">Lied </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="iiTxfl.#MUB;EfaFO/q;"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="JcTfv$r?$F7=m2$QWNgG"> <field name="TEXT"> wurde </field> </block> </value> <value name="ADD3"> <block type="convert_jsonata" id="^cI{f1Cedv)iL5xFEsa@"> <value name="EXPRESSION"> <shadow type="text" id="XolzYVS:6f[}CY%{=CtN"> <field name="TEXT">*</field> </shadow> <block type="text_join" id="jZb*`=0yOdkQuGQPKyJ="> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="kZDkEfIR!ngV#w|Mx=/J"> <field name="TEXT">$.'</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="e;xWF[am$/jUvuQxCb:["> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="=l{vI?{uIxzWwOzn0Rll"> <field name="TEXT">'</field> </block> </value> </block> </value> <value name="TARGET"> <block type="variables_get" id="KtR^h,d+F=uC4,3.tEZz"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="z8nN;k_ep!x_9cd^+BB!"> <field name="TEXT"> mal gespielt.</field> </block> </value> </block> </value> <next> <block type="debug" id=":H{dp!-z:u5+|n#a8pok"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="^Hd{-C)},fMch1=3eSN{"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="C^a!~n}WdvxU,qQ0Z+)T"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="-RRu#I@,}vQ,oH?)1byd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="Sm`R0amu|*s{$bCu-Q?q"> <value name="EXPRESSION"> <shadow type="text" id="Fc]hsd]=^{M./kva.10B"> <field name="TEXT">$.{"titel" : $keys(),"count": *}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="i]m~P99c%8l]P]S?H-ia"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <next> <block type="debug" id="$=K22lJ-lR2%5)A9G|n="> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="-l`,3:x:].IKRb}63*48"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="jOvt)?3e4F{up+G+5_s/"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.
-
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
[{"a":3},{"b":3} ...
Ich machs mal nur quick and dirty - da die Objekte ja klar definiert sind.
$.{"titel" : $keys(),"count": *}
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Q-{K{g^u8=SJ~bbJx1L2">neu</variable> <variable id="?+jUzr1AE!BT%ndErB?h">String</variable> <variable id="r2|O7xSSn}R]WP0Guw3#">Array</variable> <variable id="$-_m{u5(Dz83eo?3;{%[">Objekt</variable> <variable id="J?Di1B/ibZyz:%[nd_$1">Suche</variable> </variables> <block type="variables_set" id="2`xXRHf8dv/I7RRVQ9uP" x="-462" y="-187"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> <value name="VALUE"> <block type="text" id=":}kd79(jelVZP+`h)Q-G"> <field name="TEXT">S.O.S</field> </block> </value> <next> <block type="variables_set" id="//8bilRq!Q*Oo;YNFP0i"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> <value name="VALUE"> <block type="text" id="b;/knyEwB)g{AZ|(e4U;"> <field name="TEXT">a,b,b,a,c,d,a,b,c</field> </block> </value> <next> <block type="variables_set" id="jgNS,;m/}/6kEs:32$23"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> <value name="VALUE"> <block type="lists_split" id="4VgevC}Aug,7,$``$e2~"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="3OkVXfnD1V1{15oC}j0#"> <field name="VAR" id="?+jUzr1AE!BT%ndErB?h">String</field> </block> </value> <value name="DELIM"> <shadow type="text" id="`^2^nlc|*0tZnVb/]MU0"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="lists_setIndex" id="^1a;jzhbYsZ3.(=%^3:o"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="Yc!NOY.mpz;*MQ4a.3cc"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <value name="TO"> <block type="variables_get" id="JN(3pS60Y)^Y=(.]j~4B"> <field name="VAR" id="Q-{K{g^u8=SJ~bbJx1L2">neu</field> </block> </value> <next> <block type="debug" id="7Qj!rB9T*1u^?q*%grBj"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="X9Y@-Dl7gm/@@A1LA|rJ"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="(swR*aLu~G@PD}zgOnL+"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> <next> <block type="variables_set" id="a75e#*Xc#m)nG`veslBd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="|P_BHOAk`P/_AfD`5I`Y"> <value name="EXPRESSION"> <shadow type="text" id=":Vas?]P#E6aU7]6b,~_q"> <field name="TEXT">$distinct($).{$ : $map($$,function($v){$[$=$v]}) ~> $count()}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="5t:`o,RyQ=/bO+x?(-kv"> <field name="VAR" id="r2|O7xSSn}R]WP0Guw3#">Array</field> </block> </value> </block> </value> <next> <block type="debug" id="WJhIun5xunahKl@GICu}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="YQ7^n5qnxbu(/f6Uffd^"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="-,0VHv#EdBGI4Upg~~ZA"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="Hg9/:p^,/%Kf2tC;y-]W"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> <value name="VALUE"> <block type="text" id="m;o(c)D=jz_JWVJv@X8E"> <field name="TEXT">a</field> </block> </value> <next> <block type="debug" id="O9J+UurMn7PA^TKo,BHw"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p.m1Jo/[,,D8:FMicn0U"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="q,:sJ5DPG[Unp42nmwf4"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id=":+E?yRv@7u8_xlN?;!|Y"> <field name="TEXT">Lied </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="iiTxfl.#MUB;EfaFO/q;"> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="JcTfv$r?$F7=m2$QWNgG"> <field name="TEXT"> wurde </field> </block> </value> <value name="ADD3"> <block type="convert_jsonata" id="^cI{f1Cedv)iL5xFEsa@"> <value name="EXPRESSION"> <shadow type="text" id="XolzYVS:6f[}CY%{=CtN"> <field name="TEXT">*</field> </shadow> <block type="text_join" id="jZb*`=0yOdkQuGQPKyJ="> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="kZDkEfIR!ngV#w|Mx=/J"> <field name="TEXT">$.'</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="e;xWF[am$/jUvuQxCb:["> <field name="VAR" id="J?Di1B/ibZyz:%[nd_$1">Suche</field> </block> </value> <value name="ADD2"> <block type="text" id="=l{vI?{uIxzWwOzn0Rll"> <field name="TEXT">'</field> </block> </value> </block> </value> <value name="TARGET"> <block type="variables_get" id="KtR^h,d+F=uC4,3.tEZz"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="z8nN;k_ep!x_9cd^+BB!"> <field name="TEXT"> mal gespielt.</field> </block> </value> </block> </value> <next> <block type="debug" id=":H{dp!-z:u5+|n#a8pok"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="^Hd{-C)},fMch1=3eSN{"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="C^a!~n}WdvxU,qQ0Z+)T"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> <next> <block type="variables_set" id="-RRu#I@,}vQ,oH?)1byd"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> <value name="VALUE"> <block type="convert_jsonata" id="Sm`R0amu|*s{$bCu-Q?q"> <value name="EXPRESSION"> <shadow type="text" id="Fc]hsd]=^{M./kva.10B"> <field name="TEXT">$.{"titel" : $keys(),"count": *}</field> </shadow> </value> <value name="TARGET"> <block type="variables_get" id="i]m~P99c%8l]P]S?H-ia"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </value> <next> <block type="debug" id="$=K22lJ-lR2%5)A9G|n="> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="-l`,3:x:].IKRb}63*48"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="jOvt)?3e4F{up+G+5_s/"> <field name="VAR" id="$-_m{u5(Dz83eo?3;{%[">Objekt</field> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
$.{"titel" : $keys(),"count": *}
Du bisch der Wahnsinn :+1: :+1: :+1: :+1:
Lehrling seit 1975 !!!
Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge -
@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
$.{"titel" : $keys(),"count": *}
Du bisch der Wahnsinn :+1: :+1: :+1: :+1:
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
$.{"titel" : $keys(),"count": *}
Du bisch der Wahnsinn :+1: :+1: :+1: :+1:
So wäre es eigentlich sauber:
$.{"titel" : $keys()[0],"count": $lookup($, $keys()[0])}damit die Zuordnung eindeutig ist, wenn Dein Objekt mehrere Eigenschaften hätte-
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.
-
@mickym ob ich nochmals nachfragen darf wie ich nun aus
[{"a":3},{"b":3} ...ein
[{"titel":"a","count":"3"},{"titel":"b","count":"3"} ...machen kann um das ganze dann schön in VIS darzustellen ?
Ich bin da grad am verzweifeln :mask:
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym ob ich nochmals nachfragen darf wie ich nun aus
[{"a":3},{"b":3} ...ein
[{"titel":"a","count":"3"},{"titel":"b","count":"3"} ...machen kann um das ganze dann schön in VIS darzustellen ?
Ich bin da grad am verzweifeln :mask:
Weißt Du das Problem ist - dass Du gefragt hast, wie man das umwandelt. Wenn Du sowas gleich gesagt hättest, dann hätte man die Objekte gleich so aufbauen können.

Ich ändere mal das Blockly noch ab - wie es sich dann gehört.
Also dann hätte man auch direkt im Blockly den 1. JSONATA Ausdruck entsprechend erstellt:
$distinct($).{"titel": $, "count" : $map($$,function($v){$[$=$v]}) ~> $count()}
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.
-
@djmarc75 sagte in Aufzählung gleicher Werte aus Datenpunkt:
@mickym ob ich nochmals nachfragen darf wie ich nun aus
[{"a":3},{"b":3} ...ein
[{"titel":"a","count":"3"},{"titel":"b","count":"3"} ...machen kann um das ganze dann schön in VIS darzustellen ?
Ich bin da grad am verzweifeln :mask:
Weißt Du das Problem ist - dass Du gefragt hast, wie man das umwandelt. Wenn Du sowas gleich gesagt hättest, dann hätte man die Objekte gleich so aufbauen können.

Ich ändere mal das Blockly noch ab - wie es sich dann gehört.
Also dann hätte man auch direkt im Blockly den 1. JSONATA Ausdruck entsprechend erstellt:
$distinct($).{"titel": $, "count" : $map($$,function($v){$[$=$v]}) ~> $count()}
@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
Weißt Du das Problem ist - dass Du gefragt hast, wie man das umwandelt
Asche auf mein Haupt. Aber mir ist ja nicht bewusst gewesen wie ich überhaupt eine Aufzählung hätte umsetzen können.
Umgesetzt und läuft wie ein Uhrwerk :kiss: :joy:
Lehrling seit 1975 !!!
Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge -
@mickym sagte in Aufzählung gleicher Werte aus Datenpunkt:
Weißt Du das Problem ist - dass Du gefragt hast, wie man das umwandelt
Asche auf mein Haupt. Aber mir ist ja nicht bewusst gewesen wie ich überhaupt eine Aufzählung hätte umsetzen können.
Umgesetzt und läuft wie ein Uhrwerk :kiss: :joy:
@djmarc75 Ich hab neben Deinen Puzzleteilchen hier noch Lösungen mit alternativen Logikmaschinen eingestellt, die auch JSONATA nutzen können.
Vielleicht lässt sich ja der eine oder andere doch noch von der Leistungsfähigkeit dieser Bibliothek überzeugen insbesondere, da per Default die Bibliothek im JS Adapter integriert ist. Die NodeRed Lösung passt natürlich nicht, aber ganz verkneifen konnte ich es mir nicht, da ich sowas dann auch in meiner eigenen Bibliothek sammle.
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.