(Solved) REST sensor gives no result

I tried to config a rest sensor to monitor the availability of a EV charging station.

In my sensors I made a REST call:

  - platform: rest
    scan_interval: 1000
    method: POST
    name: ev_charger_sensors
    resource: "https://www.oplaadpalen.nl/api/maplist/location/6b3cb1b0-4e72-11e8-b8dc-42010a840002"
    headers:
      Connection: keep-alive
      Content-Length: 0
      Accept: application/json, text/plain, */*
      Origin: https://www.oplaadpalen.nl/
      X-Requested-With: XMLHttpRequest
      User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0
      Sec-Fetch-Mode: cors
      Sec-Fetch-Site: same-origin
      Referer: https://www.oplaadpalen.nl/
      Accept-Encoding: gzip, deflate, br
      Accept-Language: en-US,en;q=0.9,nl;q=0.8
      Cookie: __cfduid=d4b3ad850b0302fd6a138ad4c7a8211a51603873364; GCLB=CLm23IDYvajlRg
      DNT: 1
    json_attributes:
      - status_code
      - status_message
      - data
      - chargingstation
      - chargingspots
    value_template: 'OK'  

But the values/attributes stay empty, in the log, no errors.

when curl from home assistant commandline, I get a JSON reply:

{"status_code":1000,"status_message":"OK","data":{"id":"6b3cb1b0-4e72-11e8-b8dc-42010a840002","name":"NL*NUO*EEVB*P1542169*2","chargingstation":{"type":"ON_STREET","charging_when_closed":false,"time_zone":"Europe\/Amsterdam","support":{"tel":"+(31)-(900)-6752237","email":"[email protected]","twitter_webcare":"https:\/\/twitter.com\/nuonlaadpunten","facebook_page":"https:\/\/www.facebook.com\/nuon\/"},"chargingspots":[{"uid":"1f73d088-7929-4d46-a365-b5c3c199da19","ocpi_evse_id":"NL*NUO*EEVB*P1542169*2","physical_reference":"NL*NUO*EEVB*P154","status":"CHARGING","capabilities":[],"parking_restrictions":"EV_ONLY","connectors":[{"id":"56a1fb3b-6b5a-47ff-b2bc-f322167fe51d","standard":"IEC_62196_T2","format":"SOCKET","power_type":"AC_3_PHASE","voltage":230,"amperage":16,"max_power":11040,"tariffs":[]}]},{"uid":"2d1f76cf-fbd8-4c21-a6c2-cddb157a80d7","ocpi_evse_id":"NL*NUO*EEVB*P1542169*1","physical_reference":"NL*NUO*EEVB*P154","status":"AVAILABLE","capabilities":[],"parking_restrictions":"EV_ONLY","connectors":[{"id":"78ef7c90-f2a5-4b9b-a616-d4a2d445591a","standard":"IEC_62196_T2","format":"SOCKET","power_type":"AC_3_PHASE","voltage":230,"amperage":16,"max_power":11040,"tariffs":[]}]}],"operator":{"name":"Vattenfall","website":"https:\/\/group.vattenfall.com"},"owner":{"name":"Vattenfall","website":"https:\/\/group.vattenfall.com"},"publicaccess":"Public"},"geographic":{"coordinates":{"latitude":"52.37108211","longitude":"4.93977383"},"geodata_type":"street_address","street":"Borneolaan 512","postal_code":"1019 KN","city":"Amsterdam","countrycode":"NL"},"opening_times":{"twentyfourseven":true},"predicted_availability":{"mon":[{"hour":0,"availability":3},{"hour":1,"availability":2},{"hour":2,"availability":2},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":3},{"hour":9,"availability":3},{"hour":10,"availability":4},{"hour":11,"availability":4},{"hour":12,"availability":4},{"hour":13,"availability":4},{"hour":14,"availability":4},{"hour":15,"availability":3},{"hour":16,"availability":3},{"hour":17,"availability":3},{"hour":18,"availability":3},{"hour":19,"availability":3},{"hour":20,"availability":3},{"hour":21,"availability":2},{"hour":22,"availability":3},{"hour":23,"availability":2}],"tue":[{"hour":0,"availability":2},{"hour":1,"availability":2},{"hour":2,"availability":2},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":2},{"hour":9,"availability":2},{"hour":10,"availability":2},{"hour":11,"availability":3},{"hour":12,"availability":3},{"hour":13,"availability":3},{"hour":14,"availability":3},{"hour":15,"availability":3},{"hour":16,"availability":4},{"hour":17,"availability":4},{"hour":18,"availability":4},{"hour":19,"availability":3},{"hour":20,"availability":3},{"hour":21,"availability":3},{"hour":22,"availability":3},{"hour":23,"availability":3}],"wed":[{"hour":0,"availability":2},{"hour":1,"availability":2},{"hour":2,"availability":2},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":3},{"hour":9,"availability":3},{"hour":10,"availability":3},{"hour":11,"availability":4},{"hour":12,"availability":4},{"hour":13,"availability":4},{"hour":14,"availability":3},{"hour":15,"availability":4},{"hour":16,"availability":4},{"hour":17,"availability":4},{"hour":18,"availability":3},{"hour":19,"availability":2},{"hour":20,"availability":2},{"hour":21,"availability":2},{"hour":22,"availability":2},{"hour":23,"availability":2}],"thu":[{"hour":0,"availability":2},{"hour":1,"availability":2},{"hour":2,"availability":2},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":2},{"hour":9,"availability":3},{"hour":10,"availability":3},{"hour":11,"availability":3},{"hour":12,"availability":3},{"hour":13,"availability":3},{"hour":14,"availability":3},{"hour":15,"availability":3},{"hour":16,"availability":3},{"hour":17,"availability":3},{"hour":18,"availability":3},{"hour":19,"availability":3},{"hour":20,"availability":3},{"hour":21,"availability":3},{"hour":22,"availability":3},{"hour":23,"availability":3}],"fri":[{"hour":0,"availability":3},{"hour":1,"availability":3},{"hour":2,"availability":3},{"hour":3,"availability":3},{"hour":4,"availability":3},{"hour":5,"availability":3},{"hour":6,"availability":3},{"hour":7,"availability":3},{"hour":8,"availability":3},{"hour":9,"availability":3},{"hour":10,"availability":3},{"hour":11,"availability":3},{"hour":12,"availability":3},{"hour":13,"availability":3},{"hour":14,"availability":3},{"hour":15,"availability":2},{"hour":16,"availability":3},{"hour":17,"availability":3},{"hour":18,"availability":3},{"hour":19,"availability":2},{"hour":20,"availability":2},{"hour":21,"availability":2},{"hour":22,"availability":2},{"hour":23,"availability":2}],"sat":[{"hour":0,"availability":2},{"hour":1,"availability":2},{"hour":2,"availability":2},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":2},{"hour":9,"availability":2},{"hour":10,"availability":3},{"hour":11,"availability":3},{"hour":12,"availability":3},{"hour":13,"availability":3},{"hour":14,"availability":3},{"hour":15,"availability":3},{"hour":16,"availability":3},{"hour":17,"availability":3},{"hour":18,"availability":3},{"hour":19,"availability":3},{"hour":20,"availability":3},{"hour":21,"availability":3},{"hour":22,"availability":3},{"hour":23,"availability":3}],"sun":[{"hour":0,"availability":3},{"hour":1,"availability":3},{"hour":2,"availability":3},{"hour":3,"availability":2},{"hour":4,"availability":2},{"hour":5,"availability":2},{"hour":6,"availability":2},{"hour":7,"availability":2},{"hour":8,"availability":2},{"hour":9,"availability":3},{"hour":10,"availability":3},{"hour":11,"availability":3},{"hour":12,"availability":2},{"hour":13,"availability":2},{"hour":14,"availability":2},{"hour":15,"availability":2},{"hour":16,"availability":3},{"hour":17,"availability":3},{"hour":18,"availability":3},{"hour":19,"availability":2},{"hour":20,"availability":2},{"hour":21,"availability":2},{"hour":22,"availability":3},{"hour":23,"availability":3}]}}}

In the end, I only want the results of the “changringspots”-topic, but now i get only an empty response.

Where do I go wrong in this?

You can simplify your configuration a lot.
The URL does not appear to work with POST, but only GET. And I don’t know why you would need to define all those headers.

sensor:
  - platform: rest
    scan_interval: 1000
    method: GET
    name: ev_charger_sensors
    resource: "https://www.oplaadpalen.nl/api/maplist/location/6b3cb1b0-4e72-11e8-b8dc-42010a840002"
    json_attributes:
      - status_code
      - status_message
      - data
      - chargingstation
      - chargingspots
    value_template: 'OK'

OMG, it was that easy…

Thank you for the response.
I copied the header info from an other existing rest call, (tha obviously needed it, I had to login).

Thank you for this easy and quick fix!

1 Like