I just hit a brick wall.
Searched the forum for a solution
Tried different solutions but can’t get is to work.
In configuration.yaml
shell_command:
get_ip: "curl http://ipinfo.io/{{ip_check}}"
in automation:
actions:
- action: shell_command.get_ip
data:
ip_check: 9.9.9.9
response_variable: this_has_to_split
enabled: true
- action: notify.persistent_notification
data:
message: "{{this_has_to_split}}"
enabled: true
- action: notify.persistent_notification
data:
message: "nr 3: {{this_has_to_split.split()[0]}} "
enabled: true
mode: single
output response_variable ‘this_has_to_split’:
{'stdout': '{\n "ip": "9.9.9.9",\n "hostname": "dns9.quad9.net",\n "city": "Zürich",\n "region": "Zurich",\n "country": "CH",\n "loc": "47.3789,8.5204",\n "org": "AS19281 Quad9",\n "postal": "8004",\n "timezone": "Europe/Zurich",\n "readme": "https://ipinfo.io/missingauth",\n "anycast": true\n}', 'stderr': '% Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 283 100 283 0 0 2291 0 --:--:-- --:--:-- --:--:-- 2319', 'returncode': 0}
this is the error in traces:
error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'split'
i don’t know how to split the response_variable ‘this_has_to_split’.
i want to get the value of “country”:
Can anybody help me with this?