Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add logout API method #107

Closed
wants to merge 7 commits into from

Conversation

rhpijnacker
Copy link
Contributor

While running the Getting Started example, the KPN Box 12 keeps returning XMO_MAX_SESSION_COUNT_ERR errors.
This is simply fixed by adding a logout API method and calling this in a try / finally block.

sagemcom_api/client.py Outdated Show resolved Hide resolved
@iMicknl
Copy link
Owner

iMicknl commented Dec 2, 2021

Thanks @rhpijnacker! Do you use this with Home Assistant as well, or just in a seperate Python script?

@rhpijnacker
Copy link
Contributor Author

@iMicknl, I am testing this using the example script on the GitHub page. The ultimate goal would be to use this in Home Assistant.

@iMicknl
Copy link
Owner

iMicknl commented Dec 2, 2021

Oops, I missed that you replied here; iMicknl/ha-sagemcom-fast#19 (comment).

Happy to merge it in and bring it to HA.

}

response = await self.__api_request_async([actions], True)
data = self.__get_response(response)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this __get_response is not actually necessary?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove it indeed, since we don't do anything with the response. What is the response?

Not sure if we want to throw a bool (True/False depending on the logout result).

sagemcom_api/client.py Outdated Show resolved Hide resolved
@@ -172,10 +172,6 @@ def __get_response_value(self, response, index=0):

async def __api_request_async(self, actions, priority=False):
"""Build request to the internal JSON-req API."""
# Auto login
if self._server_nonce == "" and actions[0]["method"] != "logIn":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been removed? :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iMicknl
Copy link
Owner

iMicknl commented Dec 27, 2021

This was already part of the other PR I assume :-). Otherwise we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants