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] Steam API - JSON einlesen

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] Steam API - JSON einlesen

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

      Liebe Community,

      Ziel:
      geliefertes JSON von Steam API in Datenpunkte schreiben. (um Abhängig vom Spiel ein Scene auszulösen)

      Leider bin ich mit JSON noch nicht wirklich vertraut und komme mit meinem Blockly nicht weiter.
      JSON gibts über:

      https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=STEAM_API_KEY&format=json&steamids=STEAMID
      

      Ich habe mich nach der Anleitung von machs-smart.de versucht und scheitere kläglich

      Von Steam erhalte ich folgendes JSON:

      {
          "response": {
              "players": [
                  {
                      "steamid": "xxxxxxxxxxxxxxxxx",
                      "communityvisibilitystate": 3,
                      "profilestate": 1,
                      "personaname": "Bloop",
                      "commentpermission": 2,
                      "profileurl": "https://steamcommunity.com/id/bloop16/",
                      "avatar": "https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c.jpg",
                      "avatarmedium": "https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c_medium.jpg",
                      "avatarfull": "https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c_full.jpg",
                      "avatarhash": "ec64b177597656280c5064b41558bbbf039b342c",
                      "lastlogoff": 1679833386,
                      "personastate": 1,
                      "primaryclanid": "103582791436382048",
                      "timecreated": 1217974304,
                      "personastateflags": 0,
                      "loccountrycode": "AT",
                      "locstatecode": "08"
                  }
              ]
          }
      }
      

      Wenn ich nun in Block request ein Attribut setze erhalte ich diese nur bis response.players sobald ich dieses erweitern möchte (response.players.personaname) kommt undefined als Ergebnis

      cbef427d-04b0-4064-82ad-f35507a6a72d-image.png

      [{'steamid':'xxxxxxxxxxxxxxxxx','communityvisibilitystate':3,'profilestate':1,'personaname':'Bloop','commentpermission':2,'profileurl':'https://steamcommunity.com/id/bloop16/','avatar':'https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c.jpg','avatarmedium':'https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c_medium.jpg','avatarfull':'https://avatars.steamstatic.com/ec64b177597656280c5064b41558bbbf039b342c_full.jpg','avatarhash':'ec64b177597656280c5064b41558bbbf039b342c','lastlogoff':1679833386,'personastate':1,'primaryclanid':'103582791436382048','timecreated':1217974304,'personastateflags':0,'loccountrycode':'AT','locstatecode':'08'}]
      

      Ich denke das Problem liegt an der [ Eckigen Klammer.
      Wie kann ich in Attribut ein JSON Objekt auslesen?

      Herzlichen Dank!

      A 1 Reply Last reply Reply Quote 0
      • A
        Ahnungsbefreit @bloop last edited by

        @bloop Versuch mal
        f96cc443-9ce3-4fdf-99dc-ef80bc022c19-image.png

        denn players ist ein Array (erkennbar an der eckigen Klammer) mit nur einem Eintrag und der hat dann den Index 0

        B 1 Reply Last reply Reply Quote 1
        • B
          bloop @Ahnungsbefreit last edited by

          @ahnungsbefreit
          Hat funktioniert!
          Herzlichen Dank!

          A 1 Reply Last reply Reply Quote 0
          • A
            Ahnungsbefreit @bloop last edited by

            @bloop Dann bitte den Threat als "[Gelöst]" markieren durch Editieren der Überschrift Deines 1.Posts.

            1 Reply Last reply Reply Quote 0
            • B
              bloop last edited by

              Endergebnis:

              071ed201-a1c5-45d2-845f-1bed87572d97-image.png

              Steam dimmt mir jetzt beim zocken die Lampen auf 50% 😉

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

              Support us

              ioBroker
              Community Adapters
              Donate

              447
              Online

              32.0k
              Users

              80.4k
              Topics

              1.3m
              Posts

              2
              5
              297
              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