Restful sensor config

Trying to load data from the samsung api to a sensor to display the current running state of the dishwasher. Which is in machineState.value
json sample -

{
    "completionTime": {
        "value": "2023-05-28T00:30:50Z",
        "timestamp": "2023-05-27T22:34:50.241Z"
    },
    "machineState": {
        "value": "run",
        "timestamp": "2023-05-27T22:22:30.599Z"
    },
    "supportedMachineStates": {
        "value": null
    },
    "dishwasherJobState": {
        "value": "drying",
        "timestamp": "2023-05-28T00:00:06.433Z"
    }
}

Current attempt in configuration.yaml

sensor:
  - platform: rest
    resource: https://api.smartthings.com/v1/devices/xxx/components/main/capabilities/dishwasherOperatingState/status
    headers:
      Authorization: !secret samsung-sm
    name: dishwasher_status
    value_template: '{{value_json[1].machineState.value}}'
    json_attributes:
      - "machineState"

This doesn’t show the sensor at all and there is no errors in the log. Every other combo I have tried ends in errors. Any suggestions to point me in the right direction? Thanks

value_template: "{{ value_json.machineState['value'] }}"

The sample data you provided does not contain a list so l have removed the [1].

There’s also an issue with using the word value in a value template. It is a reserved word like value_json though instead of returning json data it returns the entire raw data. So you have to use square bracket notation to access a key called value.

ah Genius! Thank you, that works.

This is slightly unrelated, but how can I add 1 sensor each from 2 different devices? I want the machineState from the washer and the dryer. I created the sensor for the washer, and it worked, so I copied it and changed the values to the dryer. This resulted in the washer sensor disappearing and the dryer sensor returning ‘unknown’ as value.