Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'back' in apiResponse without 'data' or 'plantId' #33

Closed
JoostDkr opened this issue Nov 28, 2022 · 2 comments
Closed

'back' in apiResponse without 'data' or 'plantId' #33

JoostDkr opened this issue Nov 28, 2022 · 2 comments

Comments

@JoostDkr
Copy link

Sometimes I got a Phython-error in the log on line: self.plantId = apiResponse["back"]["data"][0]["plantId"]
the cause was: the apiResponse contail a 'back' element but no "data" or "plantId".

In order to prevent this Phython-error, I changed the line " if ('back' in apiResponse):" in "if ('back' in apiResponse and strData.find('data') > -1 and strData.find('plantId') > -1):"

Now i do not receive a Phyton-error any more, instead of that I got last night a proper exeption:
Not received anything usefull!: {"back":"503","succes":false}}

@sincze
Copy link
Owner

sincze commented Dec 17, 2022

Thanks for your insights.
So just 1 line change and we are good to go?

OLD:

   try:
                if ('back' in apiResponse):              
                #if not ['back']['success']:
                #    Domoticz.Log("Login Failed")
                #elif ('back' in apiResponse):       

NEW:

   try:
                if ('back' in apiResponse and strData.find('data') > -1 and strData.find('plantId') > -1):
                #if not ['back']['success']:
                #    Domoticz.Log("Login Failed")
                #elif ('back' in apiResponse):                  

sincze added a commit that referenced this issue Dec 17, 2022
Implemented Tip from JoostDkr to fix (Issue #33)
@JoostDkr
Copy link
Author

Yep!

@sincze sincze closed this as completed Dec 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants