Hey!
I'am using RESTful Command to call to an API witch returns this data (see picture 1) as a variable called response. As you can see in Picture 2 I then try to write the ID from the content into a Helper Input Text but i allways writes an empty value...
What am I doing worng? I guess I need to somehow parse the content as JSON, but at least the debug info (picture 1) from Traces would indicate that this has allready happend?
Thanks for any Tips!
EDIT: The orange blocks on picture one are just for censoring, I hope they dont confuse
#Cant accsess return variable contents from RESTful Command
1 messages · Page 1 of 1 (latest)
it would help if you shared the actual REST command call as well, but you should review the HA logs
presumably you've reviewed the example in the docs: https://www.home-assistant.io/integrations/rest_command/#using-rest-command-response-in-automations
For sure
rest_command:
dyndns_update_ip:
username: "username"
password: "password"
url: "http://api.com/"
method: put
payload: '{"answer":"{{ states("sensor.public_ipv4") }}"}'
content_type: "application/json"
the call, not the definition
again, just reivew the example
share the whole thing, not just bits and pieces
I have... but the request it self ins't the issue i guess... the data gets saved in the response variable i just cant accsess it
please just shared the whole thign
give me a minute and i will
My automisation
alias: DynDNS update IP
description: ""
triggers:
- trigger: time
at: "00:00:00"
conditions: []
actions:
- action: rest_command.dyndns_update_ip
metadata: {}
data: {}
response_variable: response
- if:
- condition: template
value_template: "{{ response.status == 200 }}"
then:
- action: input_text.set_value
metadata: {}
data:
value: "{{ response.content.id | string }}"
target:
entity_id: input_text.dns_record_id
mode: single
Any suggestions @worn isle ?
did you review the HA logs?
WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'str object' has no attribute 'id' when rendering '{{ response.content.id | string }}'
Thanks for pointing that out, dindnt know things like this produce log warnings
So this confirmes my theory that it somehow isnt able to accsess the field... but why thow?