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] Payload Daten in Objekte schreiben

    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

    [gelöst] Payload Daten in Objekte schreiben

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

      @paul53
      Logstufe "Error"

      GregorS Homoran 2 Replies Last reply Reply Quote 0
      • GregorS
        GregorS @GregorS last edited by

        Hab auf Debug umgestellt.
        Jetzt kommt was.

        javascript.0
        	2023-07-22 18:34:43.750	info	script.js.LoRAWAN_DEV_1: undefined
        javascript.0
        	2023-07-22 18:34:43.749	info	script.js.LoRAWAN_DEV_1: {"end_device_ids":{"device_id":"eui-a840414601871305","application_ids":{"application_id":"gs-mg-dragino-01"},"dev_eui":"A840414601871305","join_eui":"A840410000000101","dev_addr":"260BE9CF"},"correlation_ids":["as:up:01H5Z784WHCPR9CKQMD6YA61PJ","gs:conn:01H5TF5M58SGAQZTB5B766P6EM","gs:up:host:01H5TF5M5DGPVSKX7RKJ1HPXFF","gs:uplink:01H5Z784NZ778FHQVN8ATABV4B","ns:uplink:01H5Z784P0FCGCHDWHMB7EZSAR","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01H5Z784P0MKF1ZWAFJ9K7394H","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01H5Z784WGE4FZ7ETJHPJJQ9DV"],"received_at":"2023-07-22T16:34:43.728419808Z","uplink_message":{"session_key_id":"AYlu5XV3aMaeiMVAq8yISw==","f_port":2,"f_cnt":4350,"frm_payload":"NgUAAAAAAAA0/0E=","decoded_payload":{"ACI1_mA":"0.000", "ACI2_mA":"0.000", "AVI1_V":"13.829", "AVI2_V":"0.000", "Acount_times":null, "Count1_times":null, "Count2_times":null, "DI1_status":"L", "DI2_status":"H", "DI3_status":null, "DO1_status":"H", "DO2_status":"H", "DO3_status":null, "First_status":null, "Hardware_mode":"LT22222", "RO1_status":"OFF", "RO2_status":"OFF", "Work_mode":"2ACI+2AVI"},"rx_metadata":[{"gateway_ids":{"gateway_id":"eui-7076ff0056080b0f","eui":"7076FF0056080B0F"},"time":"2023-07-22T16:34:42.898Z","timestamp":3874550100,"rssi":-113,"channel_rssi":-113,"snr":-9.5,"uplink_token":"CiIKIAoUZXVpLTcwNzZmZjAwNTYwODBiMGYSCHB2/wBWCAsPENTiw7cOGgwIo4rwpQYQluzr9wEgoOC66eH+JSoMCKKK8KUGEIDJmawD","channel_index":1,"gps_time":"2023-07-22T16:34:42.898Z","received_at":"2023-07-22T16:34:42.235671618Z"}],"settings":{"data_rate":{"lora":{"bandwidth":125000, "spreading_factor":12, "coding_rate":"4/5"}}, "frequency":"867300000", "timestamp":3874550100, "time":"2023-07-22T16:34:42.898Z"},"received_at":"2023-07-22T16:34:43.520848844Z","consumed_airtime":"1.482752s","version_ids":{"brand_id":"dragino", "model_id":"lt22222-l", "hardware_version":"_unknown_hw_version_", "firmware_version":"1.5.6", "band_id":"EU_863_870"},"network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"eu1","cluster_address":"eu1.cloud.thethings.network"}}}
        
        paul53 1 Reply Last reply Reply Quote 0
        • paul53
          paul53 @GregorS last edited by paul53

          @gregors sagte: Hab auf Debug umgestellt.

          Stell auf "info".

          @gregors sagte in Payload Daten in Objekte schreiben:

          Jetzt kommt was.

          Auch alle 2 Minuten aus dem Trigger?

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

            @paul53

            18:43:37.493	info	javascript.0 (652027) Start javascript script.js.LoRAWAN_DEV_1
            18:43:37.496	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: {"end_device_ids":{"device_id":"eui-a840414601871305","application_ids":{"application_id":"gs-mg-dragino-01"},"dev_eui":"A840414601871305","join_eui":"A840410000000101","dev_addr":"260BE9CF"},"correlation_ids":["as:up:01H5Z7MYH48PRXF13SW1RS6HD4","gs:conn:01H5TF5M58SGAQZTB5B766P6EM","gs:up:host:01H5TF5M5DGPVSKX7RKJ1HPXFF","gs:uplink:01H5Z7MYARW1Q74HXA0T7D5T4S","ns:uplink:01H5Z7MYAR2XJWHT5VS9XVHEZZ","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01H5Z7MYARMWPFGXW00K1X3WSV","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01H5Z7MYH4FKD5VX7EZXWGJKHZ"],"received_at":"2023-07-22T16:41:43.204341812Z","uplink_message":{"session_key_id":"AYlu5XV3aMaeiMVAq8yISw==","f_port":2,"f_cnt":4357,"frm_payload":"NgMAAAAAAAA0/0E=","decoded_payload":{"ACI1_mA":"0.000", "ACI2_mA":"0.000", "AVI1_V":"13.827", "AVI2_V":"0.000", "Acount_times":null, "Count1_times":null, "Count2_times":null, "DI1_status":"L", "DI2_status":"H", "DI3_status":null, "DO1_status":"H", "DO2_status":"H", "DO3_status":null, "First_status":null, "Hardware_mode":"LT22222", "RO1_status":"OFF", "RO2_status":"OFF", "Work_mode":"2ACI+2AVI"},"rx_metadata":[{"gateway_ids":{"gateway_id":"eui-7076ff0056080b0f","eui":"7076FF0056080B0F"},"time":"2023-07-22T16:41:42.891Z","timestamp":4294543004,"rssi":-118,"channel_rssi":-118,"snr":-12.2,"uplink_token":"CiIKIAoUZXVpLTcwNzZmZjAwNTYwODBiMGYSCHB2/wBWCAsPEJyN5v8PGgwIxo3wpQYQiODg3AMg4KLXtf6KJioMCMaN8KUGEMCp7qgD","channel_index":3,"gps_time":"2023-07-22T16:41:42.891Z","received_at":"2023-07-22T16:41:42.692566999Z"}],"settings":{"data_rate":{"lora":{"bandwidth":125000, "spreading_factor":12, "coding_rate":"4/5"}}, "frequency":"867700000", "timestamp":4294543004, "time":"2023-07-22T16:41:42.891Z"},"received_at":"2023-07-22T16:41:43.000778353Z","consumed_airtime":"1.482752s","version_ids":{"brand_id":"dragino", "model_id":"lt22222-l", "hardware_version":"_unknown_hw_version_", "firmware_version":"1.5.6", "band_id":"EU_863_870"},"network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"eu1","cluster_address":"eu1.cloud.thethings.network"}}}
            18:43:37.496	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: registered 1 subscription, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
            18:43:43.227	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: {"end_device_ids":{"device_id":"eui-a840414601871305","application_ids":{"application_id":"gs-mg-dragino-01"},"dev_eui":"A840414601871305","join_eui":"A840410000000101","dev_addr":"260BE9CF"},"correlation_ids":["as:up:01H5Z7RKQ7EM4GPTNH3A4ZZQRM","gs:conn:01H5TF5M58SGAQZTB5B766P6EM","gs:up:host:01H5TF5M5DGPVSKX7RKJ1HPXFF","gs:uplink:01H5Z7RKGRA8VCCA5GDJDAJ32G","ns:uplink:01H5Z7RKGSHDHETYPCFKHZ4WB8","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01H5Z7RKGSTVXAW22XNQWVCPYS","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01H5Z7RKQ7Q4ASFM7XB599YRYK"],"received_at":"2023-07-22T16:43:43.207301529Z","uplink_message":{"session_key_id":"AYlu5XV3aMaeiMVAq8yISw==","f_port":2,"f_cnt":4359,"frm_payload":"NicAAAAAAAA0/0E=","decoded_payload":{"ACI1_mA":"0.000", "ACI2_mA":"0.000", "AVI1_V":"13.863", "AVI2_V":"0.000", "Acount_times":null, "Count1_times":null, "Count2_times":null, "DI1_status":"L", "DI2_status":"H", "DI3_status":null, "DO1_status":"H", "DO2_status":"H", "DO3_status":null, "First_status":null, "Hardware_mode":"LT22222", "RO1_status":"OFF", "RO2_status":"OFF", "Work_mode":"2ACI+2AVI"},"rx_metadata":[{"gateway_ids":{"gateway_id":"eui-7076ff0056080b0f","eui":"7076FF0056080B0F"},"time":"2023-07-22T16:43:42.882Z","timestamp":119566764,"rssi":-117,"channel_rssi":-117,"snr":-14.5,"uplink_token":"CiIKIAoUZXVpLTcwNzZmZjAwNTYwODBiMGYSCHB2/wBWCAsPEKzjgTkaCgi/jvClBhCVjhYg4I/wtb2OJioMCL6O8KUGEICByaQD","channel_index":7,"gps_time":"2023-07-22T16:43:42.882Z","received_at":"2023-07-22T16:43:42.693099748Z"}],"settings":{"data_rate":{"lora":{"bandwidth":125000, "spreading_factor":12, "coding_rate":"4/5"}}, "frequency":"868500000", "timestamp":119566764, "time":"2023-07-22T16:43:42.882Z"},"received_at":"2023-07-22T16:43:43.001729646Z","consumed_airtime":"1.482752s","version_ids":{"brand_id":"dragino", "model_id":"lt22222-l", "hardware_version":"_unknown_hw_version_", "firmware_version":"1.5.6", "band_id":"EU_863_870"},"network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"eu1","cluster_address":"eu1.cloud.thethings.network"}}}
            18:43:43.228	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: undefined
            
            paul53 1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @GregorS last edited by paul53

              @gregors

              log(payload);
              

              zeigt offenbar undefined, da "decoded_payload" falsch geschrieben ist (Zeile 5).

              GregorS 1 Reply Last reply Reply Quote 1
              • Homoran
                Homoran Global Moderator Administrators @GregorS last edited by

                @gregors sagte in Payload Daten in Objekte schreiben:

                Logstufe "Error"

                nee, nich?

                1 Reply Last reply Reply Quote 1
                • GregorS
                  GregorS @paul53 last edited by

                  @paul53

                  Habe ich korrigiert. Der Teufel steckt im Detail

                  19:01:43.238	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: {"end_device_ids":{"device_id":"eui-a840414601871305","application_ids":{"application_id":"gs-mg-dragino-01"},"dev_eui":"A840414601871305","join_eui":"A840410000000101","dev_addr":"260BE9CF"},"correlation_ids":["as:up:01H5Z8SJDEQ23SXYZE51TC07BD","gs:conn:01H5TF5M58SGAQZTB5B766P6EM","gs:up:host:01H5TF5M5DGPVSKX7RKJ1HPXFF","gs:uplink:01H5Z8SJ70D6PACPHB0R2GHN04","ns:uplink:01H5Z8SJ712X5TEW0CWDE4CXQM","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01H5Z8SJ715Z75WJ51BS6ZWF31","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01H5Z8SJDDM0YCG82TXN5P6Q2T"],"received_at":"2023-07-22T17:01:43.213639158Z","uplink_message":{"session_key_id":"AYlu5XV3aMaeiMVAq8yISw==","f_port":2,"f_cnt":4377,"frm_payload":"NiwAAAAAAAA0/0E=","decoded_payload":{"ACI1_mA":"0.000", "ACI2_mA":"0.000", "AVI1_V":"13.868", "AVI2_V":"0.000", "Acount_times":null, "Count1_times":null, "Count2_times":null, "DI1_status":"L", "DI2_status":"H", "DI3_status":null, "DO1_status":"H", "DO2_status":"H", "DO3_status":null, "First_status":null, "Hardware_mode":"LT22222", "RO1_status":"OFF", "RO2_status":"OFF", "Work_mode":"2ACI+2AVI"},"rx_metadata":[{"gateway_ids":{"gateway_id":"eui-7076ff0056080b0f","eui":"7076FF0056080B0F"},"time":"2023-07-22T17:01:42.871Z","timestamp":1199555188,"rssi":-118,"channel_rssi":-118,"snr":-13.8,"uplink_token":"CiIKIAoUZXVpLTcwNzZmZjAwNTYwODBiMGYSCHB2/wBWCAsPEPSE/7sEGgsI95bwpQYQ0Mb0AyCgqr7Y9K0mKgwI9pbwpQYQwM+pnwM=","channel_index":4,"gps_time":"2023-07-22T17:01:42.871Z","received_at":"2023-07-22T17:01:42.714662309Z"}],"settings":{"data_rate":{"lora":{"bandwidth":125000, "spreading_factor":12, "coding_rate":"4/5"}}, "frequency":"867900000", "timestamp":1199555188, "time":"2023-07-22T17:01:42.871Z"},"received_at":"2023-07-22T17:01:43.009292984Z","consumed_airtime":"1.482752s","version_ids":{"brand_id":"dragino", "model_id":"lt22222-l", "hardware_version":"_unknown_hw_version_", "firmware_version":"1.5.6", "band_id":"EU_863_870"},"network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"eu1","cluster_address":"eu1.cloud.thethings.network"}}}
                  19:01:43.238	info	javascript.0 (652027) script.js.LoRAWAN_DEV_1: {'ACI1_mA':'0.000','ACI2_mA':'0.000','AVI1_V':'13.868','AVI2_V':'0.000','Acount_times':null,'Count1_times':null,'Count2_times':null,'DI1_status':'L','DI2_status':'H','DI3_status':null,'DO1_status':'H','DO2_status':'H','DO3_status':null,'First_status':null,'Hardware_mode':'LT22222','RO1_status':'OFF','RO2_status':'OFF','Work_mode':'2ACI+2AVI'}
                  
                  paul53 GregorS 2 Replies Last reply Reply Quote 0
                  • paul53
                    paul53 @GregorS last edited by paul53

                    @gregors sagte: Der Teufel steckt im Detail

                    ... und nun wurde auch der Datenpunkt "AVI1_V" mit dem Wert 13.87 gefüllt?

                    1 Reply Last reply Reply Quote 1
                    • GregorS
                      GregorS @GregorS last edited by

                      @paul53
                      @Homoran
                      @marc-berg

                      Danke für Eure Geduld und die Hilfe.
                      Jetzt funktioniert es.
                      zzzz_ok.JPG

                      GregorS 1 Reply Last reply Reply Quote 0
                      • GregorS
                        GregorS @GregorS last edited by

                        Wie kann ich denn
                        "rssi" und "time"
                        extrahieren?
                        Alle anderen Infos haben funktioniert.

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

                          @gregors sagte: "rssi" und "time"

                              const msg = JSON.parse(dp.state.val).uplink_message;
                              const payload = msg.decoded_payload;
                              const rx0 = msg.rx_metadata[0];
                          
                              log(rx0.time);
                              log(rx0.rssi);
                          
                          1 Reply Last reply Reply Quote 1
                          • GregorS
                            GregorS last edited by

                            Nachdem ich jetzt die Daten in ioBroker habe, ist mir die Nacht eine
                            zusätzliche Anwendung durch den Kopf gegangen.
                            Dazu muss ich allerdings RO1 schalten.
                            Über das Gateway habe ich bereits Erfolg gehabt, und die Rückmeldung im ioBroker aufgenommen.
                            Messaging / Downlink --> 03 00 11 Relais öffnen
                            --> 03 01 11 Relais schliessen

                            Wie kann ich das RO1 aus ioBroker schalten?

                            Marc Berg 1 Reply Last reply Reply Quote 0
                            • Marc Berg
                              Marc Berg Most Active @GregorS last edited by

                              @gregors sagte in [gelöst] Payload Daten in Objekte schreiben:

                              Nachdem ich jetzt die Daten in ioBroker habe, ist mir die Nacht eine
                              zusätzliche Anwendung durch den Kopf gegangen.
                              Dazu muss ich allerdings RO1 schalten.
                              Über das Gateway habe ich bereits Erfolg gehabt, und die Rückmeldung im ioBroker aufgenommen.
                              Messaging / Downlink --> 03 00 11 Relais öffnen
                              --> 03 01 11 Relais schliessen

                              Wie kann ich das RO1 aus ioBroker schalten?

                              Ich habe das über Node Red umgesetzt, aber den entscheidenden Teil kannst du vielleicht adaptieren.

                              So sieht ein einfacher Beispiel-Flow aus:


                              2a1008bf-5ef8-4e05-94c4-0c2f2789e4e9-grafik.png

                              Der Payload (hier "0501100200") wird in einem Function-Node verarbeitet (Base64 Kodierung + Erzeugung des Downlinks) und dann per MQTT an TTN gesendet.

                              Der Code im Function-Node sieht so aus (in 'msg.hex' steckt "0501100200"):

                              var s=msg.hex;
                              var b=Buffer.from(s, 'hex');            //Buffer erzeugen
                              s=b.toString("base64");                 //to base64
                              msg.payload=
                              {
                                  "downlinks": [{
                                    "f_port": 2,
                                    "frm_payload": s,
                                    "priority": "NORMAL"
                                  }]
                              }
                              return msg;
                              

                              Dieser so aufbereitete Payload wird dann per MQTT an folgendes Topic gesendet:

                              v3/<APPLICATION-ID>@ttn/devices/<DEVICE_ID>/down/replace
                              
                              GregorS 1 Reply Last reply Reply Quote 0
                              • GregorS
                                GregorS @Marc Berg last edited by

                                @marc-berg
                                Danke für den Denkanstoss.
                                Habe aber bisher noch keinen Erfolg gehabt.
                                Bekomme das Payload nicht gesendet.

                                Bleibe dran

                                Marc Berg 1 Reply Last reply Reply Quote 0
                                • Marc Berg
                                  Marc Berg Most Active @GregorS last edited by

                                  @gregors sagte in [gelöst] Payload Daten in Objekte schreiben:

                                  Bekomme das Payload nicht gesendet.
                                  Bleibe dran

                                  Das müsste ja dann bei dir zum Einschalten so aussehen:

                                  {
                                      "downlinks": [{
                                        "f_port": 2,
                                        "frm_payload": "AwER",
                                        "priority": "NORMAL"
                                      }]
                                  }
                                  

                                  und zum Ausschalten so:

                                  {
                                      "downlinks": [{
                                        "f_port": 2,
                                        "frm_payload": "AwAR",
                                        "priority": "NORMAL"
                                      }]
                                  }
                                  

                                  Auf welche Weise sendest du den Downlink?

                                  GregorS 1 Reply Last reply Reply Quote 0
                                  • GregorS
                                    GregorS @Marc Berg last edited by GregorS

                                    @marc-berg said in [gelöst] Payload Daten in Objekte schreiben:

                                    Auf welche Weise sendest du den Downlink?

                                    Was meinst du damit?

                                    Ich habe mehrer Versionen probiert, aber es hakt immer am "Doppelpunkt" hinter downlinks.
                                    Ich galube, da fehlt was entscheidendes.

                                    //'mqtt.2.v3.gs-mg-dragino-01@ttn.devices.eui-a840414601871305.down.sent'/*v3/gs-mg-dragino-01@ttn/devices/eui-a840414601871305/down/sent*/
                                    
                                    on('mqtt.2.v3.gs-mg-dragino-01@ttn.devices.eui-a840414601871305.down', function (dp) 
                                    {
                                      "downlinks": [{
                                        "f_port": 2,
                                        "frm_payload": "130011=",
                                        "priority": "NORMAL"
                                      }]
                                    }
                                    
                                    18:26:04.002	error	javascript.0 (681137) script.js.LoRAWAN_DEV_1_senden compile failed: at script.js.LoRAWAN_DEV_1_senden:4
                                    
                                    paul53 Marc Berg 2 Replies Last reply Reply Quote 0
                                    • paul53
                                      paul53 @GregorS last edited by paul53

                                      @gregors
                                      Du willst doch keine Daten erhalten (triggern), sondern Daten senden. Das macht man mit sendTo() oder mit setState() auf den Datenpunkt, der an das Topic "v3/gs-mg-dragino-01@ttn/devices/eui-a840414601871305/down/replace" sendet.

                                      1 Reply Last reply Reply Quote 0
                                      • Marc Berg
                                        Marc Berg Most Active @GregorS last edited by

                                        @gregors sagte in [gelöst] Payload Daten in Objekte schreiben:

                                        Auf welche Weise sendest du den Downlink?

                                        Was meinst du damit?

                                        Nun ja, man kann ja die Daten per MQTT oder per API senden. Wie ich jetzt gesehen habe, versuchst du es per MQTT. Das heißt, du hast eine MQTT Instanz erstellt und dich damit an TTN angemeldet? Funktioniert denn die Anmeldung?

                                        Zum Scripting kann ich nicht viel sagen, dazu hat sich ja @paul53 schon geäußert.

                                        Aber das hier:

                                           "frm_payload": "130011=",
                                        

                                        ist auf jeden Fall falsch Base64 kodiert. Ein guter Konverter ist z.B. der hier https://base64.guru/converter/encode/hex
                                        Wenn Du deinen Hexadezimal-Payload "03 01 11" durch den Konverter schickst, kommt "AwER" raus.

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

                                        Support us

                                        ioBroker
                                        Community Adapters
                                        Donate

                                        781
                                        Online

                                        31.9k
                                        Users

                                        80.1k
                                        Topics

                                        1.3m
                                        Posts

                                        4
                                        78
                                        3040
                                        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