macxq / foxess-ha

Home Assistant & FoxESS integration. Monitor you photovoltaic installation directly from HA ☀️ ⚡️
115 stars 37 forks source link

Bad response: {'errno': 41200, 'msg': 'Query data failed' ,'result' : 'None} #226

Closed rjhazeld closed 6 months ago

rjhazeld commented 7 months ago

Updated the integration last Friday. No data since. The error 41200 isn't listed as far as I can find. There are two inverters, both H1-5.0-E. One has a battery stack the other doesn't. Both are working normally. This is the HA Log for one pair of requests: 2024-02-24 09:35:37.747 DEBUG (MainThread) [custom_components.foxess.sensor] Finished fetching FoxESS data in 0.355 seconds (success: True) 2024-02-24 09:35:38.520 DEBUG (MainThread) [custom_components.foxess.sensor] Updating data from https://www.foxesscloud.com/ 2024-02-24 09:35:38.520 DEBUG (MainThread) [custom_components.foxess.sensor] Time now: 9, last 0 2024-02-24 09:35:38.520 DEBUG (MainThread) [custom_components.foxess.sensor] TimeSlice Main Poll, interval: 65BH502025JB???, 0 2024-02-24 09:35:38.520 DEBUG (MainThread) [custom_components.foxess.sensor] OADevice Detail fetch https://www.foxesscloud.com/op/v0/device/detail?sn=65BH502025JB133 2024-02-24 09:35:39.181 DEBUG (MainThread) [custom_components.foxess.sensor] OA Device Detail Bad Response: {'errno': 41200, 'msg': 'Query data failed', 'result': None} 2024-02-24 09:35:39.182 WARNING (MainThread) [custom_components.foxess.sensor] FoxESS1 has Cloud timeout or the Inverter is off-line, connection will be retried in 1 minute. 2024-02-24 09:35:39.182 DEBUG (MainThread) [custom_components.foxess.sensor] Auxilliary TimeSlice 65BH502025JB133, -1 2024-02-24 09:35:39.182 DEBUG (MainThread) [custom_components.foxess.sensor] {'report': {}, 'reportDailyGeneration': {}, 'raw': {}, 'battery': {}, 'addressbook': {'hasBattery': False}, 'online': False} 2024-02-24 09:35:39.182 DEBUG (MainThread) [custom_components.foxess.sensor] Finished fetching FoxESS data in 0.662 seconds (success: True) 2024-02-24 09:36:37.392 DEBUG (MainThread) [custom_components.foxess.sensor] Updating data from https://www.foxesscloud.com/ 2024-02-24 09:36:37.392 DEBUG (MainThread) [custom_components.foxess.sensor] Time now: 9, last 0 2024-02-24 09:36:37.392 DEBUG (MainThread) [custom_components.foxess.sensor] TimeSlice Main Poll, interval: 60BH5020373D??2, 0 2024-02-24 09:36:37.392 DEBUG (MainThread) [custom_components.foxess.sensor] OADevice Detail fetch https://www.foxesscloud.com/op/v0/device/detail?sn=60BH5020373D112 2024-02-24 09:36:38.294 DEBUG (MainThread) [custom_components.foxess.sensor] OA Device Detail Bad Response: {'errno': 41200, 'msg': 'Query data failed', 'result': None} 2024-02-24 09:36:38.294 WARNING (MainThread) [custom_components.foxess.sensor] FoxESS3 has Cloud timeout or the Inverter is off-line, connection will be retried in 1 minute. 2024-02-24 09:36:38.294 DEBUG (MainThread) [custom_components.foxess.sensor] Auxilliary TimeSlice 60BH5020373D112, -1 2024-02-24 09:36:38.294 DEBUG (MainThread) [custom_components.foxess.sensor] {'report': {}, 'reportDailyGeneration': {}, 'raw': {}, 'battery': {}, 'addressbook': {'hasBattery': False}, 'online': False}

The device ID & SN and api were copied and pasted from the foxesscloud.com and manual check shows them to be correct.

It may be the system is not fully running and the error is effectiveley 'not available' but posted in case the cause is something else.

FozzieUK commented 7 months ago

@rjhazeld ok, thanks - i’ve not come across error 41200 so far, but it’s in the device detail request that retrieves the plant/device information and so i’m wondering it is fails when there are multiple devices in the same account.

Is that how your system is configured, one api_key for your account being used for both platform statements with different inverter serial numbers ?

FozzieUK commented 7 months ago

@rjhazeld also noted that in one of the requests the inverter serial numbers have ?? at the end of them,

2024-02-24 09:36:37.392 DEBUG (MainThread) [custom_components.foxess.sensor] TimeSlice Main Poll, interval: 60BH5020373D??2, 0

Can you double check your inverter serials numbers please - and manually type them in to make sure there are no strange characters trailing them that could have been copied and pasted in.

rjhazeld commented 7 months ago

Sorry, I deleted the last three digits of the actual serial numbers and substituted ??? and ??2 for security (probably OTT). My FoxESS user has two sites with three inverters listed one H1 and an F5000 on one and the other H! on a second. The apiKey is at user level and there doesn't seem to be a site difference. The history is that the installation was one H1 with batteries attached and one F5000 (two strings of 4kw). I spent a year trying to get data direct from the inverters only to find that the F5000 has no capability to do so. I took the decision to ditch the F5000 and have a second H1 which does supply data locally via a serial to ethernet converter. I have kept the F5000 as a contingency against one of the H1 failing and thus it remains on my account. When the switch was done the installers could not add an inverter to the existing site and therefore created a second site. Despite various efforts to do so it hasn't been possible to move the second H1 onto the original site (seems that FoxESS lock the serial number to a site and prevent it being unlocked later. In HA I had the original H! as foxess1 and the F5000 as foxess2 and the second H1 is configured to be foxess3. Initially I added foxess3 but commented foxess2 out when I got an error that the inverter appeared to be offline in case that was the problem since the F5000 is in its box and is indeed offline. Hope this makes sense my aim has been to have both the direct feed and the FoxESS cloud data in the hopes that future FoxESS changes won't leave me without data. Happy to comment out the second H1 to see if it then works if that will help.

FozzieUK commented 7 months ago

@rjhazeld ok, it might be easier to add one in at a time, if I read that correctly you have 2 accounts with H1's in each (plus one has the F5000) - so you'll need api_keys for both accounts.

If you try adding one site at a time, so pick the account with just the H1 in it, and use the api_key and SN for that one - just comment out the others for the moment, restart HA and see if that works ok.

If it does then add the second platform statement for the other H1, with it's api_key and SN and restart and see if that works.

Let me know how you get on with that, i've been able to look up the error code and it unhelpfully states 'query data failed'

rjhazeld commented 7 months ago

No there is one account with 2 sites: site 1 - 1 x H1 + 1 x F5000 site 2 - 1 x H1 I'll change the config later on and let you know the result.

FozzieUK commented 7 months ago

@rjhazeld ok, that is an unusual setup, i've never tested for that use case - but it should still work as it has the api_key for the account and the SN is the unique device/inverter within the account. - let me know how you get on 👍

rjhazeld commented 7 months ago

I have commented out the foxess3 inverter so now just one, restarted and same result and error number. Went to the foxesscloud website --> user profile-->api management and got an error message flash up in red '41201 server exception' it was only visible for seconds. I guess it may have appeared when I generated a fresh key earlier in the weekend. I will keep logging in until I don't get the error message and then generate a new key and see if that resolves the problem.

rjhazeld commented 7 months ago

No change. Whilst the 'standard page' is working normally the api management page is still throwing a 41201 error with the description 'Server Exception' . I haven't found any further information or contact method to report the problem.

FozzieUK commented 7 months ago

@rjhazeld ok, sounds like Fox cloud is having a problem with your account.

On their website can you go into each of your sites and check that plant details are filled out and set correctly - address, Timezone / Currency - the tokens produces timestamps that are relevant to your timezone so it could be something there.

Once that is checked / corrected - log off and on again and see if that clears the problem.

If not i'm afraid it will be a support ticket to Foxess to resolve the issue.

Can you report back what happens please, I suspect this may happen to other users and it will be good to know how to correct it.

rjhazeld commented 6 months ago

Just an update I'm afraid. The 'plant' data is correct and consistent with each other. The H1s show correct individual data on the Foxesscloud web page and apps.

I resorted to asking Foxess support to 1) move the new H1 to the same site as the other and delete the unneeded second site and 2) fix the problem with the API Management page (41201 - server exception) ). This was back on the 28th February. Their first reaction was that is was best to keep two sites but after repeating why I wanted it moving I got message back saying it should be moved...unfortunately it had not. I have chased them twice to get it done without success or any form of reply.

Regarding the api page this was their reply 'Our foxcloud is not being phased out there has been changes to our api so any third parties using our api would have to use the new version of our api but you can continue to use the fox cloud as this will not be phased out. '

At this point in time I can't use the integration and one site shows a red dot indicating and error but does not list one in either of the inverters s I assume that it is something to do with the API Management page error. All deeply frustrating.

I will persevere trying to get FoxESS suport to sort out the issues without any confidence they will. I'll update if any progress is made.

FozzieUK commented 6 months ago

Ahhh sorry to hear your having such a trial, yes as they said they closed the old api to 3rd parties and introduced the openapi for all non foxess traffic. They have had a busy week fixing and moving things so hopefully it will all settle down going forwards. There are probably close on a thousand users (for both the energy stats app and home assistant) and they are working fine, so the moment you can get an api_key you can use you should be on-line. Thanks for the update, please post back when you know more.

rjhazeld commented 6 months ago

No contact from FoxESS but some progress!!! I am not sure when but recently the problem that was creating an error when accessing the API management page was fixed. Happily the api that I had put in the HA configuration.yaml was correct and data was flowing. I had commented out the new H1 and the old F5000 so removed the comment. After a restart data started to flow for the new H1 but nothing for the old F5000. I suspect that means the previously collected data will have been lost but at least the current set up is now working.

Just the two site issue to get sorted now get to a normal situation.

FozzieUK commented 6 months ago

ok great, glad it was sorted 👍