Help needed: Create a Sensor from Binary Sensor Attributes

Hello everyone.

I want to create a sensor.
The data is in the attributes of a binary sensor.

vehicle_data:
  vehicleStatus:
    evStatus:
      batteryCharge: false
      batteryStatus: 71
      batteryPlugin: 0
      remainTime2:
        etc1:
          value: 17
          unit: 1
        etc2:
          value: 650
          unit: 1
        etc3:
          value: 160
          unit: 1
        atc:
          value: 1
          unit: 1
      drvDistance:
        - rangeByFuel:
            evModeRange:
              value: 317
              unit: 1
            totalAvailableRange:
              value: 317
              unit: 1
          type: 2
      reservChargeInfos:
        reservChargeInfo:
          reservChargeInfoDetail:
            reservInfo:
              day:
                - 5
              time:
                time: '0200'
                timeSection: 1
            reservChargeSet: true
            reservFatcSet:
              defrost: false
              airTemp:
                value: 00H
                unit: 0
              airCtrl: 0
              heating1: 0
        offpeakPowerInfo:
          offPeakPowerTime1:
            starttime:
              time: '1200'
              timeSection: 0
            endtime:
              time: '1200'
              timeSection: 0
          offPeakPowerFlag: 0
        reserveChargeInfo2:
          reservChargeInfoDetail:
            reservInfo:
              day:
                - 5
              time:
                time: '1200'
                timeSection: 0
            reservChargeSet: false
            reservFatcSet:
              defrost: false
              airTemp:
                value: 00H
                unit: 0
              airCtrl: 0
              heating1: 0
        reservFlag: 0
        ect:
          start:
            day: 9
            time:
              time: '1200'
              timeSection: 0
          end:
            day: 9
            time:
              time: '1200'
              timeSection: 0
        targetSOClist:
          - targetSOClevel: 100
            dte:
              rangeByFuel:
                evModeRange:
                  value: 460
                  unit: 1
                totalAvailableRange:
                  value: 460
                  unit: 1
              type: 2
            plugType: 1
          - targetSOClevel: 80
            dte:
              rangeByFuel:
                evModeRange:
                  value: 359
                  unit: 1
                totalAvailableRange:
                  value: 359
                  unit: 1
              type: 2
            plugType: 0
    ign3: true
    hoodOpen: false
    transCond: true
    steerWheelHeat: 2
    sideBackWindowHeat: 0
    tirePressureLamp:
      tirePressureLampAll: 0
      tirePressureLampFL: 0
      tirePressureLampFR: 0
      tirePressureLampRL: 0
      tirePressureLampRR: 0
    battery:
      batSoc: 88
      batState: 0
    sleepModeCheck: false
    time: '20220314082801'
    remoteWaitingTimeAlert:
      remoteControlAvailable: 1
      remoteControlWaitingTime: 168
      elapsedTime: '02:13:35'
    systemCutOffAlert: 0
    tailLampStatus: 0
    hazardStatus: 0
  odometer:
    value: 9957.6
    unit: 1
vehicle_name: E-NIRO
friendly_name: E-NIRO Data

The sensor should display the following value from the attributes:

Value 460 from first targetSOClevel:

   targetSOClist:
      - targetSOClevel: 100
        dte:
          rangeByFuel:
            evModeRange:
              **value: 460**
              unit: 1
            totalAvailableRange:
              value: 460
              unit: 1
          type: 2
        plugType: 1
      - targetSOClevel: 80
        dte:
          rangeByFuel:
            evModeRange:
              **value: 359**
              unit: 1
            totalAvailableRange:
              value: 359
              unit: 1
          type: 2
        plugType: 0

Thx in advance !

I think :

{{ state_attr('sensor.name', 'vehicle_data')['vehicleStatus']['evStatus']['targetSOClist'][0]['dte']['rangeByFuel']['evModeRange']['value'] }}
1 Like

Should be ['dte']

1 Like

Dang it! The only part i didn’t copy paste.
See what that did!

Back to copy pasting all my answers from now on.

Thanks :slight_smile:

Thx so much, following is working now:

{{ state_attr(‘binary_sensor.e_niro_data’, ‘vehicle_data’)[‘vehicleStatus’][‘evStatus’][‘reservChargeInfos’][‘targetSOClist’][0][‘dte’][‘rangeByFuel’][‘evModeRange’][‘value’] }}

I added [‘reservChargeInfos’]

without that, i got that error: