Json with Timestamps

Sorry if this is not filed correctly.
And thanks in advance for helping.

I use the rest sensor.
I got a json-response which basically looks like this:

{
  "OriginResponseTimeChart":
    {
      "2022-03-11T00:00:00Z":1,
      "2022-03-10T00:00:00Z":2,
      "2022-03-09T00:00:00Z":3
    }
}

So no arrays. Just items. But a Json-Timestamp as a attribute-key.
So I need to specify the actual timestamp under “json_attributes” and i don’t know how to do that dynamically. Even hardcoding the timestamp does not really work:

sensor:
  - platform: rest
    name: rt
    resource: https://example.com/json
    headers:
      Accept: application/json
    json_attributes_path: "$['OriginResponseTimeChart']"
    json_attributes:
      - 2022-03-11T00:00:00Z
    value_template: "ok"

Please check the rest documentation
If you would have nester items then you would use the path to go to their parent and use the attributes to the details.
For what I can judge, you only need to set json_attributes to OriginResponseTimeChart, I cannot see a multi-level path in your data-example

{
  "base": USD,
  "date": "2018-02-13",
  "rates": {
     "CAD": 1.260046,
     "CHF": 0.933058,
     "EUR": 0.806942,
     "GBP": 0.719154,
     [170 world currencies]
  }
}   

For this I have

...
path: "$.rates"
attribs: 
  - CHF
  - GBP
...

Yes. This works if you know the name of the attribute and if it is static. But my timestamps change daily. So i can’t write

json_attributes:
  - "2022-03-11T00:00:00Z"

Ah…my eyes, I missed the part that each stamp has an additional value. I would then add a template sensor that deconstructs the result of this sensor

No Problem. I now use a value-template as you suggested. This works. But it would be nice to have a possibility to parameterize the json-attributes somehow.

Yep… same feeling here, I have a couple of REST templates that I need to deconstruct as they provide multiple attribs and running them separately would bump into the limitations of calls/day

Is it always today’s value you want?

Yes. I do.

I think you can create a template sensor to get the vale from your current sensor.
Looking at this:

I think something like:

sensor:
  - platform: template
    sensors:
      rt2:
        friendly_name: "rt2"
        value_template: "{{ states_attr('sensor.rt', 'OriginResponseTimeChart')[states('sensor.date') ~ 'T00:00:00Z'] }}"

Might work

Depending on what your sensor currently is the 'OriginResponseTimeChart' might not be needed

that requires the sensor.date platform. This will replace your current sensor with the least amount of code.

When you don’t have a value for today, the sensor will be unavailable.

sensor:
  - platform: rest
    name: rt
    resource: https://example.com/json
    headers:
      Accept: application/json
    value_template: >
      {{ value_json.OriginResponseTimeChart.get(now().date()  ~ 'T00:00:00Z', none) }}
    json_attributes:
      - OriginResponseTimeChart

Man. You’re a legend. This is it.