Update climate.py#29
Open
Big-Szu wants to merge 1 commit into
Open
Conversation
Improved Asynchronous Handling:
Replaced blocking HTTP requests with non-blocking aiohttp requests for better performance and integration with Home Assistant's asynchronous framework.
Session Management:
Introduced a single aiohttp.ClientSession initialized in the __init__ method to avoid repeatedly creating new sessions, which can lead to resource exhaustion.
Added a close method to properly close the session when the component is unloaded.
Token Expiry Handling:
Added logic to detect expired tokens (HTTP 401) and automatically re-authenticate by fetching a new token and retrying the failed request.
Error Handling Enhancements:
Introduced detailed exception handling for network-related issues (aiohttp.ClientError) and JSON decoding errors to prevent the component from crashing and improve error logging.
Concurrency Protection:
Added an asyncio.Lock to ensure that multiple calls to async_update do not lead to race conditions when updating thermostat data.
Content Type Validation:
Enhanced the _get_data method to handle responses with text/html content type that contain valid JSON data, ensuring robust parsing.
Code Refactoring for Logging:
Improved logging by providing more detailed and descriptive messages, including response status and error details, while avoiding logging sensitive data (e.g., tokens).
|
I forked and merged this pr into a new repo https://github.com/kmaid/salusfy which works with hacs and latest HA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improved Asynchronous Handling:
Session Management:
Token Expiry Handling:
Error Handling Enhancements:
Concurrency Protection:
Content Type Validation:
Code Refactoring for Logging: