Sense Collector provides a way of collecting real-time data from the Sense Energy Monitor. Includes Grafana dashboards for visualizations of detected devices and smart plugs and their wattage, voltage, and amp utilization.
Implemented renew_token and periodic_token_renewal methods in SenseCollector to handle automatic token renewal at every specified interval.
The token renewal interval is set to 12 hours (43200 seconds) by default, but it can be customized via environment variables.
Logging added to track token renewal actions and intervals.
Bug Fixes
Fixed issue with environment variable comparison:
Corrected logic for case-insensitive comparison of environment variables to ensure proper detection of custom values.
Resolved issue where token renewal interval (SENSE_COLLECTOR_API_TOKEN_RENEW) was obscured incorrectly.
Logging Improvements
Improved logging in main function:
Added debug logs for each step in the main function to provide detailed tracing of the initialization process.
Enhanced logging messages for authentication and environment variable retrieval.
Added logging for individual tasks within the asyncio.gather call to ensure visibility into task startup.
Docker and Build Script Adjustments
Updated Dockerfile for new directory structure:
Moved Dockerfile to a parent directory and adjusted paths to copy necessary files from the src directory properly.
Refined build script:
Transitioned build script from bash to Python for better readability and error handling.
Ensured real-time output during the build and push commands using subprocess.Popen for command execution.
New Environment Variables
SENSE_COLLECTOR_API_TOKEN_RENEW:
Interval in seconds for token renewal. Default set to 43200 seconds (12 hours).
General Improvements
Improved error handling and robustness:
Added error handling for all subprocess calls within the build script to ensure proper reporting and exit on failure.
Enhanced visibility into Docker build and push processes by merging stdout and stderr streams and ensuring immediate output flushing.
Documentation Updates
Updated README and examples:
Examples of new environment variables and their usage were included.
Added documentation for new token renewal functionality and configuration.
Release Notes
Version 2.0.07 - Token Refresh
Enhancements
renew_token
andperiodic_token_renewal
methods inSenseCollector
to handle automatic token renewal at every specified interval. The token renewal interval is set to 12 hours (43200 seconds) by default, but it can be customized via environment variables.Bug Fixes
SENSE_COLLECTOR_API_TOKEN_RENEW
) was obscured incorrectly.Logging Improvements
main
function:main
function to provide detailed tracing of the initialization process.asyncio.gather
call to ensure visibility into task startup.Docker and Build Script Adjustments
Dockerfile
to a parent directory and adjusted paths to copy necessary files from thesrc
directory properly.subprocess.Popen
for command execution.New Environment Variables
General Improvements
Documentation Updates