I am attempting to setup a rest sensor with a resource template to Toggl to update the name of my current running project using the attributes from a previous rest call, workspace_id and project_id. When I run it with a template, I get back an error from the endpoint that there is ‘Missing or invalid workspace_id’, which seems like the url isn’t being built correctly.
Here is the relevant spot in my sensors.yaml:
- platform: rest
# resource: https://api.track.toggl.com/api/v9/workspaces/2024073/projects/177821418
resource_template: https://api.track.toggl.com/api/v9/workspaces/{{state_attr('sensor.toggl','workspace_id')}}/projects/{{state_attr('sensor.toggl','project_id')}}
name: Toggl Project Name
username: !secret TOGGL_TOKEN
authentication: basic
password: api_token
value_template: '{{ value_json["name"] }}'
The commented out resource line is what I am trying to generate, and if that is switched with the resource template, then the call is successful. However, I’ll need to generate it on the fly if the project id changes.
I’ve run the template through the dev tools, and it seems to generate the correct url format
I attempted to up the logging level to see what URL it is trying to hit, but I wasn’t able to see that info in the response. (entirely might have done this part wrong but tried a few iterations to no avail.)
configuration.yaml:
logger:
default: info
logs:
homeassistant.components.sensor.rest: debug
Any next debugging steps that I’m missing, or messups that I’m not seeing? I can run that URL through postman with success, and I know authentication works because this isn’t the first api that uses it. Appreciate any and all help
Relevant api docs: