A Windows system tray application for controlling a single TP-Link Tapo smart device switch.
TapoSwitch is a lightweight .NET 9 Windows application that provides quick access to your Tapo smart plugs and switches directly from the system tray. With a single click, you can toggle your devices on or off without opening the Tapo mobile app or web interface.
This is useful for turning external audio equipment (monitors, mixers) that are connected to a PC on and off.
- 🖱️ One-Click Control: Toggle your Tapo device on/off from the system tray
- 🚀 Auto-Start: Optional automatic startup at Windows login
- 🔄 Auto-Shutdown: Automatically turns off device when you log off or shut down Windows
- 🔒 Secure: Supports both SecurePassthrough and KLAP protocols
- 💾 Lightweight: Minimal resource usage, runs quietly in the background
- 🔁 Auto-Reconnect: Automatically reconnects if connection is lost, with configurable retry attempts
- ⚙️ Easy Installation: Automated installer with interactive configuration
- 🔧 Configurable: Set device credentials and IP address during installation
- Windows 10/11
- Visual Studio 2026
- .NET 9 Runtime
- Administrator privileges (for installation)
- TP-Link Tapo smart device (plug or switch)
- Tapo device registered and on known LAN IP address
dotnet build -c ReleaseNote: The project automatically downloads the TapoConnect NuGet package (v3.2.4) and dependencies during the build.
This creates the executable at: TapoSwitch\bin\Release\net9.0-windows\TapoSwitch.exe
Option A: Double-Click Install (Recommended)
- Double-click
Install-Startup.bat - Choose "Install"
- Follow the prompts to configure your device
Option B: PowerShell
# Run PowerShell as Administrator
.\Install-Startup.ps1The installer will:
- Display current configuration settings
- Let you edit Tapo credentials (username, password, IP address)
- Optionally install to Program Files (default, recommended)
- Create Task Scheduler entry for automatic startup at login
- Task Scheduler entry to start TapoSwitch at user login
- Program Files installation (optional, default:
C:\Program Files\TapoSwitch) - Configuration stored in
TapoSwitch.dll.config
Once installed and configured:
- System Tray Icon: Look for the TapoSwitch icon in your system tray
- 💡 Icon shows current device state (on/off)
- Left Click: Toggle device on/off
- Right Click: Access context menu (Exit option)
- Auto-Start: Application starts automatically at login (if installed)
TapoSwitch automatically manages your device in the following scenarios:
- Startup: Device is turned OFF when the application starts (to ensure a known state)
- Log Off: Device is turned OFF when you log off Windows
- Shutdown: Device is turned OFF when you shut down or restart Windows
- Exit: Device is turned OFF when you exit the application from the tray menu
This ensures your Tapo device (e.g., a desk lamp, monitor light, or PC-connected equipment) is automatically controlled based on your computer usage patterns.
Note: The device will NOT automatically turn off when you lock your screen (Win+L). You can manually control the device at any time using the system tray icon.
The installer allows you to configure:
- Username: Your Tapo account email
- Password: Your Tapo account password
- IP Address: Local IP address of your Tapo device
Edit the configuration file at the appropriate location:
If installed to Program Files:
C:\Program Files\TapoSwitch\TapoSwitch.dll.config
If using build folder:
TapoSwitch\bin\Release\net9.0-windows\TapoSwitch.dll.config
Configuration Format:
<configuration>
<appSettings>
<add key="Username" value="your-tapo-email@example.com"/>
<add key="Password" value="your-tapo-password"/>
<add key="IpAddress" value="192.168.1.100"/>
<add key="ShutdownTimeoutSeconds" value="2"/>
</appSettings>
</configuration>Configuration Parameters:
| Parameter | Description | Default | Valid Values |
|---|---|---|---|
Username |
Your Tapo account email address | (required) | Any valid email |
Password |
Your Tapo account password | (required) | Any string |
IpAddress |
Local IP address of your Tapo device | (required) | Valid IPv4 address |
ShutdownTimeoutSeconds |
Timeout in seconds to wait for device to turn off during system shutdown/logoff | 2 |
Positive integer (1-10 recommended) |
ConnectionRetryAttempts |
Number of retry attempts when connection fails | 3 |
Positive integer |
RetryDelayMilliseconds |
Base delay between retry attempts (uses exponential backoff) | 2000 |
Positive integer (milliseconds) |
About ShutdownTimeoutSeconds:
- Controls how long the application waits for the device to turn off when Windows is shutting down or logging off
- A shorter timeout (1-2 seconds) is recommended for local network devices
- Increase the value (3-5 seconds) if you have a slower network or the device is not turning off reliably
- If the timeout is reached, Windows shutdown/logoff proceeds anyway to prevent hanging
Note: Restart the application after changing configuration.
Install without copying to Program Files:
.\Install-Startup.ps1 -NoInstallToProgramsInstall with custom startup delay:
# Delay startup by 15 seconds after login (default is 10 seconds)
.\Install-Startup.ps1 -StartupDelay 15Combine options:
# Install to build folder with 5 second startup delay
.\Install-Startup.ps1 -NoInstallToPrograms -StartupDelay 5Uninstall:
.\Install-Startup.ps1 -Uninstallor double-click Install-Startup.bat and choose "Uninstall"
Installation Parameters:
| Parameter | Description | Default |
|---|---|---|
-AppName |
Name of the application (used for Task Scheduler and Program Files folder) | TapoSwitch |
-StartupDelay |
Delay in seconds before starting the app after login (allows system tray to initialize) | 10 |
-NoInstallToPrograms |
Skip copying files to Program Files, run from build folder instead | (not set) |
-Uninstall |
Remove the application and scheduled task | (not set) |
After installation:
-
Check if installed:
- Task Scheduler: Press
Win + R, typetaskschd.msc, look for "TapoSwitch" task - Program Files: Check
C:\Program Files\TapoSwitchfor installed files (if applicable)
- Task Scheduler: Press
-
Test it:
- Log out and log back in
- Check system tray for TapoSwitch icon
- Or run manually:
C:\Program Files\TapoSwitch\TapoSwitch.exe
- Check configuration: Verify the config file has correct credentials and IP address:
- Program Files:
C:\Program Files\TapoSwitch\TapoSwitch.dll.config - Build folder:
TapoSwitch\bin\Release\net9.0-windows\TapoSwitch.dll.config
- Program Files:
- Check network: Ensure device is reachable from your PC
- Check logs: Look in Event Viewer → Windows Logs → Application
- Run manually: Double-click
TapoSwitch.exeto see if there are errors
If you change configuration and it doesn't take effect:
- Make sure you edited the correct config file (see locations above)
- NOT the source file
TapoSwitch\App.config - Restart the application after changes
- You can re-run the installer to update configuration interactively
- Verify the device IP address is correct
- Ensure the device is powered on and connected to your network
- Check that your Tapo credentials are valid
- Try pinging the device IP to verify network connectivity
If your device doesn't turn off when shutting down or logging off:
- Increase the timeout: Edit
TapoSwitch.dll.configand increaseShutdownTimeoutSeconds:<add key="ShutdownTimeoutSeconds" value="5"/>
- Check network speed: Slow network connections may need more time
- Verify device is reachable: Test by manually toggling the device before shutdown
- Check Event Viewer: Look for errors in Windows Event Viewer → Application logs
- Test the installer delay: The Task Scheduler startup delay (default 10 seconds) may need adjustment:
.\Install-Startup.ps1 -StartupDelay 15
If you get "Access Denied" errors:
- Run PowerShell as Administrator
- The installation script requires admin rights for Task Scheduler and Program Files
- Use
-NoInstallToProgramsflag if you cannot install to Program Files
The installer looks for executables in this order:
bin\Release\net9.0-windows\TapoSwitch.exe(preferred)bin\Debug\net9.0-windows\TapoSwitch.exe(fallback)
Always build in Release mode for production:
dotnet build -c ReleaseRun any of these:
# Batch file
Install-Startup.bat
# Then choose option 2 (Uninstall)
# PowerShell (as Admin)
.\Install-Startup.ps1 -UninstallThe uninstall will:
- Stop any running TapoSwitch instances
- Remove the scheduled task
- Remove files from Program Files (if installed there)
Configuration file locations:
- Program Files:
C:\Program Files\TapoSwitch\TapoSwitch.dll.config - Build folder:
TapoSwitch\bin\Release\net9.0-windows\TapoSwitch.dll.config
Security recommendations:
- Never commit the built output folder (
bin\,obj\) to version control - Set appropriate file permissions on the config file to restrict access
- If installed to Program Files, only administrators can modify the config by default
- Keep your build output folder excluded from backups or cloud sync services
- Consider using Windows Credential Manager in future versions
- The source
TapoSwitch\App.configfile should remain with placeholder values only
Best Practice:
- Use the interactive installer to configure credentials securely
- Keep
TapoSwitch\App.configwith placeholder values (safe for repository) - Create a
.gitignoreentry forbin/andobj/folders (should already be present) - Install to Program Files for better security (admin rights required to modify)
When working on the codebase, you can create an App.config.user file to store your credentials without risk of accidentally committing them:
-
Copy the template (in the root directory alongside
Install-Startup.ps1):copy App.config App.config.user
-
Edit
App.config.userwith your actual credentials:<configuration> <appSettings> <add key="Username" value="your-email@example.com"/> <add key="Password" value="your-actual-password"/> <add key="IpAddress" value="192.168.1.100"/> <add key="ShutdownTimeoutSeconds" value="2"/> </appSettings> </configuration>
-
How it works:
- Place
App.config.userin the root directory (same location asInstall-Startup.ps1) - When you run the installer, it automatically detects
App.config.user - The installer copies
App.config.userto the build output folder asTapoSwitch.dll.config - Then uses that configuration for installation
App.config.useris in.gitignoreso it won't be committed- When you build the project, your build uses the standard
App.config(with placeholders)
- Place
-
Keep
App.configwith placeholders:<add key="Username" value="[YourTapoRegistrationEmail]"/> <add key="Password" value="[YourTapoRegistrationPassword]"/> <add key="IpAddress" value="[YourTapoSwitchIPOnTheLAN]"/>
This approach allows you to:
- Work with real credentials locally without modifying
App.config - Install and test the application during development without re-entering credentials
- Prevent accidentally committing credentials to version control
- Keep the repository safe for sharing
Note: When the installer detects App.config.user, it will show "[Dev Mode]" and automatically use those credentials for the installation.
File Location: Make sure App.config.user is in the root project directory:
TapoSwitch/
├── App.config # Template with placeholders (tracked in git)
├── App.config.user # Your credentials (ignored by git)
├── Install-Startup.ps1
├── Install-Startup.bat
└── ...
After installation, you can modify the task in Task Scheduler:
- Change trigger (e.g., add delay after logon)
- Change conditions (e.g., only on AC power)
- Configure for multiple users
To run TapoSwitch as a different user:
- Open Task Scheduler
- Find the TapoSwitch task
- Edit the task
- Change the user account in "General" tab
To find your Tapo device's IP address:
- Open the Tapo mobile app
- Go to device settings
- Look for "Device Info" or similar
- Note the IP address displayed
Or check your router's connected devices list.
- Framework: .NET 9 (Windows)
- UI Framework: Windows Forms
- Protocols Supported: SecurePassthrough, KLAP
- Target OS: Windows 10/11
- Dependencies:
- TapoConnect v3.2.4 (NuGet package)
- Microsoft.CSharp v4.7.0
- System.Data.DataSetExtensions v4.5.0
TapoSwitch/
├── Program.cs # Main application entry point
├── App.config # Source configuration (placeholders)
├── Install-Startup.ps1 # PowerShell installation script
├── Install-Startup.bat # Batch installation wrapper
├── README.md # This file
└── bin/Release/ # Build output folder
└── net9.0-windows/
├── TapoSwitch.exe
└── TapoSwitch.dll.config # Runtime configuration
If you encounter issues:
- Check the Troubleshooting section above
- Verify your build is up to date
- Check the GitHub repository for issues
- Create a new issue with logs and error messages
This project uses the TapoConnect NuGet package (v3.2.4) for device communication.
For more information about TapoConnect, visit the GitHub repository.
See the LICENSE file in the repository for details.
Made with ❤️ for TP-Link Tapo device automation