Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Get value from json based on attribute value

$
0
0

@i00 wrote:

I have a rest sensor that contains attributes like the following:

{% set test = 
{'data':
  [
    {'name': 'prx', 'value':24},
    {'name': 'blob', 'value':'0x27eac'}
  ]
}
%}
Value: {{ test.data.0.value }} 

The issue I have is that the prx and blob parts switch depending on what was last updated on the hardware … so what I want to do is instead of using:
{{ test.data.0.value }}
do something like:
{{ test.data.[‘name’:‘prx’].0.value }}
(I use .0. in the line above as in theory [‘name’:‘prx’] could return multiple)

Is this possible?
Thanks in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles