Struggling with RESTful sensor

I have this Curl command:

curl -X 'GET' \
  'https://cloud.solar-manager.ch/v1/data/gateway/abcdefghijklmnop' \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxcyyyyyyyyyyyyyyyyyyy'

And dont get it work as a sensor.
I tried:

sensor: 
  - platform: command_line
    name: "Curl Test"
    command: "curl -X 'GET' \
      'https://cloud.solar-manager.ch/v1/data/gateway/abcdefg' -H 'accept: application/json' -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxcyyyyyyyyyyyyyyyyyyy'"
  - platform: rest
    name: "Solarenergie_test"
    resource: https://cloud.solar-manager.ch/v1/data/gateway/abcdefg
    method: GET
    scan_interval: 30
    username: "aaaaaabbbbbb"
    password: "xxxxxxxyyyyyy"
    authentication: basic

Both don’t work.
Can somebody help? I’m sure it’s just a stupid mistake from my side, but I don’t see it.

Output should look like:

{

    "Interface Version": "1.0",

    "TimeStamp": "2022-09-02T11:55:41.553Z",

    "currentPowerConsumption": 471.72999999999956,

    "currentPvGeneration": 6149,

    "devices": [

        {

            "_id": "aaaaaaaa",

            "accumulatedErrorCount": 0,

            "currentPowerInvSm": 6149,

            "errors": [],

            "signal": "connected"

        },

        {

            "_id": "aaaaaa",

            "accumulatedErrorCount": 0,

            "currentPowerInvSm": -5677,

            "errors": [],

            "signal": "connected"

        }

    ],

    "errors": []

}

And here I need this value: “currentPvGeneration”: 6149

Reading JSON should be easy part (though is value you require always the first of 2 similar ones? There is no differentiator, unless it is _id that is unique, then iteration trough list need to be done to find the right one.
Resource part might be more tricky. From the first example it looks that you are authorizing using sort of token, but in the second you use username and password… Actual values you substituted with random letters do not mach to figure out the right combination.
So probably REST sensor should look something like that:

  - platform: rest
    resource: https://cloud.solar-manager.ch/v1/data/gateway/abcdefg
    name: solarenergie_test
    method: GET
    headers:
      Content-Type: application/json
      Authorisation: Basic xxxxxxxxxxxxxxxcyyyyyyyyyyyyyy
    value_template: >-
      {{ value_json.devices[0].currentPowerInvSm }}
1 Like

Thank you very much. The token is a name & password encoded with base64.

I tried your solution. Now at least I got a entity, but the value is “unknown”.

sensor: 
  - platform: rest
    resource: https://cloud.solar-manager.ch/v1/data/gateway/abcdefg
    name: solarenergie
    scan_interval: 30
    method: GET
    headers:
      Content-Type: application/json
      Authorisation: "Basic xxxxxxxxxxxxxxxxxxxxxcyyyyyyyyyyyyyyyy"
    value_template: >-
      {{ value_json.devices[0].currentPowerInvSm }}

Any ideas what I could try else?

I think I found a solution:

 - platform: rest
    name: "solarenergie"
    resource: https://cloud.solar-manager.ch/v1/data/gateway/gatewayid
    username: [email protected]
    password: password
    authentication: basic
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    value_template: >-
      {{ value_json.devices[0].currentPowerInvSm }}

Unfortunatelly now there is no solar produktion, but at least I get a 0. Looks like it works.

OK, so we have some progress :slight_smile:
What I’d try:

  • unknown sensor most likely means that value_template is not evaluating properly response. So probably you get some error in responce instead of proper json response. You can try to replace template with just:
    value_template: >-
      {{ value_json.devices }}
  • Above code should return entire response received from server, with no processing. JSON response is not too long, should fit, hopefully, into limits os state. Then you can see what the sensor is receiving from the server. If this is proper JSON then we need to work on template, but I’d rather extect some error message.
  • Frankly speaking I’m npot too familiar with configuration of header for RESTfull sensor. In all of my sensors I put entire URL into resource field. This way I can test this with any browser. If full URL put into address bar of browser returns proper response, it will also work in REST sensor (at least so far). So you can try with you put into your first example, though I’m a bit concerned about usin -H option… it could work for curl, but simple URL might not. probably it would be something like:
https://cloud.solar-manager.ch/v1/data/gateway/abcdefghijklmnop&user=xxxxxxx&password=yyyyyy

But it really depends on API (could be usr, user, could be user_id, etc). This is also not best practice to hardcode credentials into call, but for start could help.

  • finally I’d check the log file if there are any errors you can associate with sensor. If so this could help to diagnose.
1 Like

My attempt in my last post works. I think your part with header and value_template was the key.
Thank you very much mirekmal. I’m a little smarter now than before :smiley:

please let me jump on this: I have a rest sensor which response Is too long, so I want it in 1 single attribute (so I can template several steps out later)

Is there a default way to do that?

Well, might not be easy and I have no experience with long real JSON responces. In one of my sensors I’m processing very long XML (welll if no alerts it might be just few lines, if there are alerts, it might contain few thousents of lines), that somewhere in the process is automatically translated to JSON and processed before it reaches state or attibute:

  • using REST sensor i’m reading XML response from Meteolarm rss feed.
  • in the value_template I instantly iterate through this XML (that at this stage is already automatically converted by HA to JSON) to find the right node and put it into sensor state (just index to node containing all required for me info)
  • then I use proper json_attributes_path and attributes selection to extract actual data I need and put it into attributes.

Here is the code:

 - platform: rest
    resource: https://feeds.meteoalarm.org/feeds/meteoalarm-legacy-rss-poland
    scan_interval: 900
    name: meteoalarm_index
    value_template: >-
      {% set ns = namespace(idx = -1) %}
      {% if value_json.rss.channel.item[0] is defined %}
        {% for x in range(value_json.rss.channel.item | length) %}
          {% if value_json.rss.channel.item[x].title == 'Mazowieckie Province Wołomiński County' %}
            {% set ns.idx = x %}
          {% endif %}
        {% endfor %}
      {% else %}
        {% set ns.idx = -1 %}
      {% endif %}
      {{ ns.idx }}
    json_attributes_path: "$.rss.channel.item[?(@.title=='Mazowieckie Province Wołomiński County')]"
    json_attributes:
      - title
      - description

Perhaps using similar approach it would be possible to put all the data of JSON resppnce, starting with root name as attribute to put whole file into single attribute…

yeah, thanks Mirek.

That’s what I do normally too, but check this resources output:

https://mijn.easyenergy.com/nl/api/tariff/getapxtariffs?startTimestamp=2022-10-14&endTimestamp=2022-10-16```

It’s returning:

I am using this:

      - name: Energieprijs uur 0
        value_template: >
          {{(value_json|default(['default']))[0]['TariffUsage']|float(0) + states('sensor.prijsopslag_energie')|float(0)}}
        json_attributes_path: "$[0]"
        json_attributes: &attributes
          - SupplierID
          - TariffReturn
          - TariffUsage
          - Timestamp

      - name: Energieprijs uur 1
        value_template: >
          {{(value_json|default(['default']))[1]['TariffUsage']|float(0) + states('sensor.prijsopslag_energie')|float(0)}}
        json_attributes_path: "$[1]"
        json_attributes: *attributes

      - name: Energieprijs uur 2
        value_template: >
          {{(value_json|default(['default']))[2]['TariffUsage']|float(0) + states('sensor.prijsopslag_energie')|float(0)}}
        json_attributes_path: "$[2]"
        json_attributes: *attributes

      - name: Energieprijs uur 3
        value_template: >
          {{(value_json|default(['default']))[3]['TariffUsage']|float(0) + states('sensor.prijsopslag_energie')|float(0)}}
        json_attributes_path: "$[3]"
        json_attributes: *attributes

etc etc up to 47....

to break it all out, but the last 24 hours, are not always available and throw errors.

That’s why I want to try to get it all in 1 attribute:

      - name: Energieprijzen
        value_template: "Ok"
        json_attributes:
          - ArrayOfEnergyTariff

or whatever it takes, and use a trigger template at 16:00 hrs, when the 24-47th hour are available daily :wink:

but, or, so, what is the ‘root’ here. I’ve tried so many things…

Well, I found this to be very problematic to find the right root :slight_smile: Official documentation suggests to use tool like https://xmltodict-debugger.glitch.me/ to test conversion. E.g. you can pyt entire XML into input box, press submitt and get data converted to JSON. From there you should be able to find the root. BUT… I found some issues with these types of tools, especially for sources where field naming is more complex/using special characters. Then different tools make different conversions, up to level where root looks different… Yet having such converted file can help to figure out root with trial and error approach.
BTW, link you provided gives me error instead of somethign similar to your screenshot:

yeah sometimes its flakey, I did experience that too. currently this works though

https://mijn.easyenergy.com/nl/api/tariff/getapxtariffs?startTimestamp=2022-10-17&endTimestamp=2022-10-18

Ill whop it into the tool you posted, lets see what gives…
wel, that works:

{"converted":{"ArrayOfEnergyTariff":{"@xmlns":"http://schemas.datacontract.org/2004/07/GreatValue.Common.Models.Tariffs","@xmlns:i":"http://www.w3.org/2001/XMLSchema-instance","EnergyTariff":[{"SupplierId":"0","TariffReturn":"0.12831","TariffUsage":"0.139857900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-16T22:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.11441","TariffUsage":"0.124706900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-16T23:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.10565","TariffUsage":"0.115158500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T00:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.08964","TariffUsage":"0.097707600000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T01:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.07823","TariffUsage":"0.085270700000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T02:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.10133","TariffUsage":"0.110449700000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T03:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.12301","TariffUsage":"0.134080900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T04:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.15417","TariffUsage":"0.168045300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T05:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.18242","TariffUsage":"0.198837800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T06:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.16110","TariffUsage":"0.175599000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T07:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.13680","TariffUsage":"0.149112000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T08:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.13745","TariffUsage":"0.149820500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T09:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.12302","TariffUsage":"0.134091800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T10:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.13207","TariffUsage":"0.143956300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T11:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.13727","TariffUsage":"0.149624300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T12:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.14032","TariffUsage":"0.152948800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T13:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.16877","TariffUsage":"0.183959300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T14:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.22116","TariffUsage":"0.241064400000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T15:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.26325","TariffUsage":"0.286942500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T16:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.26816","TariffUsage":"0.292294400000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T17:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.19000","TariffUsage":"0.207100000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T18:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.16425","TariffUsage":"0.179032500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T19:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.17291","TariffUsage":"0.188471900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T20:00:00Z","d3p1:OffsetMinutes":"0"}},{"SupplierId":"0","TariffReturn":"0.14502","TariffUsage":"0.158071800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T21:00:00Z","d3p1:OffsetMinutes":"0"}}]}},"extracted":null}

formatted it a bit:

{"converted":
{"ArrayOfEnergyTariff":
  {"@xmlns":"http://schemas.datacontract.org/2004/07/GreatValue.Common.Models.Tariffs",
   "@xmlns:i":"http://www.w3.org/2001/XMLSchema-instance",
   "EnergyTariff":[{"SupplierId":"0","TariffReturn":"0.12831","TariffUsage":"0.139857900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-16T22:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.11441","TariffUsage":"0.124706900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-16T23:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.10565","TariffUsage":"0.115158500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T00:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.08964","TariffUsage":"0.097707600000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T01:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.07823","TariffUsage":"0.085270700000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T02:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.10133","TariffUsage":"0.110449700000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T03:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.12301","TariffUsage":"0.134080900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T04:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.15417","TariffUsage":"0.168045300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T05:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.18242","TariffUsage":"0.198837800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T06:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.16110","TariffUsage":"0.175599000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T07:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.13680","TariffUsage":"0.149112000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T08:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.13745","TariffUsage":"0.149820500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T09:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.12302","TariffUsage":"0.134091800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T10:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.13207","TariffUsage":"0.143956300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T11:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.13727","TariffUsage":"0.149624300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T12:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.14032","TariffUsage":"0.152948800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T13:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.16877","TariffUsage":"0.183959300000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T14:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.22116","TariffUsage":"0.241064400000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T15:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.26325","TariffUsage":"0.286942500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T16:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.26816","TariffUsage":"0.292294400000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T17:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.19000","TariffUsage":"0.207100000000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T18:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.16425","TariffUsage":"0.179032500000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T19:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.17291","TariffUsage":"0.188471900000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T20:00:00Z","d3p1:OffsetMinutes":"0"}},
                   {"SupplierId":"0","TariffReturn":"0.14502","TariffUsage":"0.158071800000000000","Timestamp":{"@xmlns:d3p1":"http://schemas.datacontract.org/2004/07/System","d3p1:DateTime":"2022-10-17T21:00:00Z","d3p1:OffsetMinutes":"0"}}]}},"extracted":null}

and its really weird. I can use [0] for attributes_path, and then it starts at the 0 element of the array in EnergyTariff.
Meaning, the root of the return of the resource is that EnergyTariff? But, and that’s my search, EnergyTariff itself is the 2nd element of the real root, being ArrayOfEnergyTariff ??

so, how to get to that root, and show the full Array of EnergyTariff in the attributes…

In other words, I am trying to do this:

      - name: Energieprijzen
        value_template: "Ok"
        json_attributes_path: "$.ArrayOfEnergyTariff"
        json_attributes:
          - EnergyTariff

Thats the problem, we do not really know how XML is converted to JSON by HA… clear example is that tth root in converted JSON is “converted”… which is not present in original XML at all. To be honest I’d expect tha the root would be entire line:

ArrayOfEnergyTariff xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/GreatValue.Common.Models.Tariffs"

and then EnergyTariff being the first element/table… It is alot of trial and error there :frowning:
Would be way simpler, if response could be stored in state, not need then to dig into such details.

one time no see…

but I need some help please, cold you hop over to KNMI rest sensor configuration (and preselect individual items in a huge attribute...) and see why

      - unique_id: knmi_waarschuwingen_basis_test
        name: KNMI waarschuwingen basis_test
        value_template: >
          {{value_json.rss.channel.time[0]['title']}}
        json_attributes_path: "$.rss.channel.item[0]"
        json_attributes:
          - title
          - category
          - description

shows the value template as unknown, while the attribute is displayed correctly?

goal: I want to create a binary (no json_attributes_path is allowed on a binary btw?) and do something like
{{ 'groen' in value_json.rss.channel.time[0]['title']}} but it does not work at all…