Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Shelly Wallbox Multi-User Script

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.

Overview

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.

Hardware Requirements

  • 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

Setup Instructions

1. Hardware Installation

  1. Install the Shelly Pro 3EM according to manufacturer instructions
  2. Connect the switch addon to control the wallbox contactor
  3. Configure the Shelly BLE buttons

2. Script Configuration

WallboxManagementScript.js

  1. Upload this script to your Shelly Pro 3EM
  2. Configure the following variables:
    • notificationScriptId: Set to the ID of NotificationScript.js
    • blueButton: 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)
  3. 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)

NotificationScript.js

  1. Upload this script to your Shelly Pro 3EM
  2. Configure:
    • webhookUrl: Your webhook endpoint URL for receiving yearly reports
  3. Note the script ID for use in WallboxManagementScript.js

3. Initialize KVS Storage

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 });

How It Works

Usage Flow

  1. User Authentication: User presses their assigned BLE button (blue or red)
  2. Wallbox Unlock: Script unlocks the wallbox via the switch addon
  3. Power Monitoring: Script monitors power consumption every 15 minutes
  4. Auto-Lock: When power drops below threshold, wallbox automatically locks
  5. Usage Tracking: Total energy consumed is added to user's KVS counter
  6. 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

Technical Details

  • 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

Features

✅ Multi-user power tracking
✅ Automatic wallbox control
✅ No external dependencies
✅ Error handling and logging
✅ Yearly automated reporting
✅ Low power consumption

Troubleshooting

Check Script Status

Access your Shelly web interface and navigate to Scripts to view logs.

Common Issues

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

Development Status

  • Multi-user power tracking
  • Automatic wallbox control
  • Yearly notification system
  • Error handling
  • Production testing
  • Additional user support (beyond 2 users)

API References

License

This project is provided as-is for use with Shelly devices.

Contributing

Improvements and bug reports are welcome. Please test thoroughly before deploying to production.

About

These scripts can be used to upgrade a normal wallbox with a Shelly Pro 3EM with a switch addon and multiple Shelly Buttons to track the power usage of mutiple users.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages