Post-processing json_attributes in REST sensors

Hi all,

I have a RESTful setup working fine retrieving the data.
However, I could not find a way to post-process the attributes of the sensor.

What I what to do is:

{{ value_json["timestamp-in-hex"] | int(base=16) }}

Thanks!

Can you post the JSON as well? And maybe the whole REST sensor code.

Thanks for the reply!
Here are the JSON response and REST sensor code.

I think of 2 ways to get it converted but looking for a smarter way to do it in an attribute of RESTful sensor. :slight_smile:

  1. Create another template sensor
  2. Use converted timestamp as state of REST sensor with value_template
# Expected REST sensor
entity_id: sensor.router_connection
state: Connected
attributes:
  name: Dummy Router
  last_connected: 2023-03-25T06:17:11+00:00
  connection_status: Connected
// JSON response
// 0x641e91e7 = 2023/03/25 06:17:11 GMT
{
  "router": {
    "name": "Dummy Router",
    "last_connected": "0x641e91e7",
    "connection_status": "Connected",
  }
}
# REST sensor code
rest:
  - resource: http://192.168.86.100/local_api
    method: GET
    scan_interval: 60
    sensor:
      - name: "Router Connection"
        value_template: '{{ value_json["router"]["connection_status"] }}'
        json_attributes_path: "$.router"
        json_attributes:
          - "name"
          - "last_connected"
          - "connection_status"