#Cant accsess return variable contents from RESTful Command

1 messages · Page 1 of 1 (latest)

pliant lichen
#

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

worn isle
#

it would help if you shared the actual REST command call as well, but you should review the HA logs

pliant lichen
#

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"

worn isle
#

the call, not the definition

#

again, just reivew the example

#

share the whole thing, not just bits and pieces

pliant lichen
worn isle
#

please just shared the whole thign

pliant lichen
#

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
pliant lichen
#

Any suggestions @worn isle ?

worn isle
#

did you review the HA logs?

pliant lichen
# 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?

worn isle
#

It's telling you that content is a string

#

Try using content|from_json