Skip to content

Dev#12

Merged
azebro merged 7 commits into
mainfrom
dev
Mar 5, 2026
Merged

Dev#12
azebro merged 7 commits into
mainfrom
dev

Conversation

@azebro
Copy link
Copy Markdown
Owner

@azebro azebro commented Mar 5, 2026

This pull request introduces a proactive midnight reset mechanism for daily energy sensors in the PyTap Home Assistant integration. The daily energy and readings sensors now zero out at exactly midnight local time, ensuring accurate daily totals even when no power reports arrive overnight (a common scenario for solar panels). The coordinator schedules and manages a midnight reset timer, updates documentation and dashboards to reflect these changes, and adds new tests to cover the reset logic.

Midnight Reset Feature:

  • Added _schedule_midnight_reset() and _perform_midnight_reset() methods to PyTapDataUpdateCoordinator in coordinator.py to schedule and execute a daily reset of energy accumulators at local midnight. The reset zeroes daily_energy_wh and readings_today for all nodes, updates sensors, and reschedules itself for the next midnight. The timer is started on listener startup and cancelled on shutdown. [1] [2] [3] [4]
  • Updated README.md and docs/architecture.md to document the proactive midnight reset behavior, replacing the previous lazy reset and clarifying timing semantics. [1] [2] [3] [4]

Dashboard and Template Sensor Updates:

  • Added a new "Panel Power" dashboard page and template sensor (sensor.tigo_max_power) to visualize live power output per panel, with color scaling formulas and YAML anchors for power tiles. Increased panel count references from 24 to 26 throughout the documentation. [1] [2] [3] [4] [5]

Documentation and Test Coverage:

  • Updated implementation documentation to describe the midnight reset timer, coordinator code size, and expanded persistence test coverage. Added a new section detailing the proactive midnight reset feature and its rationale. [1] [2] [3] [4] [5] [6] [7] [8]

Minor Code and Test Fixes:

  • Fixed a property name in sensor.py from key to value_key for correct sensor value mapping.
  • Updated test imports and test counts in test_coordinator_persistence.py to support new midnight reset tests. [1] [2] [3]

@azebro azebro merged commit d9e7f0a into main Mar 5, 2026
8 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.

2 participants