Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Node-Red
    5. ShellyPlug / NodeRed / Werte zu einem Objekt

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    ShellyPlug / NodeRed / Werte zu einem Objekt

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

      Hallo,

      ich möchte einzelne Werte des Shelly in ein Objekt ohne die Topics zusammenfassen:

      {"shellies/shellyplug-s-1/relay/0/power":0,"shellies/shellyplug-s-1/relay/0/energy":3846,"shellies/shellyplug-s-1/temperature":15.37,"shellies/shellyplug-s-1/overtemperature":0,"shellies/shellyplug-s-1/relay/0":0}
      

      nach

      {"power":0,"energy":3846,"temperature":15.37,"overtemperature":0,"relay":0}
      

      Ich weiß nicht, wie ich die Topics entfernen kann. Wer kann mir da weiterhelfen ?

      mickym 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @Frank86 last edited by mickym

        7cdfdff0-b68f-4b41-a8ed-c2502c69fb2a-image.png

        [
           {
               "id": "b4a1b3637509ca38",
               "type": "inject",
               "z": "5cf927401246e0e8",
               "name": "",
               "props": [
                   {
                       "p": "payload"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "{\"shellies/shellyplug-s-1/relay/0/power\":0,\"shellies/shellyplug-s-1/relay/0/energy\":3846,\"shellies/shellyplug-s-1/temperature\":15.37,\"shellies/shellyplug-s-1/overtemperature\":0,\"shellies/shellyplug-s-1/relay/0\":0}",
               "payloadType": "json",
               "x": 130,
               "y": 460,
               "wires": [
                   [
                       "3d5f65021e23ca15",
                       "aa0be2b314d54fd5"
                   ]
               ]
           },
           {
               "id": "3d5f65021e23ca15",
               "type": "debug",
               "z": "5cf927401246e0e8",
               "name": "Objekt",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 310,
               "y": 420,
               "wires": []
           },
           {
               "id": "aa0be2b314d54fd5",
               "type": "split",
               "z": "5cf927401246e0e8",
               "name": "",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "topic",
               "x": 310,
               "y": 460,
               "wires": [
                   [
                       "cdb9aaf8487e83ed"
                   ]
               ]
           },
           {
               "id": "cdb9aaf8487e83ed",
               "type": "change",
               "z": "5cf927401246e0e8",
               "name": "",
               "rules": [
                   {
                       "t": "change",
                       "p": "parts.key",
                       "pt": "msg",
                       "from": ".*\\/(.*)$",
                       "fromt": "re",
                       "to": "$1",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 500,
               "y": 460,
               "wires": [
                   [
                       "9f1260104cd7e37c"
                   ]
               ]
           },
           {
               "id": "9f1260104cd7e37c",
               "type": "join",
               "z": "5cf927401246e0e8",
               "name": "",
               "mode": "auto",
               "build": "object",
               "property": "payload",
               "propertyType": "msg",
               "key": "topic",
               "joiner": "\\n",
               "joinerType": "str",
               "accumulate": true,
               "timeout": "1",
               "count": "",
               "reduceRight": false,
               "reduceExp": "",
               "reduceInit": "",
               "reduceInitType": "",
               "reduceFixup": "",
               "x": 670,
               "y": 460,
               "wires": [
                   [
                       "62c5c9f9e2e7cbda"
                   ]
               ]
           },
           {
               "id": "e72b4078cf0357f4",
               "type": "debug",
               "z": "5cf927401246e0e8",
               "name": "new Object",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 1050,
               "y": 460,
               "wires": []
           },
           {
               "id": "62c5c9f9e2e7cbda",
               "type": "change",
               "z": "5cf927401246e0e8",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "payload ~>|$|{\"relay_0\" : $lookup($,\"0\"),\"relay_1\" : $lookup($,\"1\")},[\"0\",\"1\"]|",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 850,
               "y": 460,
               "wires": [
                   [
                       "e72b4078cf0357f4"
                   ]
               ]
           }
        ]
        

        So hier obigen Flow in JSONATA:

        01361eb9-d41d-4f9e-873e-2fa1ca43f062-image.png

        [
           {
               "id": "06c72fe6fdb0a916",
               "type": "inject",
               "z": "5cf927401246e0e8",
               "name": "",
               "props": [
                   {
                       "p": "payload"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "{\"shellies/shellyplug-s-1/relay/0/power\":0,\"shellies/shellyplug-s-1/relay/0/energy\":3846,\"shellies/shellyplug-s-1/temperature\":15.37,\"shellies/shellyplug-s-1/overtemperature\":0,\"shellies/shellyplug-s-1/relay/0\":0}",
               "payloadType": "json",
               "x": 290,
               "y": 220,
               "wires": [
                   [
                       "f9a7b5a98fe966b1",
                       "338f39c5e5f67428"
                   ]
               ]
           },
           {
               "id": "f9a7b5a98fe966b1",
               "type": "debug",
               "z": "5cf927401246e0e8",
               "name": "Objekt",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 470,
               "y": 180,
               "wires": []
           },
           {
               "id": "338f39c5e5f67428",
               "type": "change",
               "z": "5cf927401246e0e8",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "$each(payload, function($v, $k) {$. {$replace($k,/.*\\/(.*)$/,\"$1\"):$v}}) ~> $merge()~>|$|{\"relay_0\" : $lookup($,\"0\"),\"relay_1\" : $lookup($,\"1\")},[\"0\",\"1\"]|",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 490,
               "y": 220,
               "wires": [
                   [
                       "4a5ee4bc626bb7d9"
                   ]
               ]
           },
           {
               "id": "4a5ee4bc626bb7d9",
               "type": "debug",
               "z": "5cf927401246e0e8",
               "name": "new Object",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 690,
               "y": 220,
               "wires": []
           }
        ]
        

        Hier der JSONATA-Code aus der Change Node:

        $each(payload, function($v, $k) {$. {$replace($k,/.*\/(.*)$/,"$1"):$v}}) ~> $merge()~>|$|{"relay_0" : $lookup($,"0"),"relay_1" : $lookup($,"1")},["0","1"]|
        
        F 1 Reply Last reply Reply Quote 0
        • F
          Frank86 @mickym last edited by

          @mickym : Vielen Dank ! Sieht nach einer Lösung aus, probiere ich morgen 👍🏻

          mickym 1 Reply Last reply Reply Quote 0
          • mickym
            mickym Most Active @Frank86 last edited by mickym

            @frank86 Ja ich musste noch was ändern - da gerade wenn Du 2 Relais hast - das 0 als Integer und nicht als Key interpretiert wurde. Den JSONATA Code habe ich schon angepasst.

            So ich habe beide Lösungen angepasst. Statt relay - habe ich jetzt relay_0 und relay_1 genommen, dann passt es auch für Shellies 2.5. Falls Du das nicht willst, musst es halt wieder ändern.

            F mickym 2 Replies Last reply Reply Quote 0
            • F
              Frank86 @mickym last edited by Frank86

              @mickym
              Funktioniert !

              Jetzt stelle ich mir die Frage, warum ich nicht nur ein mqtt-Node benutzen kann mit Auswahl aller Nachrichten-Objekte ("shellies/shellyplug-s-1/#") , ich baue einen Nachricht ja zunächst auf 😕

              [{"id":"eda5f77f7c8eed8d","type":"mqtt in","z":"c9969210232b94da","name":"mqtt-shellyplug-s-1","topic":"shellies/shellyplug-s-1/overtemperature","qos":"0","datatype":"auto-detect","broker":"c34b10c04573881a","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":360,"wires":[["c87fc064918d6540"]]},{"id":"c34b10c04573881a","type":"mqtt-broker","name":"mqtt-fhem","broker":"192.168.178.212","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]! 
              

              Unbenannt1.JPG

              1 Reply Last reply Reply Quote 0
              • mickym
                mickym Most Active @mickym last edited by mickym

                @mickym Kannst Du doch - ich würde einfach shellies/shellyplug-s-1/# nehmen und den ersten Teil aus dem Topic einfach entfernen - ist doch easy. Da muss man doch nicht so Riesenverrenkungen machen:

                e722dc13-4076-4f17-a662-6ecd7cbd65e8-image.png

                [
                   {
                       "id": "ed30cdc3fbacb298",
                       "type": "mqtt in",
                       "z": "578345f4956c7a57",
                       "name": "",
                       "topic": "shellies/schalter/kueche/licht_abzug/#",
                       "qos": "2",
                       "datatype": "auto-detect",
                       "broker": "03fc28fd5e3d0913",
                       "nl": false,
                       "rap": true,
                       "rh": 0,
                       "inputs": 0,
                       "x": 350,
                       "y": 2640,
                       "wires": [
                           [
                               "1abae9f5e394107f",
                               "5cca889ca2bc40af"
                           ]
                       ]
                   },
                   {
                       "id": "1abae9f5e394107f",
                       "type": "debug",
                       "z": "578345f4956c7a57",
                       "name": "Shelly Küche",
                       "active": false,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "payload",
                       "targetType": "msg",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 650,
                       "y": 2600,
                       "wires": []
                   },
                   {
                       "id": "5cca889ca2bc40af",
                       "type": "change",
                       "z": "578345f4956c7a57",
                       "name": "",
                       "rules": [
                           {
                               "t": "change",
                               "p": "topic",
                               "pt": "msg",
                               "from": "shellies/schalter/kueche/licht_abzug/",
                               "fromt": "str",
                               "to": "",
                               "tot": "str"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 650,
                       "y": 2640,
                       "wires": [
                           [
                               "760564b613d352a4",
                               "35d92b645c892d53"
                           ]
                       ]
                   },
                   {
                       "id": "760564b613d352a4",
                       "type": "debug",
                       "z": "578345f4956c7a57",
                       "name": "Shelly Küche ohne Pfad",
                       "active": false,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "payload",
                       "targetType": "msg",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 890,
                       "y": 2680,
                       "wires": []
                   },
                   {
                       "id": "35d92b645c892d53",
                       "type": "join",
                       "z": "578345f4956c7a57",
                       "name": "",
                       "mode": "custom",
                       "build": "object",
                       "property": "payload",
                       "propertyType": "msg",
                       "key": "topic",
                       "joiner": "\\n",
                       "joinerType": "str",
                       "accumulate": true,
                       "timeout": "1",
                       "count": "",
                       "reduceRight": false,
                       "reduceExp": "",
                       "reduceInit": "",
                       "reduceInitType": "",
                       "reduceFixup": "",
                       "x": 850,
                       "y": 2640,
                       "wires": [
                           [
                               "29a8632928735825"
                           ]
                       ]
                   },
                   {
                       "id": "29a8632928735825",
                       "type": "debug",
                       "z": "578345f4956c7a57",
                       "name": "Shelly Objekt",
                       "active": true,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "payload",
                       "targetType": "msg",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 1030,
                       "y": 2640,
                       "wires": []
                   },
                   {
                       "id": "03fc28fd5e3d0913",
                       "type": "mqtt-broker",
                       "name": "MWHome - mosquitto",
                       "broker": "mwhome.fritz.box",
                       "port": "1883",
                       "clientid": "",
                       "autoConnect": true,
                       "usetls": false,
                       "protocolVersion": "4",
                       "keepalive": "60",
                       "cleansession": true,
                       "birthTopic": "",
                       "birthQos": "0",
                       "birthPayload": "",
                       "birthMsg": {},
                       "closeTopic": "",
                       "closeQos": "0",
                       "closePayload": "",
                       "closeMsg": {},
                       "willTopic": "",
                       "willQos": "0",
                       "willPayload": "",
                       "willMsg": {},
                       "userProps": "",
                       "sessionExpiry": ""
                   }
                ]
                

                F 1 Reply Last reply Reply Quote 0
                • F
                  Frank86 @mickym last edited by

                  @mickym Habe es nochmals versucht, jetzt habe ich wieder relay/0/ drin. Der Versuch mit den oben gezeigten Nodes nur "relay" stehen zu lassen schlägt fehl, ich lasse es nun so, danke.

                  [
                      {
                          "id": "8dfc8447eab4b4d7",
                          "type": "tab",
                          "label": "Flow 5",
                          "disabled": false,
                          "info": "",
                          "env": []
                      },
                      {
                          "id": "ed30cdc3fbacb298",
                          "type": "mqtt in",
                          "z": "8dfc8447eab4b4d7",
                          "name": "",
                          "topic": "shellies/shellyplug-s-1/#",
                          "qos": "0",
                          "datatype": "auto-detect",
                          "broker": "c34b10c04573881a",
                          "nl": false,
                          "rap": true,
                          "rh": 0,
                          "inputs": 0,
                          "x": 140,
                          "y": 140,
                          "wires": [
                              [
                                  "1abae9f5e394107f",
                                  "886f94224123013e"
                              ]
                          ]
                      },
                      {
                          "id": "1abae9f5e394107f",
                          "type": "debug",
                          "z": "8dfc8447eab4b4d7",
                          "name": "Shelly Küche",
                          "active": false,
                          "tosidebar": true,
                          "console": false,
                          "tostatus": false,
                          "complete": "payload",
                          "targetType": "msg",
                          "statusVal": "",
                          "statusType": "auto",
                          "x": 390,
                          "y": 60,
                          "wires": []
                      },
                      {
                          "id": "886f94224123013e",
                          "type": "change",
                          "z": "8dfc8447eab4b4d7",
                          "name": "Relais - string to int",
                          "rules": [
                              {
                                  "t": "change",
                                  "p": "payload",
                                  "pt": "msg",
                                  "from": "on",
                                  "fromt": "str",
                                  "to": "1",
                                  "tot": "num"
                              },
                              {
                                  "t": "change",
                                  "p": "payload",
                                  "pt": "msg",
                                  "from": "off",
                                  "fromt": "str",
                                  "to": "0",
                                  "tot": "num"
                              }
                          ],
                          "action": "",
                          "property": "",
                          "from": "",
                          "to": "",
                          "reg": false,
                          "x": 390,
                          "y": 140,
                          "wires": [
                              [
                                  "e7cfa2110d433df8"
                              ]
                          ]
                      },
                      {
                          "id": "e7cfa2110d433df8",
                          "type": "change",
                          "z": "8dfc8447eab4b4d7",
                          "name": "",
                          "rules": [
                              {
                                  "t": "change",
                                  "p": "topic",
                                  "pt": "msg",
                                  "from": "shellies/shellyplug-s-1/",
                                  "fromt": "str",
                                  "to": "",
                                  "tot": "str"
                              }
                          ],
                          "action": "",
                          "property": "",
                          "from": "",
                          "to": "",
                          "reg": false,
                          "x": 590,
                          "y": 140,
                          "wires": [
                              [
                                  "46377bffe56d4ecc",
                                  "f105ba5467a7b184"
                              ]
                          ]
                      },
                      {
                          "id": "46377bffe56d4ecc",
                          "type": "debug",
                          "z": "8dfc8447eab4b4d7",
                          "name": "Shelly Küche ohne Pfad",
                          "active": false,
                          "tosidebar": true,
                          "console": false,
                          "tostatus": false,
                          "complete": "payload",
                          "targetType": "msg",
                          "statusVal": "",
                          "statusType": "auto",
                          "x": 830,
                          "y": 60,
                          "wires": []
                      },
                      {
                          "id": "f105ba5467a7b184",
                          "type": "join",
                          "z": "8dfc8447eab4b4d7",
                          "name": "",
                          "mode": "custom",
                          "build": "object",
                          "property": "payload",
                          "propertyType": "msg",
                          "key": "topic",
                          "joiner": "\\n",
                          "joinerType": "str",
                          "accumulate": true,
                          "timeout": "1",
                          "count": "",
                          "reduceRight": false,
                          "reduceExp": "",
                          "reduceInit": "",
                          "reduceInitType": "",
                          "reduceFixup": "",
                          "x": 770,
                          "y": 140,
                          "wires": [
                              [
                                  "4a297d0aef5f7b54"
                              ]
                          ]
                      },
                      {
                          "id": "4a297d0aef5f7b54",
                          "type": "debug",
                          "z": "8dfc8447eab4b4d7",
                          "name": "Shelly Objekt",
                          "active": true,
                          "tosidebar": true,
                          "console": false,
                          "tostatus": false,
                          "complete": "payload",
                          "targetType": "msg",
                          "statusVal": "",
                          "statusType": "auto",
                          "x": 930,
                          "y": 140,
                          "wires": []
                      },
                      {
                          "id": "c34b10c04573881a",
                          "type": "mqtt-broker",
                          "name": "mqtt-fhem",
                          "broker": "192.168.178.212",
                          "port": "1883",
                          "clientid": "",
                          "autoConnect": true,
                          "usetls": false,
                          "protocolVersion": "4",
                          "keepalive": "60",
                          "cleansession": true,
                          "birthTopic": "",
                          "birthQos": "0",
                          "birthPayload": "",
                          "birthMsg": {},
                          "closeTopic": "",
                          "closeQos": "0",
                          "closePayload": "",
                          "closeMsg": {},
                          "willTopic": "",
                          "willQos": "0",
                          "willPayload": "",
                          "willMsg": {},
                          "userProps": "",
                          "sessionExpiry": ""
                      }
                  ]
                  

                  Unbenannt.JPG

                  mickym 1 Reply Last reply Reply Quote 0
                  • mickym
                    mickym Most Active @Frank86 last edited by

                    @frank86 warum stört dich der /? Du kannst die / ja auch noch weg lassen.

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

                    Support us

                    ioBroker
                    Community Adapters
                    Donate

                    589
                    Online

                    31.7k
                    Users

                    79.7k
                    Topics

                    1.3m
                    Posts

                    2
                    8
                    262
                    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