Need help to store JSON data in sensor attribute

Hi,
I’m using the ENTSOE api to retrieve quarter-hour electricity spot prices.
I need to make some calculations on the data to control electrical consumers.
The API returns an XML which automatically converts to JSON in HA. Got this working.
The challenge I’m facing is to extract the 96 day-prices and store them as a list in a rest sensor attribute. Assume I need an attribute because the length of the list is more than 256 characters.
This is the sensor code with which I’m able to extract the first price. But how can i loop through the prices and build a comma separated list to store as an attribute?

sensor:
     - name: "Epex Data"
       value_template: "OK"
       json_attributes_path: "$.Publication_MarketDocument.TimeSeries.Period.Point[0]"
        json_attributes:
           - "price.amount"

JSON (copy of converted xml api response in debug log file):

{"Publication_MarketDocument":{"@xmlns":"urn:iec62325.351:tc57wg16:451-3:publicationdocument:7:3","mRID":"dae2f041ff794b7689897de2df78b68e","revisionNumber":"1","type":"A44","sender_MarketParticipant.mRID":{"@codingScheme":"A01","#text":"10X1001A1001A450"},"sender_MarketParticipant.marketRole.type":"A32","receiver_MarketParticipant.mRID":{"@codingScheme":"A01","#text":"10X1001A1001A450"},"receiver_MarketParticipant.marketRole.type":"A33","createdDateTime":"2025-10-24T07:01:41Z","period.timeInterval":{"start":"2025-10-22T22:00Z","end":"2025-10-23T22:00Z"},"TimeSeries":{"mRID":"1","auction.type":"A01","businessType":"A62","in_Domain.mRID":{"@codingScheme":"A01","#text":"10YBE----------2"},"out_Domain.mRID":{"@codingScheme":"A01","#text":"10YBE----------2"},"contract_MarketAgreement.type":"A01","currency_Unit.name":"EUR","price_Measure_Unit.name":"MWH","curveType":"A03","Period":{"timeInterval":{"start":"2025-10-22T22:00Z","end":"2025-10-23T22:00Z"},"resolution":"PT15M","Point":[{"position":"1","price.amount":"85.64"},{"position":"2","price.amount":"89.99"},{"position":"3","price.amount":"77.26"},{"position":"4","price.amount":"65.36"},{"position":"5","price.amount":"75.51"},{"position":"6","price.amount":"73.47"},{"position":"7","price.amount":"66.34"},{"position":"8","price.amount":"63.62"},{"position":"9","price.amount":"60.82"},{"position":"10","price.amount":"60.16"},{"position":"11","price.amount":"62.1"},{"position":"12","price.amount":"60.38"},{"position":"13","price.amount":"65.29"},{"position":"14","price.amount":"61.05"},{"position":"15","price.amount":"51.68"},{"position":"16","price.amount":"44.67"},{"position":"17","price.amount":"54.95"},{"position":"18","price.amount":"50.86"},{"position":"19","price.amount":"49.39"},{"position":"20","price.amount":"47.57"},{"position":"21","price.amount":"47.07"},{"position":"22","price.amount":"47.33"},{"position":"23","price.amount":"47.79"},{"position":"24","price.amount":"48.2"},{"position":"25","price.amount":"22.32"},{"position":"26","price.amount":"26.28"},{"position":"27","price.amount":"27.09"},{"position":"28","price.amount":"30.85"},{"position":"29","price.amount":"31.41"},{"position":"30","price.amount":"38.07"},{"position":"31","price.amount":"43.93"},{"position":"32","price.amount":"45.71"},{"position":"33","price.amount":"57.32"},{"position":"34","price.amount":"70"},{"position":"35","price.amount":"73.91"},{"position":"36","price.amount":"62.71"},{"position":"37","price.amount":"88.1"},{"position":"38","price.amount":"72.74"},{"position":"39","price.amount":"70.05"},{"position":"40","price.amount":"57.29"},{"position":"41","price.amount":"77.63"},{"position":"42","price.amount":"68.43"},{"position":"43","price.amount":"56.8"},{"position":"44","price.amount":"50.39"},{"position":"45","price.amount":"61.24"},{"position":"46","price.amount":"54.58"},{"position":"47","price.amount":"52.57"},{"position":"48","price.amount":"50.45"},{"position":"49","price.amount":"51.7"},{"position":"50","price.amount":"49.58"},{"position":"51","price.amount":"49.99"},{"position":"52","price.amount":"48.94"},{"position":"53","price.amount":"50.09"},{"position":"54","price.amount":"48.61"},{"position":"55","price.amount":"48.29"},{"position":"56","price.amount":"47.81"},{"position":"57","price.amount":"44.58"},{"position":"58","price.amount":"47.8"},{"position":"59","price.amount":"48.78"},{"position":"60","price.amount":"50.42"},{"position":"61","price.amount":"49.21"},{"position":"62","price.amount":"51.59"},{"position":"63","price.amount":"60.88"},{"position":"64","price.amount":"77.93"},{"position":"65","price.amount":"55.74"},{"position":"66","price.amount":"60.06"},{"position":"67","price.amount":"71.05"},{"position":"68","price.amount":"83.31"},{"position":"69","price.amount":"62.71"},{"position":"70","price.amount":"76.64"},{"position":"71","price.amount":"83.44"},{"position":"72","price.amount":"105.98"},{"position":"73","price.amount":"85.31"},{"position":"74","price.amount":"90.48"},{"position":"75","price.amount":"101.8"},{"position":"76","price.amount":"104.16"},{"position":"77","price.amount":"115.21"},{"position":"78","price.amount":"107.85"},{"position":"79","price.amount":"95.72"},{"position":"80","price.amount":"80.63"},{"position":"81","price.amount":"104.71"},{"position":"82","price.amount":"77.18"},{"position":"83","price.amount":"74.34"},{"position":"84","price.amount":"62.31"},{"position":"85","price.amount":"80.05"},{"position":"86","price.amount":"75.13"},{"position":"87","price.amount":"67.19"},{"position":"88","price.amount":"59.44"},{"position":"89","price.amount":"80"},{"position":"90","price.amount":"66.35"},{"position":"91","price.amount":"67.02"},{"position":"92","price.amount":"61.1"},{"position":"93","price.amount":"57.2"},{"position":"94","price.amount":"49.31"},{"position":"95","price.amount":"49.3"},{"position":"96","price.amount":"43.52"}]}}}}

Help and advice very much appreciated!

JSON beautifiers are great…

{
  "Publication_MarketDocument": {
    "@xmlns": "urn:iec62325.351:tc57wg16:451-3:publicationdocument:7:3",
    "mRID": "dae2f041ff794b7689897de2df78b68e",
    "revisionNumber": "1",
    "type": "A44",
    "sender_MarketParticipant.mRID": {
      "@codingScheme": "A01",
      "#text": "10X1001A1001A450"
    },
    "sender_MarketParticipant.marketRole.type": "A32",
    "receiver_MarketParticipant.mRID": {
      "@codingScheme": "A01",
      "#text": "10X1001A1001A450"
    },
    "receiver_MarketParticipant.marketRole.type": "A33",
    "createdDateTime": "2025-10-24T07:01:41Z",
    "period.timeInterval": {
      "start": "2025-10-22T22:00Z",
      "end": "2025-10-23T22:00Z"
    },
    "TimeSeries": {
      "mRID": "1",
      "auction.type": "A01",
      "businessType": "A62",
      "in_Domain.mRID": {
        "@codingScheme": "A01",
        "#text": "10YBE----------2"
      },
      "out_Domain.mRID": {
        "@codingScheme": "A01",
        "#text": "10YBE----------2"
      },
      "contract_MarketAgreement.type": "A01",
      "currency_Unit.name": "EUR",
      "price_Measure_Unit.name": "MWH",
      "curveType": "A03",
      "Period": {
        "timeInterval": {
          "start": "2025-10-22T22:00Z",
          "end": "2025-10-23T22:00Z"
        },
        "resolution": "PT15M",
        "Point": [
          {
            "position": "1",
            "price.amount": "85.64"
          },
          {
            "position": "2",
            "price.amount": "89.99"
          },
          {
            "position": "3",
            "price.amount": "77.26"
          },
          {
            "position": "4",
            "price.amount": "65.36"
          },
          {
            "position": "5",
            "price.amount": "75.51"
          },
          {
            "position": "6",
            "price.amount": "73.47"
          },
          {
            "position": "7",
            "price.amount": "66.34"
          },
          {
            "position": "8",
            "price.amount": "63.62"
          },
          {
            "position": "9",
            "price.amount": "60.82"
          },
          {
            "position": "10",
            "price.amount": "60.16"
          },
          {
            "position": "11",
            "price.amount": "62.1"
          },
          {
            "position": "12",
            "price.amount": "60.38"
          },
          {
            "position": "13",
            "price.amount": "65.29"
          },
          {
            "position": "14",
            "price.amount": "61.05"
          },
          {
            "position": "15",
            "price.amount": "51.68"
          },
          {
            "position": "16",
            "price.amount": "44.67"
          },
          {
            "position": "17",
            "price.amount": "54.95"
          },
          {
            "position": "18",
            "price.amount": "50.86"
          },
          {
            "position": "19",
            "price.amount": "49.39"
          },
          {
            "position": "20",
            "price.amount": "47.57"
          },
          {
            "position": "21",
            "price.amount": "47.07"
          },
          {
            "position": "22",
            "price.amount": "47.33"
          },
          {
            "position": "23",
            "price.amount": "47.79"
          },
          {
            "position": "24",
            "price.amount": "48.2"
          },
          {
            "position": "25",
            "price.amount": "22.32"
          },
          {
            "position": "26",
            "price.amount": "26.28"
          },
          {
            "position": "27",
            "price.amount": "27.09"
          },
          {
            "position": "28",
            "price.amount": "30.85"
          },
          {
            "position": "29",
            "price.amount": "31.41"
          },
          {
            "position": "30",
            "price.amount": "38.07"
          },
          {
            "position": "31",
            "price.amount": "43.93"
          },
          {
            "position": "32",
            "price.amount": "45.71"
          },
          {
            "position": "33",
            "price.amount": "57.32"
          },
          {
            "position": "34",
            "price.amount": "70"
          },
          {
            "position": "35",
            "price.amount": "73.91"
          },
          {
            "position": "36",
            "price.amount": "62.71"
          },
          {
            "position": "37",
            "price.amount": "88.1"
          },
          {
            "position": "38",
            "price.amount": "72.74"
          },
          {
            "position": "39",
            "price.amount": "70.05"
          },
          {
            "position": "40",
            "price.amount": "57.29"
          },
          {
            "position": "41",
            "price.amount": "77.63"
          },
          {
            "position": "42",
            "price.amount": "68.43"
          },
          {
            "position": "43",
            "price.amount": "56.8"
          },
          {
            "position": "44",
            "price.amount": "50.39"
          },
          {
            "position": "45",
            "price.amount": "61.24"
          },
          {
            "position": "46",
            "price.amount": "54.58"
          },
          {
            "position": "47",
            "price.amount": "52.57"
          },
          {
            "position": "48",
            "price.amount": "50.45"
          },
          {
            "position": "49",
            "price.amount": "51.7"
          },
          {
            "position": "50",
            "price.amount": "49.58"
          },
          {
            "position": "51",
            "price.amount": "49.99"
          },
          {
            "position": "52",
            "price.amount": "48.94"
          },
          {
            "position": "53",
            "price.amount": "50.09"
          },
          {
            "position": "54",
            "price.amount": "48.61"
          },
          {
            "position": "55",
            "price.amount": "48.29"
          },
          {
            "position": "56",
            "price.amount": "47.81"
          },
          {
            "position": "57",
            "price.amount": "44.58"
          },
          {
            "position": "58",
            "price.amount": "47.8"
          },
          {
            "position": "59",
            "price.amount": "48.78"
          },
          {
            "position": "60",
            "price.amount": "50.42"
          },
          {
            "position": "61",
            "price.amount": "49.21"
          },
          {
            "position": "62",
            "price.amount": "51.59"
          },
          {
            "position": "63",
            "price.amount": "60.88"
          },
          {
            "position": "64",
            "price.amount": "77.93"
          },
          {
            "position": "65",
            "price.amount": "55.74"
          },
          {
            "position": "66",
            "price.amount": "60.06"
          },
          {
            "position": "67",
            "price.amount": "71.05"
          },
          {
            "position": "68",
            "price.amount": "83.31"
          },
          {
            "position": "69",
            "price.amount": "62.71"
          },
          {
            "position": "70",
            "price.amount": "76.64"
          },
          {
            "position": "71",
            "price.amount": "83.44"
          },
          {
            "position": "72",
            "price.amount": "105.98"
          },
          {
            "position": "73",
            "price.amount": "85.31"
          },
          {
            "position": "74",
            "price.amount": "90.48"
          },
          {
            "position": "75",
            "price.amount": "101.8"
          },
          {
            "position": "76",
            "price.amount": "104.16"
          },
          {
            "position": "77",
            "price.amount": "115.21"
          },
          {
            "position": "78",
            "price.amount": "107.85"
          },
          {
            "position": "79",
            "price.amount": "95.72"
          },
          {
            "position": "80",
            "price.amount": "80.63"
          },
          {
            "position": "81",
            "price.amount": "104.71"
          },
          {
            "position": "82",
            "price.amount": "77.18"
          },
          {
            "position": "83",
            "price.amount": "74.34"
          },
          {
            "position": "84",
            "price.amount": "62.31"
          },
          {
            "position": "85",
            "price.amount": "80.05"
          },
          {
            "position": "86",
            "price.amount": "75.13"
          },
          {
            "position": "87",
            "price.amount": "67.19"
          },
          {
            "position": "88",
            "price.amount": "59.44"
          },
          {
            "position": "89",
            "price.amount": "80"
          },
          {
            "position": "90",
            "price.amount": "66.35"
          },
          {
            "position": "91",
            "price.amount": "67.02"
          },
          {
            "position": "92",
            "price.amount": "61.1"
          },
          {
            "position": "93",
            "price.amount": "57.2"
          },
          {
            "position": "94",
            "price.amount": "49.31"
          },
          {
            "position": "95",
            "price.amount": "49.3"
          },
          {
            "position": "96",
            "price.amount": "43.52"
          }
        ]
      }
    }
  }
}

I believe you want this:

     - name: "Epex Data"
       value_template: "OK"
       json_attributes:
         - "Publication_MarketDocument.TimeSeries.Period.Point"

I’m a bit unsure about the indentations since your code is indented incorrectly but I guess this is correct.
And this should give you a list of the values

        [
          {
            "position": "1",
            "price.amount": "85.64"
          },
          {
            "position": "2",
            "price.amount": "89.99"
          },
          {
            "position": "3",
            "price.amount": "77.26"
          },
          {
            "position": "4",
            "price.amount": "65.36"
          },
          {
            "position": "5",
            "price.amount": "75.51"
          },
          {
            "position": "6",
            "price.amount": "73.47"
          },
          {
            "position": "7",
            "price.amount": "66.34"
          },
          {
            "position": "8",
            "price.amount": "63.62"
          },
          {
            "position": "9",
            "price.amount": "60.82"
          },
          {
            "position": "10",
            "price.amount": "60.16"
          },
          {
            "position": "11",
            "price.amount": "62.1"
          },
          {
            "position": "12",
            "price.amount": "60.38"
          },
          {
            "position": "13",
            "price.amount": "65.29"
          },
          {
            "position": "14",
            "price.amount": "61.05"
          },
          {
            "position": "15",
            "price.amount": "51.68"
          },
          {
            "position": "16",
            "price.amount": "44.67"
          },
          {
            "position": "17",
            "price.amount": "54.95"
          },
          {
            "position": "18",
            "price.amount": "50.86"
          },
          {
            "position": "19",
            "price.amount": "49.39"
          },
          {
            "position": "20",
            "price.amount": "47.57"
          },
          {
            "position": "21",
            "price.amount": "47.07"
          },
          {
            "position": "22",
            "price.amount": "47.33"
          },
          {
            "position": "23",
            "price.amount": "47.79"
          },
          {
            "position": "24",
            "price.amount": "48.2"
          },
          {
            "position": "25",
            "price.amount": "22.32"
          },
          {
            "position": "26",
            "price.amount": "26.28"
          },
          {
            "position": "27",
            "price.amount": "27.09"
          },
          {
            "position": "28",
            "price.amount": "30.85"
          },
          {
            "position": "29",
            "price.amount": "31.41"
          },
          {
            "position": "30",
            "price.amount": "38.07"
          },
          {
            "position": "31",
            "price.amount": "43.93"
          },
          {
            "position": "32",
            "price.amount": "45.71"
          },
          {
            "position": "33",
            "price.amount": "57.32"
          },
          {
            "position": "34",
            "price.amount": "70"
          },
          {
            "position": "35",
            "price.amount": "73.91"
          },
          {
            "position": "36",
            "price.amount": "62.71"
          },
          {
            "position": "37",
            "price.amount": "88.1"
          },
          {
            "position": "38",
            "price.amount": "72.74"
          },
          {
            "position": "39",
            "price.amount": "70.05"
          },
          {
            "position": "40",
            "price.amount": "57.29"
          },
          {
            "position": "41",
            "price.amount": "77.63"
          },
          {
            "position": "42",
            "price.amount": "68.43"
          },
          {
            "position": "43",
            "price.amount": "56.8"
          },
          {
            "position": "44",
            "price.amount": "50.39"
          },
          {
            "position": "45",
            "price.amount": "61.24"
          },
          {
            "position": "46",
            "price.amount": "54.58"
          },
          {
            "position": "47",
            "price.amount": "52.57"
          },
          {
            "position": "48",
            "price.amount": "50.45"
          },
          {
            "position": "49",
            "price.amount": "51.7"
          },
          {
            "position": "50",
            "price.amount": "49.58"
          },
          {
            "position": "51",
            "price.amount": "49.99"
          },
          {
            "position": "52",
            "price.amount": "48.94"
          },
          {
            "position": "53",
            "price.amount": "50.09"
          },
          {
            "position": "54",
            "price.amount": "48.61"
          },
          {
            "position": "55",
            "price.amount": "48.29"
          },
          {
            "position": "56",
            "price.amount": "47.81"
          },
          {
            "position": "57",
            "price.amount": "44.58"
          },
          {
            "position": "58",
            "price.amount": "47.8"
          },
          {
            "position": "59",
            "price.amount": "48.78"
          },
          {
            "position": "60",
            "price.amount": "50.42"
          },
          {
            "position": "61",
            "price.amount": "49.21"
          },
          {
            "position": "62",
            "price.amount": "51.59"
          },
          {
            "position": "63",
            "price.amount": "60.88"
          },
          {
            "position": "64",
            "price.amount": "77.93"
          },
          {
            "position": "65",
            "price.amount": "55.74"
          },
          {
            "position": "66",
            "price.amount": "60.06"
          },
          {
            "position": "67",
            "price.amount": "71.05"
          },
          {
            "position": "68",
            "price.amount": "83.31"
          },
          {
            "position": "69",
            "price.amount": "62.71"
          },
          {
            "position": "70",
            "price.amount": "76.64"
          },
          {
            "position": "71",
            "price.amount": "83.44"
          },
          {
            "position": "72",
            "price.amount": "105.98"
          },
          {
            "position": "73",
            "price.amount": "85.31"
          },
          {
            "position": "74",
            "price.amount": "90.48"
          },
          {
            "position": "75",
            "price.amount": "101.8"
          },
          {
            "position": "76",
            "price.amount": "104.16"
          },
          {
            "position": "77",
            "price.amount": "115.21"
          },
          {
            "position": "78",
            "price.amount": "107.85"
          },
          {
            "position": "79",
            "price.amount": "95.72"
          },
          {
            "position": "80",
            "price.amount": "80.63"
          },
          {
            "position": "81",
            "price.amount": "104.71"
          },
          {
            "position": "82",
            "price.amount": "77.18"
          },
          {
            "position": "83",
            "price.amount": "74.34"
          },
          {
            "position": "84",
            "price.amount": "62.31"
          },
          {
            "position": "85",
            "price.amount": "80.05"
          },
          {
            "position": "86",
            "price.amount": "75.13"
          },
          {
            "position": "87",
            "price.amount": "67.19"
          },
          {
            "position": "88",
            "price.amount": "59.44"
          },
          {
            "position": "89",
            "price.amount": "80"
          },
          {
            "position": "90",
            "price.amount": "66.35"
          },
          {
            "position": "91",
            "price.amount": "67.02"
          },
          {
            "position": "92",
            "price.amount": "61.1"
          },
          {
            "position": "93",
            "price.amount": "57.2"
          },
          {
            "position": "94",
            "price.amount": "49.31"
          },
          {
            "position": "95",
            "price.amount": "49.3"
          },
          {
            "position": "96",
            "price.amount": "43.52"
          }
        ]

Is there any reason you want it comma separated and not in a list?
Seems very inconvenient

Your json_attributes_path is correct and the key you are using in json_attributes is correct. However you have an incorrect indent that should be fixed. Remove 1 space before json_attributes

What you have is not correct for the sensor platform. You need to use the rest integration format or the legacy sensor format. Here is the rest format.

rest:
- resource: ...
  sensor:
     - name: "Epex Data"
       value_template: "OK"
       json_attributes_path: "$.Publication_MarketDocument.TimeSeries.Period.Point[0]"
       json_attributes:
         - "price.amount"

Lastly, if are using the rest format but you omitted in your post, your json_attributes are not at the correct indentation level.

  sensor:
     - name: "Epex Data"
       value_template: "OK"
       json_attributes_path: "$.Publication_MarketDocument.TimeSeries.Period.Point[0]"
       json_attributes:
         - "price.amount"

@Hellis81
Hi,

Thank you for your swift reply to my post for help.
I do use JSON beautifiers and path finders, but I just copied the converted xml from the debug log file as this is what the HA logic is working with.
Anyway, I changed my rest sensor exactly as per your recommendation:

rest:
  - resource: https://web-api.tp.entsoe.eu/api?documentType=A44&processType=A01&in_Domain=10YBE----------2&out_Domain=10YBE----------2&periodStart=202510222200&periodEnd=202510232200&securityToken=xxxyyy
    sensor:
      - name: "Epex Data"
        value_template: "OK"
        json_attributes:
          - "Publication_MarketDocument.TimeSeries.Period.Point"

No error messages when the sensor is triggered, but I see no attributes appearing in the sensor state:

In the debug log file I see the xml data come in and the conversion to JSON, but after that nothing happens.
As for the list of prices that I would like to get in the sensor attribute: for me it doesn’t have to be comma separated, but that is what I see in some other implementations (e.g. Nordpool): numeric values separated by comma’s:

Do you see anything wrong?

@Petro:
Hi Petro,
Thank you for your reaction.
The indentation problem was likely caused by copy/paste to the forum.
I modified the setup of the rest sensor as per your recommedation:

rest:
  - resource: https://web-api.tp.entsoe.eu/api?documentType=A44&processType=A01&in_Domain=10YBE----------2&out_Domain=10YBE----------2&periodStart=202510222200&periodEnd=202510232200&securityToken=xxxyyy
    sensor:
      - name: "Epex Data"
        value_template: "OK"
        json_attributes_path: "$.Publication_MarketDocument.TimeSeries.Period.Point[0]"
        json_attributes:
          - "price.amount"

I get the first spot price as an attribute in sensor, which is the same as what I had before:

But what I want to achieve is the have a sensor attribute with a list of the 96 spot prices for the day that are in the JSON.
That is where I’m stuck…
Do you see a possibility?

Yep, so…

rest:
  - resource: https://web-api.tp.entsoe.eu/api?documentType=A44&processType=A01&in_Domain=10YBE----------2&out_Domain=10YBE----------2&periodStart=202510222200&periodEnd=202510232200&securityToken=8f288fc6-c830-4be2-811a-55d9a94ab206
    sensor:
      - name: "Epex Data"
        value_template: "OK"
        json_attributes_path: "$.Publication_MarketDocument.TimeSeries.Period"
        json_attributes:
          - Point

Then you’ll have a list of dictionaries in that sensor. From there, you can make a template sensor that just contains a list of prices.

template:
- sensor:
  - name: Epex Data Prices
    unique_id: epex_data_prices
    unit_of_measurement: $
    state: >
      {{ state_attr('sensor.epex_data', 'Point') | map(attribute='price.amount') | map('float', None) | reject('none') | list | average }}
    availability: >
      {{ state_attr('sensor.epex_data', 'Point') is list }}
    attributes:
      prices: >
        {{ state_attr('sensor.epex_data', 'Point') | map(attribute='price.amount') | map('float', None) | reject('none') | list }}

@petro
Hi Petro,
Thank you for your help, I think I’m close to the solution now.
but the problem I stumble into now is that there seems to be a problem with the dot in the JSON attribute name ‘price.amount’ that is used in the template MAP function.
I have also done some testing in the template editor and that generates the same error: the MAP function interprets the attribute as ‘price’ insyead of ‘price.amount’ and so appears to stumble over the dot in the name.
I tried to search for some solution to escape the dot, but no avail…

This is the error generated after an HA reboot or when I trigger the rest sensor:
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:101
integration: Template (documentation, issues)
First occurred: 12:15:19 (2 occurrences)
Last logged: 12:15:19

  • TemplateError(‘UndefinedError: ‘dict object’ has no attribute ‘price’’) while processing template ‘Template<template=({{ state_attr(‘sensor.epex_data’, ‘Point’) | map(attribute=‘price.amount’) | map(‘float’, None) | reject(‘none’) | list | average }}) renders=4>’ for attribute ‘_attr_native_value’ in entity ‘sensor.epex_data_prices’
  • TemplateError(‘UndefinedError: ‘dict object’ has no attribute ‘price’’) while processing template ‘Template<template=({{ state_attr(‘sensor.epex_data’, ‘Point’) | map(attribute=‘price.amount’) | map(‘float’, None) | reject(‘none’) | list }}) renders=4>’ for attribute ‘prices’ in entity ‘sensor.epex_data_prices’

Do you see a way around this?
Thank you

You have to do some magic

template:
- sensor:
  - name: Epex Data Prices
    unique_id: epex_data_prices
    unit_of_measurement: $
    state: >
      {{ state_attr('sensor.epex_data', 'Point') | map('to_json') | map('replace', 'price.amount', 'price') | map('from_json') | map(attribute='price') | map('float', None) | reject('none') | list | average }}
    availability: >
      {{ state_attr('sensor.epex_data', 'Point') is list }}
    attributes:
      prices: >
        {{ state_attr('sensor.epex_data', 'Point') | map('to_json') | map('replace', 'price.amount', 'price') | map('from_json') | map(attribute='price') | map('float', None) | reject('none') | list }}

@petro
Hi Petro,

Thank you so much, your magic works perfectly fine!
One last thing I would like to achieve is to divide the ‘price’ values by 10 and round them to 2 decimals. This is to convert from euro/MwH to Ct/kwh.
Is this possible ‘in-line’ where the attribute list is created? I can’t figure it out.

Never mind question above, I bumped into the solution by coincidence: map(‘multiply’, 0.1) | map(‘round’, 2) does the trick…

Again, thank you for all your help, I would never have resolved it by myself.

1 Like