#RESTful sensor

1 messages · Page 1 of 1 (latest)

nimble osprey
#

For the RESTful sensor https://www.home-assistant.io/integrations/sensor.rest#fetch-multiple-json-values-and-present-them-as-attributes

{"result": {"size": 481105, "modified": 1674882245.5337312, "uuid": "23918406-90fc-4703-bb0a-f31783022297", "slicer": "SuperSlicer", "slicer_version": "2.4", "gcode_start_byte": 277005, "gcode_end_byte": 466454, "layer_count": 63, "object_height": 12.6, "estimated_time": 684, "nozzle_diameter": 0.4, "layer_height": 0.2, "first_layer_height": 0.2, "first_layer_extr_temp": 215.0, "first_layer_bed_temp": 55.0, "chamber_temp": 15.0, "filament_name": "Basic PLA @VORON", "filament_type": "PLA", "filament_total": 362.26, "filament_weight_total": 1.08, "thumbnails": [{"width": 32, "height": 24, "size": 1686, "relative_path": ".thumbs/cali_mouse-32x32.png"}, {"width": 64, "height": 64, "size": 7031, "relative_path": ".thumbs/cali_mouse-64x64.png"}, {"width": 400, "height": 300, "size": 192315, "relative_path": ".thumbs/cali_mouse-400x300.png"}], "print_start_time": 1674882246.3691816, "job_id": "00005B", "filename": "cali_mouse.gcode"}}

How do I select the third relative_path value ".thumbs/cali_mouse-400x300.png" with this?

  - platform: rest
    scan_interval: 15
    name: klipper_preview_path
    unique_id: "IPfd0ae36c-0d51-4392-a18d-89861d536ba4"
    resource_template: "http://IP:7125/server/files/metadata?filename={{ states(('sensor.3d_printer_current_print')) }}"
    json_attributes_path: "$.result.thumbnails.[1]"
    json_attributes:
      - relative_path
      - width
      - height
      - size
    value_template: "OK"

would I do

  - relative_path[1]
#

I would assume you would change

"$.result.thumbnails.[1]" -> "$.result.thumbnails.[2]"
#

maybe it's storing the old value in the database so when I change that it doesn't actually update so my change looks like it does nothing.

#

So I tried tossing another print after sending that value but still it shows the 64x64 image instead of the 400x300 image path.