#RESTful integration - json-attributes

9 messages · Page 1 of 1 (latest)

urban hawk
#

Hello - sorry if that is the wrong place, i did not know where else i should ask.

I have a rest integration sensor where the value template works fine, but i can't get the attributes to work.
The Rest message that i get is the following:

{
  "queue": 3,
  "processing": 1,
  "processed": 9434,
  "time": "4:36:08",
  "processingFiles": [
    {
      "name": "my_name",
      "relativePath": "my_path",
      "library": "my_library",
      "step": "FFMPEG Builder: Executor",
      "stepPercent": 49.23714
    }
  ]
}

The yaml is as follows:

rest:
  - resource: http://some_ip:19200/api/status
    scan_interval: 30
    method: GET
    sensor:
      - unique_id: fileflows_bigbox_queue
        name: Fileflows Bigbox Queue
        force_update: true
        value_template: "{{ value_json['queue'] | int }}"
        state_class: measurement
        json_attributes_path: "$."
        json_attributes:
          - "processing"
          - "processed"
          - "time"

The value_template works fine and i get the queue length.
But i want the 3 other values as attributes, which i can't seem to get to work. I guess it has something to do with that they are on the root level?
Of course i could make separate sensors for that, but that would mean that i get a lot of sensors that in reality should belong together.

On a second note, independently from that: how should i configure a number sensor? It's not a "number" entity, as it is readonly, but it also does only have positive integers, because it is a count, but that is not available as a device-class.

pseudo zenith
#

You shouldn't need to use json_attributes_path as the attributes are already in the root of the structure

#

Regarding configuration of a sensor that returns a number - defining it as a measurement is all you need to do.

urban hawk
pseudo zenith
#

You might need to restart home assistant rather than just reload the configuration

urban hawk
#

ah yes, that might be true.
I added another sensor with just the values switched and that one has the attributes.
now i just wonder if i can delete the unnecessary ones. 😉

pseudo zenith
#

Heh

urban hawk
#

@pseudo zenith works! thank you!