Formatting assistance needed (multiple sensors in a single REST call)

I currently have working code for multiple REST calls against a single API endpoint (see below). In order to reduce load on the server, I would like to combine them into a single REST call. I have tried and tried… but, just can’t get the formatting right. I haven’t made much progress with trial and error. :frowning:

Original “working” configuration with multiple REST calls + respective templates: (working)

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/uptime
    value_template: '{{ value_json | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
    name: Horizon Uptime
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/cpu
    name: Horizon CPU
    value_template: '{{ value_json.total | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/mem
    name: Horizon RAM
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/memswap
    name: Horizon Pagefile
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: gpu
    resource: http://192.168.1.2:61208/api/3/gpu
    value_template: '{{ ( value_json ) }}'
    json_attributes:
      - name
      - mem
      - proc
      - temperature
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: network
    resource: http://192.168.1.2:61208/api/3/network
    value_template: N/A
    json_attributes:
      - interface_name
      - time_since_update
      # - cumulative_rx
      - rx
      # - cumulative_tx
      - tx
      # - cumulative_cx
      - cx
      # - is_up
      # - speed
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon C Drive Used
    value_template: '{{ value_json[0].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon E Drive Used
    value_template: '{{ value_json[1].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: diskio_0
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[0] ) }}'
    json_attributes_path: "$.0"
    json_attributes:
      - time_since_update
      - disk_name
      # - read_count
      # - write_count
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: diskio_1
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[1] ) }}'
    json_attributes_path: "$.1"
    json_attributes:
      - time_since_update
      - disk_name
      # - read_count
      # - write_count
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 30
    scan_interval: 16

#Respective Templates for REST sensors:

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_e_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_1', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_1") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_e_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_1', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_1") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_gpu_name:
        value_template: '{{ state_attr("sensor.gpu", "name") }}'
        # value_template: '{{ states.sensor.gpu.attributes["name"] }}'
  - platform: template
    sensors:
      horizon_gpu_memory:
        value_template: '{{ state_attr("sensor.gpu", "mem") | round }}'
        # value_template: '{{ states.sensor.gpu.attributes["mem"] | round }}'
        unit_of_measurement: "%"
  - platform: template
    sensors:
      horizon_gpu_processor:
        value_template: '{{ state_attr("sensor.gpu", "proc") }}'
        # value_template: '{{ states.sensor.gpu.attributes["proc"] }}'
        unit_of_measurement: "%"
  - platform: template
    sensors:
      horizon_gpu_temperature:
        value_template: '{{ state_attr("sensor.gpu", "temperature") }}'
        # value_template: '{{ states.sensor.gpu.attributes["temperature"] }}'
        unit_of_measurement: "°C"
  - platform: template
    sensors:
      horizon_download_speed:
        value_template: >-
                {% set receive = state_attr('sensor.network', 'rx') %}
                {% set time_since = state_attr('sensor.network', 'time_since_update') %}
                {% if (receive != None ) and (time_since != None ) %}
                  {{ ((receive | int) / (time_since | int) * 8 / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.network") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_upload_speed:
        value_template: >-
                {% set transmit = state_attr('sensor.network', 'tx') %}
                {% set time_since = state_attr('sensor.network', 'time_since_update') %}
                {% if (transmit != None ) and (time_since != None ) %}
                  {{ ((transmit | int) / (time_since | int) * 8 / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.network") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_total_speed:
        value_template: >-
                {% set total = state_attr('sensor.network', 'cx') %}
                {% set time_since = state_attr('sensor.network', 'time_since_update') %}
                {% if (total != None ) and (time_since != None ) %}
                  {{ ((total | int) / (time_since | int) * 8 / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.network") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

Consolidated REST + respective templates: (not correct!)
The following integrations and platforms could not be set up:

  • rest
    2021-02-08 17:58:10 ERROR (SyncWorker_6) [homeassistant.util.yaml.loader] mapping values are not allowed here
    in “/config/configuration.yaml”, line 70, column 14
sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
rest:
  - resource: http://192.168.1.2:61208/api/3/all
      sensors:
        - name: Horizon C Drive Used
          value_template: '{{ value_json[0].fs.percent | round }}'
          unit_of_measurement: "%"
        - name: Horizon E Drive Used
          value_template: '{{ value_json[1].fs.percent | round }}'
          unit_of_measurement: "%"
        - name: diskio_0
          value_template: '{{ ( value_json[0].diskio ) }}'
          json_attributes_path: "$.0"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        - name: diskio_1
          value_template: '{{ ( value_json[1].diskio ) }}'
          json_attributes_path: "$.1"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        - name: Horizon Uptime
          value_template: '{{ value_json.uptime | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
        - name: Horizon CPU
          value_template: '{{ value_json.cpu.total | round }}'
          unit_of_measurement: "%"
        - name: Horizon RAM
          value_template: '{{ value_json.mem.percent | round }}'
          unit_of_measurement: "%"
        - name: Horizon Pagefile
          value_template: '{{ value_json.memswap.percent | round }}'
          unit_of_measurement: "%"
        - name: gpu
          value_template: '{{ ( value_json.gpu ) }}'
          json_attributes:
            - name
            - mem
            - proc
            - temperature
        - name: network
          value_template: '{{ ( value_json.network ) }}'
          json_attributes:
            - interface_name
            - time_since_update
            # - cumulative_rx
            - rx
            # - cumulative_tx
            - tx
            # - cumulative_cx
            - cx
            # - is_up
            # - speed          
      verify_ssl: false
      timeout: 30
      scan_interval: 16

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

Here’s another attempt: (not working either)
Invalid config for [sensor.rest]: [sensors] is an invalid option for [sensor.rest]. Check: sensor.rest->sensors. (See ?, line ?).

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/all
    sensors:
      - name: Horizon C Drive Used
        value_template: '{{ value_json[0].fs.percent | round }}'
        unit_of_measurement: "%"
      - name: Horizon E Drive Used
        value_template: '{{ value_json[1].fs.percent | round }}'
        unit_of_measurement: "%"
      - name: diskio_0
        value_template: '{{ ( value_json[0].diskio ) }}'
        json_attributes_path: "$.0"
        json_attributes:
          - time_since_update
          - disk_name
        # - read_count
        # - write_count
          - read_bytes
          - write_bytes
      - name: diskio_1
        value_template: '{{ ( value_json[1].diskio ) }}'
        json_attributes_path: "$.1"
        json_attributes:
          - time_since_update
          - disk_name
        # - read_count
        # - write_count
          - read_bytes
          - write_bytes
      - name: Horizon Uptime
        value_template: '{{ value_json.uptime | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
      - name: Horizon CPU
        value_template: '{{ value_json.cpu.total | round }}'
        unit_of_measurement: "%"
      - name: Horizon RAM
        value_template: '{{ value_json.mem.percent | round }}'
        unit_of_measurement: "%"
      - name: Horizon Pagefile
        value_template: '{{ value_json.memswap.percent | round }}'
        unit_of_measurement: "%"
      - name: gpu
        value_template: '{{ ( value_json.gpu ) }}'
        json_attributes:
          - name
          - mem
          - proc
          - temperature
      - name: network
        value_template: '{{ ( value_json.network ) }}'
        json_attributes:
          - interface_name
          - time_since_update
          # - cumulative_rx
          - rx
          # - cumulative_tx
          - tx
          # - cumulative_cx
          - cx
          # - is_up
          # - speed          
    verify_ssl: false
    timeout: 30
    scan_interval: 16

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

Here’s one more variation: (doesn’t work either)

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/all
    sensors:
        Horizon C Drive Used
          value_template: '{{ value_json[0].fs.percent | round }}'
          unit_of_measurement: "%"
        Horizon E Drive Used
          value_template: '{{ value_json[1].fs.percent | round }}'
          unit_of_measurement: "%"
        diskio_0
          value_template: '{{ ( value_json[0].diskio ) }}'
          json_attributes_path: "$.0"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        diskio_1
          value_template: '{{ ( value_json[1].diskio ) }}'
          json_attributes_path: "$.1"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        Horizon Uptime
          value_template: '{{ value_json.uptime | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
        Horizon CPU
          value_template: '{{ value_json.cpu.total | round }}'
          unit_of_measurement: "%"
        Horizon RAM
          value_template: '{{ value_json.mem.percent | round }}'
          unit_of_measurement: "%"
        Horizon Pagefile
          value_template: '{{ value_json.memswap.percent | round }}'
          unit_of_measurement: "%"
        gpu
          value_template: '{{ ( value_json.gpu ) }}'
          json_attributes:
            - name
            - mem
            - proc
            - temperature
        network
          value_template: '{{ ( value_json.network ) }}'
          json_attributes:
            - interface_name
            - time_since_update
            # - cumulative_rx
            - rx
            # - cumulative_tx
            - tx
            # - cumulative_cx
            - cx
            # - is_up
            # - speed          
    verify_ssl: false
    timeout: 30
    scan_interval: 16

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

problem in first section:

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
rest:
  - resource: http://192.168.1.2:61208/api/3/all
      sensors:
        - name: Horizon C Drive Used
          value_template: '{{ value_json[0].fs.percent | round }}'
          unit_of_measurement: "%"

a rest sensor can’t be configured like that.

it isn’t it’s own domain it goes under the “sensor:” key as in your first example that worked.

problem in the next two sections:

  - platform: rest
    resource: http://192.168.1.2:61208/api/3/all
    sensors:
      - name: Horizon C Drive Used
        value_template: '{{ value_json[0].fs.percent | round }}'

the error tells you what the problem is.

“sensors:” isn’t valid here.

look at the rest sensor docs:

Thanks for your response @finity . I’m embarrassed to say that I posted AFTER looking at the REST documentation. More specifically, my issue is I’m NOT able to add my new REST code shown below (that’s incorrectly under its own domain) to go under my existing “sensor” section (also shown below).

If you notice, I did try a couple of different times to do this unsuccessfully in the 2nd and 3rd examples in my OP. I posted the 2nd and 3rd examples to show that I did try my best unsuccessfully before posting here.

Current Sensor section:

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use

I need help to redo the code below so it goes under the sensor section above:

rest:
  - resource: http://192.168.1.2:61208/api/3/all
      sensors:
        - name: Horizon C Drive Used
          value_template: '{{ value_json[0].fs.percent | round }}'
          unit_of_measurement: "%"
        - name: Horizon E Drive Used
          value_template: '{{ value_json[1].fs.percent | round }}'
          unit_of_measurement: "%"
        - name: diskio_0
          value_template: '{{ ( value_json[0].diskio ) }}'
          json_attributes_path: "$.0"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        - name: diskio_1
          value_template: '{{ ( value_json[1].diskio ) }}'
          json_attributes_path: "$.1"
          json_attributes:
            - time_since_update
            - disk_name
          # - read_count
          # - write_count
            - read_bytes
            - write_bytes
        - name: Horizon Uptime
          value_template: '{{ value_json.uptime | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
        - name: Horizon CPU
          value_template: '{{ value_json.cpu.total | round }}'
          unit_of_measurement: "%"
        - name: Horizon RAM
          value_template: '{{ value_json.mem.percent | round }}'
          unit_of_measurement: "%"
        - name: Horizon Pagefile
          value_template: '{{ value_json.memswap.percent | round }}'
          unit_of_measurement: "%"
        - name: gpu
          value_template: '{{ ( value_json.gpu ) }}'
          json_attributes:
            - name
            - mem
            - proc
            - temperature
        - name: network
          value_template: '{{ ( value_json.network ) }}'
          json_attributes:
            - interface_name
            - time_since_update
            # - cumulative_rx
            - rx
            # - cumulative_tx
            - tx
            # - cumulative_cx
            - cx
            # - is_up
            # - speed          
      verify_ssl: false
      timeout: 30
      scan_interval: 16

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: >-
                {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (read_byte != None ) and (time_since != None ) %}
                  {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: >-
                {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
                {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
                {% if (write_byte != None ) and (time_since != None ) %}
                  {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
                {% endif %}
        availability_template: >-
                {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
        unit_of_measurement: 'MB/s'

that’s thing. You can’t do it the way you want.

you will either have to create rest sensor for each templated value as you already have…

or you might be able to create one rest sensor call then split the result up using template sensors pulling data out of the rest sensor state.

But that will only work as long as the rest call returns a value that is less than 255 characters (the limit in HA for an entity state). And unfortunately it looks like you might easily hit that limitation seeing all of the values you are already templating out of the returned value in your other rest sensors.

It’s hard to know for sure without seeing the total result of the rest call.

Thanks. Below, is what’s returned in a single REST call.

API endpoint: http://192.168.1.2:61208/api/3/all

Response: Result.json

I found the workaround (link below). I’m not sure if its the same thing you just mentioned …the workaround stores info in json attributes (since there is no character limit for attributes). …then, referencing those attributes in respective Templates:

Having said that, it looks like my first example in the OP DOES store each REST response in attributes …and references these attributes in respective templates (towards the bottom of the code example). This DOES work correctly for each individual REST call. However, I’m not sure if it’s possible to do the same thing in a single REST request in my case. If it is possible… I would really appreciate it if you could please show me how to change my code to do this.

I guess if there’s no way at all, I could just leave my code as-is… with multiple REST calls. Hopefully, it’s not impossible.

Not all of them. Only 4 of them do. the rest store the result in a templated state.

Yeah, I’d say that is more than 255 characters… :laughing:

Pretty much, yes.

I’m honestly not sure how to easily do it. I’ve never used any rest sensors with attributes like that.

Maybe it would be better to post your question in that other thread so the people who have experience with it can help you.

I might be able to dig thru and figure it out but TBH I really don’t want to spend that much time on it.

Thank you for taking the time to explain; and, being honest with me. I will post in that other thread for help.

1 Like

Just a note for anyone watching this thread, I just confirmed with a developer that what I’m trying to do isn’t implemented yet. My YAML syntax/formatting below would have worked otherwise.

The below code sensors option isn’t implemented yet for REST:

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_use
      - type: memory_use_percent
      - type: processor_use
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/all
    sensors:      #This option is NOT implemented yet!!
      - name: Horizon C Drive Used
        value_template: '{{ value_json[0].fs.percent | round }}'
        unit_of_measurement: "%"
      - name: Horizon E Drive Used
        value_template: '{{ value_json[1].fs.percent | round }}'
        unit_of_measurement: "%"
      - name: diskio_0
        value_template: '{{ ( value_json[0].diskio ) }}'
        json_attributes_path: "$.0"
        json_attributes:
          - time_since_update
          - disk_name
          - read_bytes
          - write_bytes
      - name: diskio_1
        value_template: '{{ ( value_json[1].diskio ) }}'
        json_attributes_path: "$.1"
        json_attributes:
          - time_since_update
          - disk_namet
          - read_bytes
          - write_bytes       

I’m having the same issue. When is the sensors option going to be implemented for REST?

It came out. It’s the new RESTful integration. Here is a working example:

rest:
  - resource: http://192.168.1.2:61208/api/3/all
    sensor:
      - name: Horizon C Drive Used
        value_template: '{{ value_json.fs.0.percent }}'
        unit_of_measurement: "%"
      - name: Horizon E Drive Used
        value_template: '{{ value_json.fs.1.percent }}'
        unit_of_measurement: "%"
      - name: diskio_0
        value_template: '{{ value_json[0] | default }}'
        json_attributes_path: "$.diskio.0"
        json_attributes:
          - time_since_update
          - disk_name
          - read_bytes
          - write_bytes
      - name: diskio_1
        value_template: '{{ value_json[1] | default }}'
        json_attributes_path: "$.diskio.1"
        json_attributes:
          - time_since_update
          - disk_name
          - read_bytes
          - write_bytes

PS: It doesn’t say “sensors”… but it does what I was hoping for.

2 Likes