Good morning,
i need help to access diffent keys in dict inside the respons_variable of shell_command.
For example i want to read the value inside key ‘value’ which is 255
Here is my code an the return inside respons_variable status
I am only able to access the dict behind stdout with " {{ status[‘stdout’] }} " but i have no clue how to access keys. I have triede different methods but nothing works for now
" {{ status[‘stdout’].value }} "
" {{ status[‘stdout’] }}[‘value’] "
I hope you can help me with this issue
Code:
configuration.yaml:
shell_command:
# Get token for auth
theben_login: 'curl -k "https://192.168.178.200/rest/login" -X POST -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" --data-raw "{\"username\": \"admin\",\"password\": \"admin\"}"'
theben_j4_hoehe: 'curl -k "https://192.168.178.200/rest/datapoints/values" -X "PUT" -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" -H "{{ token }}" --data-raw "{\"datapoints_values\": [{\"id\":{{ id }},\"value\":\"{{ value }}\"}],\"command\": 3}"'
theben_j4_pos: 'curl -k "https://192.168.178.200/rest/datapoints/values" -X "PUT" -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" -H "{{ token }}" --data-raw "{\"datapoints_values\": [{\"id\":{{ id }},\"value\":\"{{ value }}\"}],\"command\": 3}"'
theben_j4_hoehe_1: 'curl -k "https://192.168.178.200/rest/datapoints/values" -X "PUT" -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" -H "{{ token }}" --data-raw "{\"datapoints_values\": [{\"id\":174,\"value\":\"255\"}],\"command\": 3}"'
theben_j4_status: 'curl -k "https://192.168.178.200/rest/datapoints/{{ id }}" -X "GET" -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" -H "{{ token }}"'
theben_j4_test: 'curl -k "https://192.168.178.200/rest/datapoints/values" -X "PUT" -H "Accept: application/json, text/plain, */*" -H "Content-Type: application/json;charset=UTF-8" -H "{{ token }}" --data-raw "{\"datapoints_values\": [{\"id\":{{ id }},\"value\":\"{{ value }}\"}],\"command\": 3}"'
automation.yaml:
- id: '1711567216847'
alias: j4_up
description: ''
trigger: []
condition: []
action:
- service: shell_command.theben_login
response_variable: return_token
data: {}
- service: shell_command.theben_j4_status
response_variable: status
data:
token: 'Cookie: user=%22{{ return_token[''stdout''] }}%22'
id: 174
- service: notify.persistent_notification
metadata: {}
data:
title: Theben Status
message: " {{ status['stdout'] }} "
mode: single```
1 post - 1 participant