olibos / Home-Assistant-FusionSolar-OpenApi

Integrate FusionSolar into your Home Assistant.
MIT License
8 stars 0 forks source link

Refactoring API management #3

Open olibos opened 1 year ago

olibos commented 1 year ago

Tasks:

Source: @fmarton https://github.com/olibos/Home-Assistant-FusionSolar-OpenApi/issues/1#issuecomment-1283459514

fmarton commented 1 year ago

As I see api send:

  1. the same errorcode (403) in case of expired Token and too many KPI request. too many request. So token should be refreshed by timer. If there is only one api client it is in 1 request/min limit.

  2. StationCode doesnt matter (getDevRealKpi).

  3. wrong DevId, data is empty 200 {'data': [], 'failCode': 0, 'message': None, 'params': {'currentTime': 1666167050027, 'devIds': 'xxx', 'devTypeId': 1}, 'success': True}

  4. wrong DevType, data is none 200 {'data': None, 'failCode': 20006, 'message': None, 'params': {'currentTime': 1666166945489, 'devIds': 'xxx', 'devTypeId': 1345}, 'success': False} "6 20006 Some devices do not match the device type."

I cannot test if there are more devices.

fmarton commented 1 year ago

Sorry, it is not working stably, dont use

post getDevRealKpi return this message if the token is not valid. { "failCode": 305, "immediately": true, "message": "USER_MUST_RELOGIN" }

So you can request new token when you get this error message, schedule is not necessary.

fmarton commented 1 year ago

I hided my comments in this topic. I think the limits should be enough for operating this integration when no more api client. I think token request in every 5 mins is more simplier than any other solution. Static DevID, DevType shouldnot be complicated development (same than stationCode). A script may be enogh that get the right parameters. user can copy them into the configuration.yaml. Set this feature lower proirity. Thank you Ferenc