Help needed with Rest Sensor parsing

Hi,

I’m trying to integrate the local waste collection schedule into HA.
Found an API with all the dates, unfortunately, HA complains it’s too big (+255 chars) to import & template.
But with the help of Apify I managed to make the API response a lot smaller.
(Date fields are milisecond epoch)

But I still can’t manage to get it into HA…
Anyone able to help?

Sample API response:

    [{
      "Umido": "1539820800000",
      "Secco": "1540166400000",
      "Carta": "1539648000000",
      "Plastica": "1540339200000",
      "Vetro": "1539907200000",
      "Ecomobile": "1541462400000",
      "url": "http://www.convenzionerifiutisesto.it/RaccolteDomicilio/LoadRaccolteDomicilioForComune?comuneId=30"
    }]

Configuration Snippets:
Try 1:

    - platform: rest 
      name: Umido Collection
      resource: https://api.apify.com/v1/wRi29ffoih2SPhwMA/crawlers/BC24cHRsNwCSM2epA/lastExec/results?simplified=1&token=worJhZpKAnHKCKv27dBsgkP5N
      value_template: '{{ (value_json.Umido | float / 1000) | timestamp_local }}'

Try 2:

      - platform: rest 
        resource: https://api.apify.com/v1/wRi29ffoih2SPhwMA/crawlers/BC24cHRsNwCSM2epA/lastExec/results?simplified=1&token=worJhZpKAnHKCKv27dBsgkP5N
        name: Waste Collection
        json_attributes:
          - Umido

Error log:

    2018-10-15 15:32:59 ERROR (MainThread) [homeassistant.helpers.template] Error parsing value: 'list object' has no attribute 'Umido' (value: [{
      "Umido": "1539820800000",
      "Secco": "1540166400000",
      "Carta": "1539648000000",
      "Plastica": "1540339200000",
      "Vetro": "1539907200000",
      "Ecomobile": "1541462400000",
      "url": "http://www.convenzionerifiutisesto.it/RaccolteDomicilio/LoadRaccolteDomicilioForComune?comuneId=30"
    }], template: {{ (value_json.Umido | float / 1000) | timestamp_local }})

Actually figured it out myself!

The API was returning a list to me, so the correct config is:

  - platform: rest 
    name: Waste Collection
    resource: https://api.apify.com/v1/wRi29ffoih2SPhwMA/crawlers/BC24cHRsNwCSM2epA/lastExec/results?simplified=1&token=worJhZpKAnHKCKv27dBsgkP5N
    value_template: '{{ (value_json[0].Umido | float / 1000) | timestamp_local }}'

Just trying to figure out now how to get the dates of all different waste collections in 1 API call rather than 6.

Normally, json_attributes parameter is what you need, but I understand that it only handles top level named elements, so I don’t think it will work with the json you currently get. If you can get rid of the array in the json using apify, you might be able to use it.