REST sensor: Where "x" equals "Y"

URL: http://10.0.24.11:61208/api/3/processlist
Output: https://pastebin.com/3zkvSgrp

In the above output there is just a list of processes.
What I can’t find is a way to select the “object” where “Name” equals “deCONZ” and get the attributes from there.

However this code works, but I want to selct it by name, and not by place [1].

  - platform: rest
    resource: http://10.0.24.11:61208/api/3/processlist
    name: Glances - DeCONZ - CPU - Process
    value_template:  '{{ "ok" }}'
    json_attributes_path: '$[1]'
    json_attributes:
      - name
      - status
      - username

I have tried a lot of compinations of code, but I cant find a working way.
Anyone know?

I’m behind a corporate firewall that bocks pasebin.com. Interestingly it does not block https://paste.ubuntu.com/ so if you paste the output there I can have a look for you.

Try this:
https://paste.ubuntu.com/p/tpq4jvsFCq/

1 Like

As it is a list and not a dictionary I don’t see any way of doing it other than indexing by $[1].

There is a way :smile::

  - platform: rest
    resource: http://10.0.24.11:61208/api/3/processlist
    name: Glances - DeCONZ - CPU - Process
    value_template:  '{{ "ok" }}'
    json_attributes_path: '$..[?(@.name=="deCONZ")]'
    json_attributes:
      - name
      - status
      - username
3 Likes

it works :smiley:

1 Like

I was looking to do something similar way back and gave up… excellent I’ll give this another go now…

I don’t pretend to understand how it works but I’ve bookmarked it for future reference.

1 Like