mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-08 23:21:58 +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
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel (or oxc when used in rolldown-vite) for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])