A comprehensive solution for tracking power usage of multiple users on a wallbox using Shelly Pro 3EM with a switch addon and Shelly BLE buttons.
These scripts enable multi-user power tracking on a standard wallbox by:
- Using Shelly BLE buttons to authenticate different users
- Tracking individual power consumption via Shelly Pro 3EM energy monitoring
- Storing usage data in Shelly's Key-Value Storage (KVS)
- Sending yearly reports via webhook
- Automatically locking/unlocking the wallbox based on usage
All functionality runs directly on the Shelly Pro 3EM - no external server or storage required.
- Shelly Pro 3EM (energy monitoring device)
- Shelly Plus Add-On with switch capability
- Shelly BLE Button 1 (or compatible BLE buttons)
- Wallbox with contactor control
- Install the Shelly Pro 3EM according to manufacturer instructions
- Connect the switch addon to control the wallbox contactor
- Configure the Shelly BLE buttons
- Upload this script to your Shelly Pro 3EM
- Configure the following variables:
notificationScriptId: Set to the ID of NotificationScript.jsblueButton: Set to your first button's component ID (e.g., "bthomesensor:201")redButton: Set to your second button's component ID (e.g., "bthomesensor:203")SWITCH_ID: Set to your switch addon ID (default: 100)
- Adjust constants if needed:
POWER_CHECK_INTERVAL: Time between power checks (default: 15 minutes)POWER_THRESHOLD: Minimum power to consider wallbox in use (default: 10W)
- Upload this script to your Shelly Pro 3EM
- Configure:
webhookUrl: Your webhook endpoint URL for receiving yearly reports
- Note the script ID for use in WallboxManagementScript.js
Run these commands once via Shelly's console to initialize storage:
Shelly.call("KVS.Set", { key: "powerUsageBlue", value: 0 });
Shelly.call("KVS.Set", { key: "powerUsageRed", value: 0 });- User Authentication: User presses their assigned BLE button (blue or red)
- Wallbox Unlock: Script unlocks the wallbox via the switch addon
- Power Monitoring: Script monitors power consumption every 15 minutes
- Auto-Lock: When power drops below threshold, wallbox automatically locks
- Usage Tracking: Total energy consumed is added to user's KVS counter
- Yearly Report: On January 1st at midnight, notification script:
- Retrieves accumulated power usage for both users
- Sends data to configured webhook
- Resets counters for the new year
- Energy data is retrieved from Shelly's EMData API
- Power usage is stored in watt-hours (Wh)
- All operations include error handling and logging
- Scripts use Shelly's event-driven architecture for efficiency
✅ Multi-user power tracking
✅ Automatic wallbox control
✅ No external dependencies
✅ Error handling and logging
✅ Yearly automated reporting
✅ Low power consumption
Access your Shelly web interface and navigate to Scripts to view logs.
Wallbox doesn't unlock:
- Verify button component IDs are correct
- Check switch addon connection
- Review script logs for errors
Power tracking inaccurate:
- Ensure Shelly Pro 3EM is properly calibrated
- Verify energy meter (em:0) is functioning
- Check POWER_THRESHOLD setting
Schedule not running:
- Verify notificationScriptId is correct
- Check that notification script is enabled
- Review Shelly's schedule configuration
- Multi-user power tracking
- Automatic wallbox control
- Yearly notification system
- Error handling
- Production testing
- Additional user support (beyond 2 users)
This project is provided as-is for use with Shelly devices.
Improvements and bug reports are welcome. Please test thoroughly before deploying to production.