Hi everyone, when i required a status of a switch i reiceve this json:
{“metadata”: [[“device_id”,“datatime_utc_last_data”,“api_data_return”]],“value”: [[“DIM-623”,“2020-09-30 12:26:15.133”,“{"Status":"ON","Set":"ON","StatusIntensity":100,"SetIntensity":100}”] ]}
What is the correct set value for Status ON?
I tested in templating “value_json.value.Status” with no result.
Recte
September 30, 2020, 1:13pm
2
Nevermind, didn’t read well…
Sorry, i want extract the Status of the dimmer, this the response of request:
{
"metadata": [
[
"device_id",
"datatime_utc_last_data",
"api_data_return"
],
],
"value": [
[
"DIM-623",
"2020-10-05 17:32:18.11",
"{"Status":"ON","Set":"ON","StatusIntensity":90,"SetIntensity":90}"
],
],
}
If i test {% set stato = value_json.value[0][2] %}
the response is: {“Status”:“ON”,“Set”:“ON”,“StatusIntensity”:90,“SetIntensity”:90}
if i test {% set stato = value_json.value[0][2].Status %}
the response is: error
Please help me
Because the response is a JSON’s object into a JSON, i solved with:
{% set stato_json = value_json.value[0][2] | from_json %}
{%- if stato_json.Status == 'ON' -%}
{{ true }}
{%- else -%}
{{ false }}
{%- endif -%}