reading an inverter setting through API returns -1 ?

7 comments started 2024-02-20 last 2024-02-21
APIsHome Automation
D
#1 DD

My scripts didn't work last night. Got an unexpected -1 value when reading the value of a setting. The API docs describe what happens when an attempt to modify a setting goes wrong (the 'success' field contains 'False' and the 'message' field says what went wrong).

Reproduced it today by just slowly iterating through the settings, reading one at a time, and one or two return -1. No additional fields to say it failed or anything. Is this known/intended behaviour?

D
#3 DD

hoggy Yes it is, it means "maybe I did it"

Hmm - I'd interpreted that as only applying to the case of multiple devices. But fair enough - my script failed with a -2 and I was wondering where that had come from.

R
#4 Rubikcube

When you get a -1 response from the API, you just need to send the same command again.

Sometimes the inverter plays deaf and just ignores a request. The error rate figures on my app can give an indication of how deaf your inverter is. I think 1% to 5% is normal, and you should expect the same error rate through the API.

To you it will seem random, however it is firmware bugs not network issues, and I can prove that because in one test version of my app I managed about a 98% error rate!

T
#5 TX200

Could it also be because something else was talking at the same time? E.g. portal updates, local comms e.g. home assistant, local mode app, etc - occasionally colliding?

D
#6 DD

TX200 yes, I reproduced the timeout by running the app while running API queries. When it first went wrong, the read returned -2 and the subsequent modify reported inverter offline.

#7 Wonder Watt

TX200 This is definitely something that affects it. Initially, we were making multiple async calls (for sake of scalability etc.) for the same Giv inverter to the API, but ran into a good amount of these. So much so, we had to implement sync equivalents.

And retry policies. 😉