WattWise
Una herramienta CLI ligera para monitorear el consumo de energía de enchufes inteligentes en tiempo real, ya sea directamente o a través de Home Assistant.
Demo

Características
- Monitoreo en tiempo real del consumo de energía con vatios y corriente (amperios)
- Múltiples opciones de conexión:
- Conexión directa a enchufes inteligentes TP-Link Kasa
- Conexión a través de Home Assistant
- Visualización dinámica del consumo codificada por colores (verde < 300W, amarillo 300-1200W, rojo > 1200W)
- Monitoreo continuo con gráficos y datos históricos
- Interfaz sencilla de línea de comandos
Instalación
Via pip
pip install .
Usando Docker
# 1. Build the Docker image (from project directory)
docker build -t wattwise .2. Create directories for persistence (first time only)
mkdir -p ~/.config/wattwise
mkdir -p ~/.local/share/wattwise3. First time setup: Configure a data source
Configure Home Assistant
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise config haOR Configure Kasa smart plug
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise config kasaOptional: Add additional devices (multi-device config)
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise devices add --name "PC" --type kasa --ip 192.168.1.50docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise devices add --name "Server" --type homeassistant \
--host http://homeassistant.local:8123 \
--token $HA_TOKEN \
--entity-id sensor.server_power \
--current-entity-id sensor.server_current
4. Run a single check with Docker
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise5. Run with continuous monitoring
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise --watch6. If you have permission issues, you can fix them with:
sudo chown -R $USER:$USER ~/.config/wattwise ~/.local/share/wattwise
chmod -R u+rw ~/.config/wattwise ~/.local/share/wattwiseOr using the built-in command:
docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise config fix-permissionsDesinstalación
Desinstalación Completa
Para una eliminación rápida y completa de WattWise incluyendo contenedores Docker, imágenes y toda la configuración:
# Make the script executable (first time only)
chmod +x clean_uninstall.shRun the uninstallation script
./clean_uninstall.shEste script eliminará todos los contenedores Docker de WattWise, la imagen Docker, archivos de configuración y datos. También detectará y ofrecerá desinstalar cualquier instalación de WattWise vía pip.
Desinstalación Manual
#### Vía pip
# Uninstall the package
pip uninstall wattwiseRemove configuration files if desired
rm -rf ~/.config/wattwise
rm -rf ~/.local/share/wattwise#### Docker
# Remove the Docker image
docker rmi wattwiseRemove local configuration if desired
rm -rf ~/.config/wattwise
rm -rf ~/.local/share/wattwiseUso Básico
Configuración Inicial
# Configure Home Assistant connection
wattwise config haOR Configure Kasa smart plug
wattwise config kasaMonitoreo
# Quick power view (single reading)
wattwiseTo discover the kasa devices on your local network
wattwise --discoverContinuous monitoring with charts
wattwise --watchMonitor current (amperes) as well
wattwise --current --watchSet refresh interval (seconds)
wattwise --watch --interval 5Output only raw watt value (for scripting use)
wattwise --rawContinuous raw monitoring (output a new value every second)
wattwise --raw --watchSpecify data source manually
wattwise --source homeassistant
wattwise --source kasaManage multiple devices
wattwise devices list
wattwise devices add --name "PC" --type kasa --ip 192.168.1.50
wattwise devices add --name "Server" --type homeassistant \
--host http://homeassistant.local:8123 \
--token $HA_TOKEN \
--entity-id sensor.server_power \
--current-entity-id sensor.server_current
wattwise --device "PC"Requisitos
- Python 3.11 o superior
- Un enchufe inteligente TP-Link Kasa conectado a tu equipo
- Opcional: Configuración de Home Assistant con la integración Kasa
Configuración
La configuración se almacena en ~/.config/wattwise/config.yaml e incluye:
- Detalles de conexión de Home Assistant (URL, token, IDs de entidad)
- Detalles del dispositivo Kasa (dirección IP)
- Los tokens de autenticación se almacenan de forma segura
Consejos para el uso con Docker
Crear un alias para un uso sencillo
Puedes crear un alias bash para un uso más fácil:
# Add to your .bashrc or .zshrc file
alias wattwise='docker run -it --rm --network host \
-v ~/.config/wattwise:/root/.config/wattwise \
-v ~/.local/share/wattwise:/root/.local/share/wattwise \
wattwise'After creating the alias, you can use it just like the normal command:
wattwise # Single reading
wattwise --watch # Continuous monitoring
wattwise config fix-permissions # Fix directory permissions
wattwise --device "PC" # Target a specific configured deviceLicense
MIT
--- Tranlated By Open Ai Tx | Last indexed: 2026-05-01 ---