github jsight/ha-pecron v0.3.2
v0.3.2: Smart Time Sensors

latest releases: v0.5.0, v0.4.1, v0.4.0...
3 months ago

๐Ÿง  Feature Release: v0.3.2 - Smart Time Sensors

Time sensors are now intelligent! They show N/A when values don't make sense for the current device state.

โœจ New Features

Smart Time Sensor Logic

Time to Full and Time to Empty sensors now adapt based on what your device is doing:

Device State Time to Full Time to Empty
๐Ÿ”Œ CHARGING (plugged in, no load) โœ… Shows time โŒ N/A
๐Ÿ”‹ DISCHARGING (on battery, load active) โŒ N/A โœ… Shows time
โšก UPS MODE (plugged in + load) โœ… Shows time โœ… Shows runtime*
๐Ÿ’ค IDLE (no power flow) โŒ N/A โŒ N/A

* In UPS mode, "Time to Empty" shows how long the battery would last if input power disconnected

Always Visible

  • Both time sensors always appear (no more disappearing based on TSL)
  • Show "Unavailable" only when truly N/A for current state
  • Zero values (0 minutes) indicate battery full/empty, not errors

Robust Edge Case Handling

โœ… Missing property values โ†’ N/A
โœ… Negative power (measurement errors) โ†’ Treated as 0
โœ… None/missing power values โ†’ Treated as 0
โœ… Small power values (1W) โ†’ Still trigger state logic

๐Ÿงช Quality Assurance

  • 18 new comprehensive unit tests covering all scenarios
  • Device states: idle, charging, discharging, UPS mode
  • Edge cases: missing properties, zero/negative/None values
  • All 43 tests passing (25 original + 18 new)

๐Ÿ“ฆ Upgrade

Via HACS:

  1. Update to v0.3.2
  2. Reload integration (Settings โ†’ Devices & Services โ†’ Pecron โ†’ Reload)

Via Manual:

  1. Download and extract
  2. Copy to custom_components/pecron
  3. Restart Home Assistant

Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md

Enjoy smarter time sensors! ๐ŸŽ‰

Don't miss a new ha-pecron release

NewReleases is sending notifications on new releases.