RestFul: How to send time in GET request


I have a URL that requires a start and end time (in epoch format) to be sent as part of the URL. I am having trouble working out how to send these, and any help appreciated.

For example, the full url should be something like:

his is a part of my configuration, but instead of sending the time, it sends the actual text:

   - platform: rest
     method: GET
     scan_interval: 15
       start: '{{ now() -900 }}'
       end: "{{ now() }}"

Can anyone help on how to actually send the time value as a parameter in the GET request?





I did work out that as_timestamp(now)) displays epoch.

The problem is that the rest platform does not like the template format and instead sends the actual text and not the converted time.

For example, on the server side, I see this in apache2 logs: (not exactly the same request as above as I’ve been mucking around with the format, but I think you get the point)

GET /api/?start=%7B%7B%20(as_timestamp(now())%20%7C%20int)%20%7D%7D

Ah, right.
params do not take templates :roll_eyes:

You’ll have to use resource_template rather than resource

resource_template: '{{ as_timestamp(now()) - 900 }}&end={{ as_timestamp(now()) }}'
1 Like

Perfect. Thanks!