Richtiger json path für Wert

Hallo Zusammen,
ich habe jetzt ewige Zeit versucht den richtigen Path für einen
value_json heraus zu bekommen, aber evtl. fehlt es mir an ausreichend Erfahrung. :sob:

auf der “obersten” Ebene den Wert auslesen klappt …
value_json.data | selectattr(‘id’,‘eq’,‘59260’) | map(attribute=‘status’)

ABER Ich möchte aber den Wert
value_json.data.??? | selectattr(‘uid’,‘eq’,‘131880’) | map(attribute=‘status’

und habe schon etliche Schreibweisen ohne Erfolg für den Pfad versucht

Kann mir jemand helfen?
Wäre super …

Wenn du den JSON-Code mal als Code/Text postest, wäre es einfacher dir zu helfen!

Moin, der Screen kommt von einer Webseite.
Mit paste & copy sieht das leider so aus …
Bin mir nicht sicher ob das besser ist …

1. {success: true, errorCode: null, messageLocalized: null, dataType: "array", data: [,…]}

  1. data: [,…]

    1. 0: {id: "59260", name: "MaLIS1_Käfertaler_Straße", status: "active", address: "Käfertaler Straße 15",…}

      1. address: "Käfertaler Straße 15"
      2. city: "Mannheim"
      3. comment: "In direkter Nähe: Neckarpromenade, VR-Bank"
      4. coordinates: {latitude: "49.495849", longitude: "8.476730"}
      5. country: "DE"
      6. directions: ""
      7. distance_in_m: "0"
      8. evses: [{uid: "131880", id: "DE*MVV*E00066*R1", status: "AVAILABLE", reservable: false,…},…]

        1. 0: {uid: "131880", id: "DE*MVV*E00066*R1", status: "AVAILABLE", reservable: false,…}

Bin mir nicht sicher ob das besser ist …

Nee, nicht wirklich :frowning:

Alternativ könnte man es auch so schreiben …

nützt das was ???

oder evtl. der link zu der Seite, wobei ich mir hier die Infos via. Chrome mit dem “Entwicklertool” ansehe

   data: [,…]
     0: {id: "59260", name: "MaLIS1_Käfertaler_Straße", status: "active", address: "Käfertaler Straße 15",…}
       evses: [{uid: "131880", id: "DE*MVV*E00066*R1", status: "AVAILABLE", reservable: false,…},…]
         0: {uid: "131880", id: "DE*MVV*E00066*R1", status: "AVAILABLE", reservable: false,…}

Habe den json Code auch gefunden:

Bei meiner Abfrage bekomme ich NUR bei
“Schafweide L1” den korrekten Wert zurück …

Für die Abfragen von " selectattr(‘uid’ … )
bekomme ich gar nichts od bei R3 “unbekannt” zurück …

Hilfe?! :cry:

Hier der Code:

{
    "success": true,
    "errorCode": null,
    "messageLocalized": null,
    "dataType": "array",
    "data": [
        {
            "id": "59260",
            "name": "MaLIS1_K\u00e4fertaler_Stra\u00dfe",
            "status": "active",
            "address": "K\u00e4fertaler Stra\u00dfe 15",
            "city": "Mannheim",
            "postal_code": "68167",
            "country": "DE",
            "directions": "",
            "comment": "In direkter N\u00e4he: Neckarpromenade, VR-Bank",
            "coordinates": {
                "latitude": "49.495849",
                "longitude": "8.476730"
            },
            "distance_in_m": "0",
            "operator": {
                "operatorId": "MVV",
                "name": "MVV Energie",
                "hotline": "+498006886880"
            },
            "opening_times": {
                "twentyfourseven": true
            },
            "owner": null,
            "roaming": false,
            "evses": [
                {
                    "uid": "131880",
                    "id": "DE*MVV*E00066*R1",
                    "status": "AVAILABLE",
                    "reservable": false,
                    "capabilities": [
                        "RFID_READER",
                        "REMOTE_START_STOP_CAPABLE"
                    ],
                    "physical_reference": "",
                    "floor_level": "",
                    "vehicle_type": "four_wheeled",
                    "chargePointPosition": null,
                    "chargePointPublicComment": null,
                    "chargePointParkingSpaceNumbers": null,
                    "chargingStationPosition": null,
                    "roaming": false,
                    "connectors": [
                        {
                            "id": "4475130",
                            "status": "AVAILABLE",
                            "standard": "IEC_62196_T2",
                            "format": "SOCKET",
                            "power_type": "AC_3_PHASE",
                            "ampere": "32",
                            "voltage": "400",
                            "max_power": 22,
                            "tariff_id": "23904ac"
                        }
                    ]
                },
                {
                    "uid": "131882",
                    "id": "DE*MVV*E00066*L1",
                    "status": "AVAILABLE",
                    "reservable": false,
                    "capabilities": [
                        "RFID_READER",
                        "REMOTE_START_STOP_CAPABLE"
                    ],
                    "physical_reference": "",
                    "floor_level": "",
                    "vehicle_type": "four_wheeled",
                    "chargePointPosition": null,
                    "chargePointPublicComment": null,
                    "chargePointParkingSpaceNumbers": null,
                    "chargingStationPosition": null,
                    "roaming": false,
                    "connectors": [
                        {
                            "id": "4475132",
                            "status": "AVAILABLE",
                            "standard": "IEC_62196_T2",
                            "format": "SOCKET",
                            "power_type": "AC_3_PHASE",
                            "ampere": "32",
                            "voltage": "400",
                            "max_power": 22,
                            "tariff_id": "23904ac"
                        }
                    ]
                }
            ],
            "tariffZones": [
                "386",
                "784",
                "1040"
            ]
        }
    ]
}

Meine Abfragen:

# MVV Integration
###################
  - resource: https://api.chargecloud.de/rest:contract/5f703068922b9c5126799addfe67cf49/getEmobilityLocationsDataDetails?offset=0&limit=100&locationId=59260
    scan_interval: 60
    headers:
      User-Agent: "Home Assistant REST sensor"
      Authorization: 'Token Y29udHJhY3QjY2VhNWFhNTY5ZjdjNTM5NjA3NjM4OWMzOGJlNmFjM2EzOWIwNzE5ZmQzNmRjNzkzNjdkYTc0MWY5NGEzOTc4NQ=='
      Origin: "https://app.emotion.mvv.de"
      Referer: "https://app.emotion.mvv.de/"
    sensor:
      - name: "Schafweide L1"
        icon: mdi:ev-plug-ccs2
        unique_id: "charger_schafweide_l1_kafertaler_strasse"
        value_template: >-
          {{ value_json.data | selectattr('id','eq','59260') | map(attribute='status') | first }}

      - name: "Schafweide R1"
        icon: mdi:ev-plug-ccs2
        unique_id: "charger_schafweide_r1"
        value_template: >-
          {{ value_json.data[0].evses[0] | selectattr('uid','eq','131880') | map(attribute='status') | first }}
          
      - name: "Schafweide R2"
        icon: mdi:ev-plug-ccs2
        unique_id: "charger_schafweide_r1_2"
        value_template: >-
          {{ value_json.data[0].evses[0].status | selectattr('uid','eq','131880') | map(attribute='status') | first }}

      - name: "Schafweide R3"
        icon: mdi:ev-plug-ccs2
        unique_id: "charger_schafweide_r1_3"
        value_template: >-
          {{ value_json[0].evses[0].status | selectattr('uid','eq','131880') | map(attribute='status') | first }}


PSS: nach 8std probieren, studieren und keiner Ahnung die Lösung doch gefunden :muscle:

Dies führte zum Erfolg:
und frag mich einer warum :rofl: :thinking:

      - name: "Schafweide R3"
        icon: mdi:ev-plug-ccs2
        unique_id: "charger_schafweide_r1_3"
        value_template: >-
          "{{ value_json['data'][0]['evses'] | selectattr('uid','eq','131880') | map(attribute='status') | first }}"