python-sagemcom-api icon indicating copy to clipboard operation
python-sagemcom-api copied to clipboard

F@st 5684 fiber router

Open sanderjo opened this issue 8 months ago • 2 comments

I have a F@st 5684 fiber router

Running the example python script, I get the below:

(venv) sander@zwarte-2504:~/python-sagemcom-api$ python3 python-sagemcom-api.py 
64:FD:96:FA:B5:E0 Fast5684
1C:BF:CE:2F:C3:6D - zwarte-2504
false
{'reply': {'uid': 0, 'id': 4, 'error': {'code': 16777216, 'description': 'XMO_REQUEST_NO_ERR'}, 'actions': [{'uid': 1, 'id': 0, 'error': {'code': 16777238, 'description': 'XMO_NO_ERR'}, 'callbacks': [{'uid': 1, 'result': {'code': 16777238, 'description': 'XMO_NO_ERR'}, 'xpath': 'Device/UserInterface/AdvancedMode', 'parameters': {}}]}], 'events': []}}

EDIT:

Ah, this good?

sanderjo avatar Apr 28 '25 15:04 sanderjo

Interesting:

(venv) sander@zwarte-2504:~/python-sagemcom-api$ cat fast-output.json | python3 -m json.tool
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

So replace single-quote with double-quote, and there is the pretty print JSON:

$ cat fast-output.json | tr "'" '"' | python3 -m json.tool
{
    "reply": {
        "uid": 0,
        "id": 4,
        "error": {
            "code": 16777216,
            "description": "XMO_REQUEST_NO_ERR"
        },
        "actions": [
            {
                "uid": 1,
                "id": 0,
                "error": {
                    "code": 16777238,
                    "description": "XMO_NO_ERR"
                },
                "callbacks": [
                    {
                        "uid": 1,
                        "result": {
                            "code": 16777238,
                            "description": "XMO_NO_ERR"
                        },
                        "xpath": "Device/UserInterface/AdvancedMode",
                        "parameters": {}
                    }
                ]
            }
        ],
        "events": []
    }
}

sanderjo avatar Apr 28 '25 15:04 sanderjo

Yes, or you can use json.dumps(devices) to turn the Python object in JSON>

iMicknl avatar Apr 30 '25 14:04 iMicknl