Releases: jsight/ha-pecron
v0.4.1: Split AC and DC Input Power Sensors
What's New
Split Input Power Sensors
New sensors that break down input power by source, matching the official Pecron app:
- AC Input Power — Grid/AC charging power (W)
- DC Input Power — Solar/DC input power (W)
Both sensors extract values from the ac_data_input_hm and dc_data_input_hm STRUCT properties already reported by the device. TSL-based discovery ensures they only appear for devices that support them.
The existing Input Power (total) sensor remains unchanged.
Closes #3 — thanks @mrVoltrix for the suggestion!
Full Changelog
https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
🤖 Generated with Claude Code
v0.4.0: AC Charge Speed Control
What's New
AC Charge Speed Control
New select entity to control AC charging power level with options: 0%, 25%, 50%, 75%, 100%.
- Optimistic UI updates with settling period for smooth UX
- Delayed refreshes to reconcile actual device state
- TSL-based discovery — only created for devices that support
ac_charging_power_ios - Addresses feature request #1
Dependency Update
- Upgraded to
unofficial-pecron-apiv0.3.0
Full Changelog
https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
🤖 Generated with Claude Code
v0.3.5: Eliminate UI Flicker
Fixed
- Eliminated UI flicker during switch toggles
- Problem: Switches showed ON → OFF → ON pattern when toggling
- Root cause: Immediate coordinator refresh returned stale state, clearing optimistic update
- Solution: 20-second settling period keeps optimistic state while device processes change
- Stale coordinator updates ignored during settling period
- UI now shows smooth ON/OFF transitions without flickering back to old state
- Switch state synchronization now rock-solid with optimistic updates + settling period + delayed refreshes
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
v0.3.4: Enhanced Switch State Sync
🔄 Enhanced Fix: v0.3.4 - Guaranteed Switch State Sync
Since optimistic updates alone didn't work, added scheduled polling to ensure UI syncs!
🛠️ What Changed
Multi-Layer Approach
When you toggle a switch, we now do 4 things to ensure the UI updates:
- Instant (0s): Optimistic UI update → Immediate feedback ⚡
- Immediate (0s): Trigger coordinator refresh → Try to sync now
- Delayed (5s): Scheduled refresh → Device has time to process 🕐
- Confirmation (15s): Final refresh → Catch slow responses ✅
Why This Works
- Optimistic update: Instant visual feedback (even if it doesn't always trigger)
- 5 second refresh: Gives device time to actually change state
- 15 second refresh: Confirmation that state persisted
- Catches edge cases: Slow device responses, API delays, UI glitches
📊 Timeline Example
0s: You toggle AC Output ON
→ UI shows ON (optimistic)
→ Request refresh (immediate)
5s: → Scheduled refresh polls device
→ Device confirms: AC is ON
→ UI confirms: ON ✓
15s: → Final refresh (confirmation)
→ State: ON ✓
📦 Upgrade
This should definitely fix the UI sync issue!
- Update to v0.3.4 via HACS
- Reload integration
- Toggle switches → UI should update within 5 seconds max
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
Try it out! The UI should sync reliably now. 🎯
v0.3.3: Instant Switch Updates
🔧 Critical Fix: v0.3.3 - Instant Switch Updates
Fixes the annoying issue where toggling switches didn't update the UI!
🐛 Bug Fixed
Problem: Toggling AC/DC switches sent the command successfully, but the UI still showed the old state until the next scheduled refresh (up to 10 minutes later).
Solution: Implemented optimistic UI updates for instant feedback.
✨ How It Works Now
- You toggle a switch → UI updates instantly ⚡
- Command sent to device → Happens in background
- If successful → Coordinator refreshes to confirm actual state
- If failed → UI automatically reverts + shows error notification
🎯 User Experience
Before:
- Toggle switch
- UI shows old state
- Wait up to 10 minutes for UI to update 😤
After:
- Toggle switch
- UI updates immediately ✨
- Confirmed by device within seconds
- Auto-reverts if command fails
📦 Upgrade
This is a critical UX fix - highly recommended!
Via HACS:
- Update to v0.3.3
- Reload integration
Via Manual:
- Download and extract
- Copy to
custom_components/pecron - Restart Home Assistant
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
Enjoy responsive switches! 🎉
v0.3.2: Smart Time Sensors
🧠 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:
- Update to v0.3.2
- Reload integration (Settings → Devices & Services → Pecron → Reload)
Via Manual:
- Download and extract
- Copy to
custom_components/pecron - Restart Home Assistant
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
Enjoy smarter time sensors! 🎉
v0.3.1: Critical Fix - Switches Not Appearing
🔧 Critical Patch Release: v0.3.1
This emergency patch fixes a critical bug in v0.3.0 where switches and some sensors didn't appear after integration reload.
🐛 Bug Fixed
Problem: After upgrading to v0.3.0 and reloading the integration, users only saw 5 sensors and no switches (AC Output, DC Output).
Root Cause: The TSL (Thing Specification Language) uses property codes with _hm suffix (e.g., ac_switch_hm, dc_switch_hm, ups_status_hm), but the unofficial-pecron-api maps these to properties without the suffix. Our TSL filtering was too strict and only checked exact matches, causing entities to be filtered out.
Solution: TSL filtering now checks both property_name and property_name_hm variants.
✅ What's Fixed
- ✅ AC Output switch now appears
- ✅ DC Output switch now appears
- ✅ UPS Mode binary sensor now appears
- ✅ All supported sensors are created properly
🚀 Upgrade Instructions
If you're on v0.3.0 and don't see your switches:
- Update to v0.3.1 (via HACS or manual installation)
- Reload the integration:
- Go to Settings → Devices & Services
- Find Pecron integration
- Click three dots → Reload
- Verify: You should now see AC Output and DC Output switches
📝 Changed Files
custom_components/pecron/switch.py- Fixed TSL filtering for switchescustom_components/pecron/binary_sensor.py- Fixed TSL filtering for binary sensorscustom_components/pecron/sensor.py- Fixed TSL filtering for sensors
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
Apologies for the inconvenience caused by v0.3.0. This fix ensures the new control features work as intended! 🙏
v0.3.0: Control Features and Dynamic Discovery
🎉 Major Feature Release: v0.3.0
This release adds device control capabilities and intelligent entity discovery to the Pecron Home Assistant integration.
✨ New Features
🎛️ Controllable Switch Entities
- AC and DC outputs are now controllable switches (previously read-only)
- Turn power outputs on/off directly from Home Assistant
- Create automations to control outputs based on conditions (e.g., "turn off AC when battery < 20%")
- Enhanced error handling with persistent notifications
🔧 Advanced Control Service
- New
pecron.set_propertyservice for power users - Control any writable device property via automations or scripts
- Automatic TSL validation ensures only valid properties are modified
- Smart type conversion (handles boolean strings, numbers, etc.)
🔍 TSL-Based Dynamic Discovery
- Integration now queries device capabilities automatically
- Only creates entities your device actually supports
- No more 'unavailable' entities cluttering your interface
- Automatically supports new device models without code changes
🐛 Bug Fixes
- Fixed critical token refresh issue: Authentication errors during property fetching now properly trigger token refresh (not just during initial device fetch)
- Improved error detection for all auth error patterns (5032, token, 401, unauthorized, authentication)
- Case-insensitive error matching ensures reliable recovery
🔄 Changes
- Breaking: AC and DC outputs moved from
binary_sensortoswitchplatform- Old entities will be removed, new switch entities will be created
- Update your automations to use the new switch entities
- Binary sensors now only include UPS Mode and Online status (read-only properties)
- Upgraded to unofficial-pecron-api v0.2.0
🧪 Developer Improvements
- Comprehensive test suite for token refresh (16 new tests)
- Improved test coverage overall (25 tests passing)
- Enhanced logging for diagnostics
📦 Installation
Via HACS (Recommended)
- Open HACS → Integrations
- Find "Pecron" and update to v0.3.0
- Restart Home Assistant
Manual Installation
- Download the latest release
- Copy
custom_components/pecronto your HA config directory - Restart Home Assistant
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
v0.2.5
Bug Fixes
- Fixed token refresh detection for error 5032: Enhanced automatic token refresh to properly detect API error 5032 (Token validation failed). The previous implementation only caught "authentication", "401", or "unauthorized" errors, but missed the specific error code 5032 that the Pecron API returns when tokens expire. Now also checks for "5032" and "token" keywords in error messages, ensuring expired tokens are automatically refreshed.
Changes
- Updated token refresh error detection in coordinator
- Improved error handling for token expiration scenarios
This release ensures more reliable automatic token refresh when the Pecron API returns token validation errors.
v0.2.4
Fixed
- Automatic token refresh when Pecron API authentication expires
- Integration now handles expired tokens gracefully without requiring manual reload or restart
- Added retry logic (up to 2 attempts) to recover from transient authentication failures
- Improved logging to distinguish between initial login and token refresh operations