gethomepage / homepage

A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.
https://gethomepage.dev
GNU General Public License v3.0
18.73k stars 1.1k forks source link

Fix/handle null id in json rpc responses and cpu load representation for openwrt widget #3576

Closed LiranV closed 4 months ago

LiranV commented 4 months ago

Proposed change

Issue:

I've configured the OpenWRT widget in my homepage container, but saw the following:

initial-state

Tested on:

The service configuration I've used:

    - OpenWRT:
        icon: openwrt.png
        widget:
          type: openwrt
          url: https://10.0.0.138
          username: homepage
          password: ********

Explanation:

The widget starts by issuing an unauthorized request to OpenWRT, which for some reason results with a response id that is null (according to the JSON-RPC 2.0 specification this is discouraged) and it seems to not play nice with the json-rpc-2.0 package)

{
    "jsonrpc": "2.0",
    "id": null,
    "error": {
        "code": -32002,
        "message": "Access denied"
    }
}

My first commit solves this issue by checking if the response id is null and setting it as 1 instead. This solves the issue and the widget starts working:

null-id-fix

Additional Fix:

After the widget started working I've noticed that the CPU Load number was "off" and didn't look like the standard UNIX load format expected by something like uptime. To solve this I've added the following calculation according to this:

The values in load are the load averages over 1, 5, and 15 minutes. to get to the familiar values reported by uptime divide these numbers by 65536.0 and round to 2 decimals.

After fixing CPU load representation: cpu-load-fix

Type of change

Checklist:

shamoon commented 4 months ago

I have no way to test or verify this and I dont know if anyone else has reported. @DanGRT ?

github-actions[bot] commented 3 months ago

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. See our contributing guidelines for more details.