Skip to content

Dev#115

Merged
KJonline merged 26 commits intomasterfrom
dev
Mar 6, 2026
Merged

Dev#115
KJonline merged 26 commits intomasterfrom
dev

Conversation

@KJonline
Copy link
Copy Markdown
Contributor

No description provided.

Khole Jones and others added 26 commits February 14, 2026 17:56
Migrated from custom Logger class to Python's standard logging module across all components. Added _LOGGER instances to action, alarm, api, auth, camera, device_attributes, heating, and other modules. Updated error handling calls from session.log.error() to _LOGGER.error() and session.log.errorCheck() to session.helper.errorCheck(). Added debug logging for API requests, authentication flows, and device state changes.
Created dev-publish.yml workflow for building and publishing development packages from non-master branches. Includes guard job to block execution on master branch, build job to create distribution packages, and publish job to upload to PyPI using trusted publishing.
Enhanced error handling for authentication failures with dedicated HiveAuthError exception for 401/403 responses. Added retry logic with device re-login fallback when token refresh fails. Improved logging with token length/tail debug output and response body snippets in error messages. Refactored header construction to reduce duplication. Changed initial tokenCreated to datetime.min for clearer expiry logic. Added HiveReauthRequired propagation and
Changed version from "1.0.8_dev_2" to "1.0.8.dev2" to follow PEP 440 standard for development release identifiers.
Added detailed debug logging for token expiry checks showing current time vs expiry time. Expanded refresh logging to display token creation time, actual expiry, early refresh threshold (×0.95), and current time for better troubleshooting of token refresh timing issues.
…evices

Added ClientTimeout(total=10) to all API requests to prevent indefinite hangs. Enhanced offline device handling in climate, hotwater, light, plug, and sensor modules to return cached state when devices are offline. Added asyncio.TimeoutError handling in getAllNodes() and updateData() to preserve cached data on timeout. Improved logging messages to distinguish between session token and Cognito token operations. Reorganized device
…detection

Added request duration logging to API calls showing method, URL, duration, and HTTP status. Implemented slow poll detection that marks polls as slow when API responses exceed 8 seconds or timeout occurs. Modified offline device caching in climate, hotwater, light, plug, and sensor modules to only return cached state during slow polls. Added _lastPollSlow session flag to track API performance and prevent stale data during
…holds

Reduced API request timeout from 10s to 5s to fail faster on network issues. Lowered slow poll detection threshold from 8s to 3s to more aggressively identify performance problems and trigger cached state fallback.
… temperature validation

Added setdefault() calls to ensure device status dictionaries exist with None values when devices are offline or slow polls occur, preventing KeyError exceptions. Implemented temperature value validation in getCurrentTemperature() to catch and log non-numeric values before processing. Added None checks in getState() before comparing temperatures. Reduced API timeout from 10s to 5s and fixed timeout parameter
…ctly

When hiveRefreshTokens falls back to deviceLogin due to an expired/invalid
refresh token, device_login calls login() which can return an AuthenticationResult
directly (no device challenge) when device tracking is not enforced by the
Cognito user pool. Previously this case fell through to the else branch and
raised HiveInvalidDeviceAuthentication, preventing the integration from loading.

Also handle SMS_MFA challenge in device_login by raising HiveReauthRequired
so Home Assistant can trigger a proper re-auth flow for accounts with 2FA enabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…try logic

Added detailed token logging in updateTokens() showing token lengths and tails for IdToken, AccessToken, and RefreshToken. Enhanced login, 2FA login, device login, and token refresh logging to display AuthenticationResult keys. Implemented exponential retry logic (0s, 2s, 5s delays) for API calls after device re-login to handle transient authentication failures. Moved slow poll threshold to configurable instance variable _
…ble with forced refresh support

Added force_refresh parameter to hiveRefreshTokens() to allow bypassing expiry checks. Made refresh threshold configurable via _refreshThreshold instance variable (default 0.90, down from 0.95). Enhanced refresh logging to show threshold multiplier and force_refresh flag. Modified _retryDeviceLogin() to call hiveRefreshTokens(force_refresh=True) after device login. Added guard to prevent recursive
…h adjusted retry delays

Added float conversion validation in getTargetTemperature() to catch and log non-numeric target/heat values before processing, returning None for invalid data. Changed retry delay sequences from (0, 2, 5) to (0, 5, 10) seconds for API calls after device re-login and from (0, 5, 15) to (0, 5, 10) seconds for device login retries to reduce total retry time while maintaining adequate spacing.
Fix device_login failing when login returns AuthenticationResult directly
Alphabetized exception imports in hive_auth_async.py and added blank line after standard library imports in session.py to separate them from third-party imports.
Alphabetized exception imports in hive_auth_async.py and added blank line after standard library imports in session.py to separate them from third-party imports.
…e-metadata

Extract NewDeviceMetadata in login() for when 2FA isn't enforced
…ent poll protection

Replaced global devices dict with entityCache keyed by haType|hiveID|hiveType to enable per-entity caching. Added shouldUseCachedData() to return cached state during slow polls or when another task holds the update lock, preventing redundant API calls. Implemented getCachedDevice() and setCachedDevice() helper methods with _entityCacheKey() for consistent cache key generation. Updated all device types (action
Bump version to 1.0.8 and implement entity-level caching with concurr…
@KJonline KJonline merged commit 7b7323e into master Mar 6, 2026
28 of 30 checks passed
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.

3 participants