Hi guys,
I am trying to extract certain information from JSON file.
Then testing data with Template Editor i get the right values
{% set value_json = {
"device_summary": {
"details": [
{
"dig": "team",
"ver": "0.8.0"
}
]
},
"device_stats": {
"details": [
{
"dig": "team2",
"what": "gold",
"metal": "iron",
"fans": [
34,
31,
44,
36,
40
]
}
]
},
"notes": "none"
}
%}
From {{ value_json }} I get
{‘device_summary’: {‘details’: [{‘dig’: ‘team’, ‘ver’: ‘0.8.0’}]}, ‘device_stats’: {‘details’: [{‘dig’: ‘team2’, ‘what’: ‘gold’, ‘metal’: ‘iron’, ‘fans’: [34, 31, 44, 36, 40]}]}, ‘notes’: ‘none’}
From {{ value_json.device_stats.details[0].fans }} I get [34, 31, 44, 36, 40]
From {{ value_json.device_stats.details[0].fans[0] }} I get 34
But when I configure sensor I get state UNKNOWN - rather then 34
- platform: rest
name: Fans percentage
resource: https://xxx.xxx.xxx.xxx
method: GET
headers:
Authorization: Bearer **TOKEN**
value_template: ' {{ value_json.device_stats.details[0].fans[0] }} '
unit_of_measurement: "%"
scan_interval: 30
Any help with understanding why is this happening would be much appreciated.