Accessing dict variable in automation

I am struggeling with dicts and accessing them in my automation.

I have a variable called sqlanswer that turned out to be a dict. When put to logbook (which seems to convert into a full string), the content reads:

{'result': [{'openstring': 'http://192.168.0.0/hello'}]}

When I put sqlanswer.result to logbook, it correctly posts:

[{'openstring': 'http://192.168.0.0/hello'}]

But trying to access openstring, fails to me!

Neither sqlanswer.openstring nor sqlanswer.result.openstring is resulting in ANY output.

What would I have to write to return the content of openstring?

sqlanswer.result.0.openstring

result contains a list. You want the zeroth (first) element of that list.

1 Like