Home > Net >  Home Assistant - correct syntax for extracting variable
Home Assistant - correct syntax for extracting variable

Time:05-15

So I am using the SmartThings API integration for my Samsung washer and dryer, and am trying to extract the following items into sensors- remaining time kids lock

The format for the sensor.smartthings_dryer_api is as follows:

 components:
  main:
    custom.dryerWrinklePrevent:
      operatingState:
        value: ready
        timestamp: '2022-03-12T09:09:09.254Z'
      dryerWrinklePrevent:
        value: 'off'
        timestamp: '2022-03-12T09:09:09.430Z'
    samsungce.dryerDryingTemperature:
      dryingTemperature:
        value: medium
        timestamp: '2022-05-12T14:29:41.834Z'
      supportedDryingTemperature:
        value:
          - none
          - extraLow
          - low
          - mediumLow
          - medium
          - high
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.welcomeMessage:
      welcomeMessage:
        value: null
    samsungce.dryerCyclePreset:
      maxNumberOfPresets:
        value: 10
        timestamp: '2021-07-14T04:24:01.303Z'
      presets:
        value: null
    samsungce.deviceIdentification:
      micomAssayCode:
        value: '20233745'
        timestamp: '2021-07-17T18:01:23.747Z'
      modelName:
        value: null
      serialNumber:
        value: null
      serialNumberExtra:
        value: null
      modelClassificationCode:
        value: 300000010011
        timestamp: '2021-07-14T01:14:32.968Z'
      description:
        value: DA_WM_A51_20_/DC92-02
        timestamp: '2021-07-17T02:26:34.816Z'
      binaryId:
        value: DA_WM_A51_20_COMMON
        timestamp: '2021-07-14T04:17:43.540Z'
    switch:
      switch:
        value: 'off'
        timestamp: '2022-05-12T14:29:40.957Z'
    samsungce.dryerFreezePrevent:
      operatingState:
        value: null
    ocf:
      st:
        value: null
      mndt:
        value: null
      mnfv:
        value: DA_WM_A51_20_COMMON_30
        timestamp: '2021-07-14T04:23:58.420Z'
      mnhw:
        value: ARTIK051
        timestamp: '2021-07-14T04:17:42.176Z'
      di:
        value: 0c9488c1-348b
        timestamp: '2021-07-14T01:14:29.964Z'
      mnsl:
        value: http://www.samsung.com
        timestamp: '2021-10-28T23:28:25.361Z'
      dmv:
        value: res.1.1.0,sh.1.1.0
        timestamp: '2021-10-28T23:28:25.361Z'
      'n':
        value: '[dryer] Samsung'
        timestamp: '2021-07-14T01:14:29.964Z'
      mnmo:
        value: DA_WM_A51_20_COMMON|20233741|3000000
        timestamp: '2021-07-14T04:17:42.176Z'
      vid:
        value: DA-WM-WD-000001
        timestamp: '2021-07-14T01:14:29.964Z'
      mnmn:
        value: Samsung Electronics
        timestamp: '2021-07-14T01:14:29.964Z'
      mnml:
        value: http://www.samsung.com
        timestamp: '2021-07-14T01:14:29.964Z'
      mnpv:
        value: DAWIT 2.0
        timestamp: '2021-07-14T04:17:42.176Z'
      mnos:
        value: TizenRT 1.0   IPv6
        timestamp: '2021-07-14T04:17:42.176Z'
      pi:
        value: 0c9488c1-348b
        timestamp: '2021-07-14T01:14:29.964Z'
      icv:
        value: core.1.1.0
        timestamp: '2021-07-14T01:14:29.964Z'
    custom.dryerDryLevel:
      dryerDryLevel:
        value: normal
        timestamp: '2022-05-12T14:29:41.830Z'
      supportedDryerDryLevel:
        value:
          - none
          - damp
          - less
          - normal
          - more
          - very
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.dryerAutoCycleLink:
      dryerAutoCycleLink:
        value: 'off'
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.dryerCycle:
      dryerCycle:
        value: Table_00_Course_01
        timestamp: '2022-05-12T14:29:41.271Z'
      supportedCycles:
        value:
          - cycle: '01'
            supportedOptions:
              dryingLevel:
                raw: D33E
                default: normal
                options:
                  - damp
                  - less
                  - normal
                  - more
                  - very
              dryingTemperature:
                raw: '8410'
                default: medium
                options:
                  - medium
          - cycle: 9C
            supportedOptions:
              dryingLevel:
                raw: D33E
                default: normal
                options:
                  - damp
                  - less
                  - normal
                  - more
                  - very
              dryingTemperature:
                raw: '8520'
                default: high
                options:
                  - high
          - cycle: A5
            supportedOptions:
              dryingLevel:
                raw: D33E
                default: normal
                options:
                  - damp
                  - less
                  - normal
                  - more
                  - very
              dryingTemperature:
                raw: '8520'
                default: high
                options:
                  - high
          - cycle: 9E
            supportedOptions:
              dryingLevel:
                raw: D33E
                default: normal
                options:
                  - damp
                  - less
                  - normal
                  - more
                  - very
              dryingTemperature:
                raw: '8308'
                default: mediumLow
                options:
                  - mediumLow
          - cycle: 9B
            supportedOptions:
              dryingLevel:
                raw: D520
                default: very
                options:
                  - very
              dryingTemperature:
                raw: '8520'
                default: high
                options:
                  - high
          - cycle: '27'
            supportedOptions:
              dryingLevel:
                raw: D000
                options: []
              dryingTemperature:
                raw: '8520'
                default: high
                options:
                  - high
          - cycle: E5
            supportedOptions:
              dryingLevel:
                raw: D000
                options: []
              dryingTemperature:
                raw: '8000'
                options: []
          - cycle: A0
            supportedOptions:
              dryingLevel:
                raw: D000
                options: []
              dryingTemperature:
                raw: '8000'
                options: []
          - cycle: A4
            supportedOptions:
              dryingLevel:
                raw: D000
                options: []
              dryingTemperature:
                raw: 853E
                default: high
                options:
                  - extraLow
                  - low
                  - mediumLow
                  - medium
                  - high
          - cycle: A6
            supportedOptions:
              dryingLevel:
                raw: D000
                options: []
              dryingTemperature:
                raw: '8520'
                default: high
                options:
                  - high
          - cycle: A3
            supportedOptions:
              dryingLevel:
                raw: D308
                default: normal
                options:
                  - normal
              dryingTemperature:
                raw: '8410'
                default: medium
                options:
                  - medium
          - cycle: A2
            supportedOptions:
              dryingLevel:
                raw: D33E
                default: normal
                options:
                  - damp
                  - less
                  - normal
                  - more
                  - very
              dryingTemperature:
                raw: '8102'
                default: extraLow
                options:
                  - extraLow
        timestamp: '2021-07-14T01:14:32.968Z'
      referenceTable:
        value:
          id: Table_00
        timestamp: '2021-07-14T01:14:32.968Z'
    custom.disabledCapabilities:
      disabledCapabilities:
        value:
          - samsungce.dryerCyclePreset
          - samsungce.dryerFreezePrevent
          - samsungce.welcomeMessage
        timestamp: '2021-10-28T23:28:27.622Z'
    samsungce.driverVersion:
      versionNumber:
        value: 21082401
        timestamp: '2021-10-28T17:10:18.181Z'
    samsungce.kidsLock:
      lockState:
        value: unlocked
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.detergentOrder:
      alarmEnabled:
        value: false
        timestamp: '2021-07-14T01:14:32.968Z'
      orderThreshold:
        value: 0
        unit: cc
        timestamp: '2021-07-14T01:14:32.968Z'
    powerConsumptionReport:
      powerConsumption:
        value:
          energy: 1841800
          deltaEnergy: 0
          power: 0
          powerEnergy: 0
          persistedEnergy: 0
          energySaved: 0
          start: '2022-05-12T14:24:29Z'
          end: '2022-05-12T14:29:13Z'
        timestamp: '2022-05-12T14:29:13.497Z'
    dryerOperatingState:
      completionTime:
        value: '2022-05-12T15:44:42Z'
        timestamp: '2022-05-12T14:29:42.244Z'
      machineState:
        value: stop
        timestamp: '2022-05-12T14:29:41.386Z'
      supportedMachineStates:
        value: null
      dryerJobState:
        value: none
        timestamp: '2022-05-12T14:29:41.395Z'
    samsungce.detergentState:
      remainingAmount:
        value: 0
        unit: cc
        timestamp: '2021-07-14T01:14:32.968Z'
      dosage:
        value: 0
        unit: cc
        timestamp: '2021-07-14T01:14:32.968Z'
      initialAmount:
        value: 0
        unit: cc
        timestamp: '2021-07-14T01:14:32.968Z'
      detergentType:
        value: none
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.dryerDelayEnd:
      remainingTime:
        value: 0
        unit: min
        timestamp: '2021-10-28T17:10:18.497Z'
    refresh: {}
    custom.jobBeginningStatus:
      jobBeginningStatus:
        value: null
    execute:
      data:
        value:
          payload:
            rt:
              - x.com.samsung.da.operation
            if:
              - oic.if.baseline
              - oic.if.a
            x.com.samsung.da.state: Ready
            x.com.samsung.da.remainingTime: '01:15:00'
            x.com.samsung.da.progressPercentage: '1'
            x.com.samsung.da.progress: None
            x.com.samsung.da.delayEndTime: '00:00:00'
            x.com.samsung.da.supportedProgress:
              - None
              - Drying
              - Cooling
              - Finish
        data:
          href: /operational/state/vs/0
        timestamp: '2022-05-12T14:29:42.244Z'
    remoteControlStatus:
      remoteControlEnabled:
        value: 'false'
        timestamp: '2021-07-14T01:18:09.064Z'
    custom.supportedOptions:
      referenceTable:
        value:
          id: Table_00
        timestamp: '2021-07-14T01:14:32.968Z'
      supportedCourses:
        value:
          - '01'
          - 9C
          - A5
          - 9E
          - 9B
          - '27'
          - E5
          - A0
          - A4
          - A6
          - A3
          - A2
        timestamp: '2021-07-14T01:14:32.968Z'
    samsungce.dryerDryingTime:
      supportedDryingTime:
        value:
          - '0'
          - '20'
          - '30'
          - '40'
          - '50'
          - '60'
        timestamp: '2021-07-14T01:14:32.968Z'
      dryingTime:
        value: '0'
        unit: min
        timestamp: '2022-05-12T14:29:42.043Z'
friendly_name: SmartThings dryer API

I have tried every variation of state_attr I can think of to get the values, but nothing works. Also I need to just extract the 'minutes' and 'hours' portion of the remaining time and convert it to straight minutes remaining.

The path to the variables is as follows:

components:
 main:
  execute:
   data:
    value:
     payload:
      if: (?????)
       x.com.samsung.da.remainingTime: '01:15:00'        (need just hour and minutes as total minutes)

and

components:
 main:
  samsungce.kidsLock:
   lockState:
    value: unlocked

CodePudding user response:

{{ state_attr('sensor.smartthings_dryer_api', 'components').main.execute.data.value.payload['x.com.samsung.da.remainingTime'] }}

{{ state_attr('sensor.smartthings_dryer_api', 'components').main['samsungce.kidsLock'].lockState.value }}

  • Related