mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-03 04:31:28 +02:00
Home Assistant smart plugs can now use separate sensor entities for energy monitoring, enabling energy tracking for plugs that expose power/energy data as separate sensors (Tapo, IKEA Zigbee2mqtt, etc.). Features: - Configure dedicated power (W), today (kWh), and total (kWh) sensors - New API endpoint GET /api/v1/smart-plugs/ha/sensors lists available sensors - Falls back to switch entity attributes if no sensors configured - Print energy tracking now works for HA plugs (not just Tasmota) Backend: - Added ha_power_entity, ha_energy_today_entity, ha_energy_total_entity fields to SmartPlug model - Updated get_energy() to fetch from configured sensor entities - Added _get_plug_energy() helper to handle both plug types - Updated backup/restore to include new fields - Added database migration for new columns Frontend: - Added energy sensor dropdowns in AddSmartPlugModal (shown for HA plugs) - Dropdowns filtered by unit (W/kW for power, kWh/Wh for energy) Tests: - Added 4 new integration tests for HA energy sensor functionality Docs: - Updated README with new feature - Updated CHANGELOG with 0.1.6b11 entry