Very simple Rust binary that can turn on/off a TP-Link L920 led light strip in your local network

Overview

TP-Link L920 on/off script

This is a (very) simple Rust binary that can turn on/off a TP-Link L920 led light strip in your local network.

Installation

Requires you to have a modern version of Rust.

Clone this repo and run:

cargo build --release

Then the binary will be available in <your-local-repo>/target/release/tapo-l920-on-off

Alternatively, if you want to let cargo clone the git repo, compile the binary and make it available in your system PATH, you can run the following command:

cargo install --git [email protected]:lmammino/tapo-l920-on-off.git

Usage

Note: you must have a Tapo account and your led strip must have been registered there.

The binary requires 3 environment variables to be set:

  • TAPO_USERNAME: your TAPO email
  • TAPO_PASSWORD: your TAPO password
  • TAPO_DEVICE_IP: your L920 device local IP Address

You can use the .env~sample example in this repo as a reference.

Once, these variables are set, just execute the binary and if the led strip is on, it will be turned off and vice versa!

If you create a .env file with the necessary environment variables, you can simply run the run.sh script in this repository.

Troubleshooting

If you are experiencing unexpected issues or errors, you can get more insights into what's going on by enabling DEBUG logs.

You can do that by setting the following environment variable:

export RUST_LOG=debug

For even more verbose logs you can set the RUST_LOG variable to trace.

Use with an Elgato Stream deck

I created this script so I can have a shortcut to turn my led strip on and off from my Elgato Stream Deck.

Below there's a description of my setup, in case you want to do something similar.

Note
These instructions have only been tested on a Mac. If you use Windows or Linux, this setup might vary slightly. PRs are welcome to fix any gap that might exist for other OSs.

1. Install & configure

  • Install the binary by cloning the repo and compiling the binary yourself.
  • Copy the .env~sample to .env and fill out the details.
  • Execute the run.sh script and make sure it works.

2. Configure your Stream Deck

2.1 Open your Stream Deck application.

Do it! 😊

2.2 Pick an empty button as your destination and drag a "Multi Action Switch" action onto it

Drag and drop a "Multi Action Switch" action

2.3 Select the "Open" action and drop it into the "Multi Action" area (Panel 1). Configure it to run the shell script.

Configure panel 1 with a run action

2.4 Switch to Panel 2 and repeat the same process

Configure panel 2 with a run action

2.5 Customise your icons to represent on/off states (optional)

Pick a lightbulb or something like that from the Elgato icon library. Or if you feel brave enough, you can even create your custom icon! 👩‍🎨

Warning
With this approach, I couldn't find any way to update the Stream Deck button in case the state of the led strip changes due to external factors (scheduled activation, activation through app or physical button, etc.), therefore your button status (on/off), might go off sync and show inverted indicators (on when it is actually off and viceversa). In this case, make sure to use the TP-link app or the physical button to bring the led strip to the same state displayed in yours Stream Deck button.

Acknowledgements

Huge thanks to Mihai Dinculescu for their awesome work on the tapo crate which made this project quite trivial to implement.

Contributing

Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.

License

Licensed under MIT License. © Luciano Mammino

You might also like...
Efficent platform for inference and serving local LLMs including an OpenAI compatible API server.

candle-vllm Efficient platform for inference and serving local LLMs including an OpenAI compatible API server. Features OpenAI compatible API server p

very cool esoteric language pls use

okfrick has one memory pointer has less than 5 characters hopefully works well is turing complete (possibly) + - increase memeory pointer value ( - st

🌋 A very lightweight wrapper around the Vulkan Memory Allocator 🦀

🌋 vk-mem-alloc-rs A very lightweight wrapper around the Vulkan Memory Allocator 🦀 [dependencies] vk-mem-alloc = "0.1.1" Simple Vulkan Memory Allocat

Compiler & Interpreter for the (rather new and very experimental) Y programming language.

Y Lang Why would anyone build a new (and rather experimental) language with no real world use case. Design Y (pronounced as why) is based on the idea

A clean and simple network looking glass application
A clean and simple network looking glass application

lg lg is my custom Looking Glass server software for use in ZZANet. The whole application is lightweight, self-contained, and easy to use even outside

Click-once - A small tiny little binary to fix undesired mouse double clicks in Windows, written in Rust.

click-once A small tiny little binary to fix malfunctioning mouse double clicks in Windows, written in Rust. Minimal executable with little to no over

NSE is a rust cli binary and library for extracting real-time data from National Stock Exchange (India)

NSE Check out the sister projects NsePython and SaveKiteEnctoken which are Python & Javascript libraries to use the NSE and Zerodha APIs respectively

A zero-copy parser for the contents of the __unwind_info section of a mach-O binary.

A parser for Apple's Compact Unwinding Format, which is used in the __unwind_info section of mach-O binaries.

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

Owner
Luciano Mammino
FullStack ☁️ developer, entrepreneur, fighter, butterfly maker! 📗 Co-author https://nodejsdp.link 💌 maintainer https://fstack.link
Luciano Mammino
Turn off monitors to save power (for Wayland)

Same as xset dpms force off, but for Wayland. It requires zwlr_output_power_manager_v1 and org_kde_kwin_idle support from the Wayland compositer. wlro

依云 15 Dec 8, 2022
Some tools for streaming frames to rpi-rgb-led-matrix using ZeroMQ, written in Rust.

led_matrix_zmq Some tools for streaming frames to rpi-rgb-led-matrix using ZeroMQ, written in Rust. This repository includes: Rust client and server l

Dan 2 Sep 6, 2022
Another Network Tunnel; A simple program for local/remote port forwarding over a SSH tunnel.

?? ANT Another Network Tunnel; A simple program for local/remote port forwarding over a SSH tunnel. Table of Contents Installation Pre-requisites Pre-

Hendrik Böck 20 Jun 25, 2023
The language that eats the stack. Heavily inspired by porth which is inspired off of forth

Snack The language that eats the stack. Heavily inspired by porth which is inspired off of forth Install To use Snack you will need Rust and fasm Afte

Cowboy8625 2 Mar 20, 2022
A boiler plate code to create dynamic link library in rust.

?? rust-dll-bp This is a boiler plate code that will be generated as a dll binary. I personally cache this here for me but if you're intend to create

s3pt3mb3r 9 Nov 7, 2022
🐀 Building a federated link aggregator in rust

English | Español | Русский Lemmy A link aggregator / Reddit clone for the fediverse. Join Lemmy · Documentation · Report Bug · Request Feature · Rele

LemmyNet 7.2k Jan 2, 2023
osu-link is a program which links osu!stable beatmaps to osu!lazer's new store format, saving you disk space.

osu-link is a program which links osu!stable beatmaps to osu!lazer's new store format, saving you disk space.

LavaDesu 2 Nov 8, 2021
The missing link to modern server controlling for TrackMania Forever.

xrd (XASeCo Replacing Daemon) xrd is a next-gen server controller for TrackMania Forever and Nations ESWC that is designed to be hassle-free and easil

Autumn Leaf 6 Mar 26, 2022
A fast & light weight Discord Client made with love using the Rust programming language.

LemonCord A fast & light-weight Discord Client written in Rust using the wry crate. Features Fast, light-weight, easy to use. 100% Open sourced. No su

Lemon Rose 5 Jan 30, 2023
An asynchronous API client for a light installation at the University of Kiel

An asynchronous API client for a light installation at the University of Kiel

FW 2 Nov 22, 2022