Attributes - Second Level - Sensor Template - HELP

Hello.

I have tried to search for solutions to get my attribute sensor working.
but I really can’t get the value I want.

Frist of all I use the eForsyning integration from HACS.

Here is the sensor list with attributes:

and I have marked the attribute I need to be shown.

Here is my template sensor:

- sensor:
  - name: "Heat Price Actual Year"
    state:  '{{ states.sensor.eforsyning_amount_remaining.attributes["data"][1] }}'

if I do like this:

- sensor:
  - name: "Heat Price Actual Year"
    state:  '{{ states.sensor.eforsyning_amount_remaining.attributes["data"] }}'

I get the whole list from the “data”:

can anyone here help me ?

It’s json data not a list. Try this:

- sensor:
  - name: "Heat Price Actual Year"
    state:  "{{ state_attr('sensor.eforsyning_amount_remaining', 'data').MWh-Price }}"

Thank you tom_l.

but I have tried this once.

sensor:
  - name: "Heat Price Actual Year"
    state:  "{{ state_attr('sensor.eforsyning_amount_remaining', 'data').MWh-Price }}"

but it makes it make the sensor: unknown

What about:

sensor:
  - name: "Heat Price Actual Year"
    state:  "{{ (state_attr('sensor.eforsyning_amount_remaining', 'data')|from_json).MWh-Price }}"

still get same unavailable.
i do really not get why I can’t get the value, I think it should be possible as it is a attribute.

No one here can help me out ?

Somebody already a solution? I have the same issue…

I wonder if it is the dash that is mucking things up. Try this:

- sensor:
  - name: "Heat Price Actual Year"
    state:  "{{ state_attr('sensor.eforsyning_amount_remaining', 'data')['MWh-Price'] }}"

For me it worked like this:
state: “{{ state_attr(‘sensor.eforsyning_amount_remaining’, ‘data’)[0].MWh-Price }}”

Ah. there’s a list in there.

I wish the Dev Tools would not hide that.