#Using Template for resource value in REST sensor

1 messages · Page 1 of 1 (latest)

near geyser
#

I'm trying to create a rest sensor but I want to use a template in the resource. I want to get the last 15 days worth of data and that requires passing a query param but the value will change obviously as time marches on. When I use this, I get nothing. If I hardcode a date_min I get results so the API and sensor is working as expected, but I think I'm having an issue with the template. The template itself gives the correct value so it's either syntax error or I'm not able to use templates here.

- platform: rest
  scan_interval: 15
  name: BabyBuddy Temperatures
  resource: >-
    http://IP_ADDRESS:8000/api/temperature/?date_min={{as_datetime(now().timestamp() - 15*24*60*60).isoformat()}}
  value_template: N/A
  json_attributes:
    - results
  headers:
    Authorization: !secret baby_buddy_token