wallento / sungrow-websocket

Python Library to acees the websocket interface of Sungrow inverters
MIT License
7 stars 3 forks source link

No longer working #7

Open kalaws opened 1 month ago

kalaws commented 1 month ago

The script seems no longer to work since I updated to the latest SW for the WiNet-S module on my SH10RT. Anyone else having problems? @damolp ?

        async with websockets.client.connect(
            f"ws://{self.host}:{self.port}/ws/home/overview"
        ) as websocket:
            await websocket.send(
                json.dumps(
                    {"lang": self.locale, "token": "", "service": "connect"}
                )
            )
            d: Result = json.loads(await websocket.recv())
            if d["result_code"] != 1 or d["result_msg"] != "success":
                return data
            token: str = d["result_data"]["token"]
            print(d)
            await websocket.send(
                json.dumps(
                    {
                        "lang": self.locale,
                        "token": token,
                        "service": "devicelist",
                        "type": "0",
                        "is_check_token": "0",
                    }
                )
            )
            d = json.loads(await websocket.recv())
            print(d)

returns

{'result_code': 1, 'result_msg': 'success', 'result_data': {'service': 'connect', 'token': '****redacted****', 'uid': 1, 'tips_disable': 0, 'virgin_flag': 0, 'isFirstLogin': 0, 'forceModifyPasswd': 0}}
{'result_code': 401, 'result_msg': 'I18N_COMMON_INTER_ABNORMAL', 'result_data': {'service': 'devicelist'}}
{"Body": {}}
kalaws commented 1 month ago

Potentially the problem is related to authentication. Compare the following (I’m not sure myself how to implement this):

https://github.com/bohdan-s/SungrowModbusWebClient/compare/main...caliph9k:SungrowModbusWebClient:main

mbaul commented 1 month ago

I've also noticed this. I'm keen to hear if there is an update available and happy to help in testing.