How can I control WiFi LEDNet devices from a computer?
I have a pair of RGB lights that are controlled from a smartphone using apps like Magic Home or Magic Lantern. The control is done through WiFi LEDNet technology, about which I couldn’t find detailed information. To connect, both Bluetooth and WiFi need to be used simultaneously. It’s also possible to control multiple devices at the same time without the need for authorization - the devices are simply discovered and connected.
Could someone tell me what protocol this is and where I can read about it? I’m interested in the possibility of controlling these devices from a computer.
WiFi LEDNet Protocol: Direct Computer Control of RGB LED Devices
WiFi LEDNet is a protocol for controlling RGB devices via WiFi, allowing computers to directly interact with LED strips and bulbs without using mobile applications. This protocol uses simple TCP communication on port 5577 and does not require authentication for basic control.
Table of Contents
- LEDNet Protocol Basics
- Computer Control Methods
- Python Libraries for Control
- Code Examples and Implementations
- Integration with Smart Home Systems
- Technical Protocol Details
LEDNet Protocol Basics
The LEDNet protocol is used to control WiFi RGB devices, including LED strips and bulbs. Key features of this protocol include:
- Network Naming: Devices create their own WiFi network with a name in the format “LEDnetxxxxx” (e.g., “LEDnet75E92”)
- Communication Port: The standard port for communication is 5577
- Data Format: Colors are transmitted as 3-byte hexadecimal values (RRGGBB)
- Authentication: Not required for basic device control
Devices support simultaneous connection from multiple controllers, allowing multiple RGB lights to be controlled simultaneously from different devices.
Computer Control Methods
There are several ways to control LEDNet devices from a computer:
Direct TCP Communication
The most direct method is to send commands directly to the device’s IP address through port 5577. This approach does not require installing additional libraries and can be implemented using standard network tools.
Using Specialized Libraries
For convenience, there are ready-made libraries in various programming languages that simplify sending commands and controlling devices.
Integration with Automation Systems
LEDNet devices can be integrated into systems like Home Assistant using official or third-party integrations.
Python Libraries for Control
ledenet_api
The ledenet_api library provides an API for controlling LEDENET Magic UFO LED WiFi controllers. It allows:
- Connecting to devices by IP address
- Controlling color, brightness, and lighting modes
- Working with multiple devices simultaneously
flux_led
The flux_led library is designed to control Flux WiFi Smart LED bulbs. It includes:
- Support for various device models
- Setting color, brightness, and effects
- Working with patterns and lighting modes
Other Libraries
sunix-ledstrip-controller-clientfor Sunix controllerspython-wifi-ledsfor cross-vendor support- Custom implementations on GitHub for specific models
Code Examples and Implementations
Simple Script for Controlling LEDNet Devices
import socket
def send_led_command(ip, port, command):
"""Send command to LEDNet device"""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect((ip, port))
sock.send(command)
sock.close()
return True
except Exception as e:
print(f"Connection error: {e}")
return False
# Usage examples
ip_address = "10.10.123.3" # IP address of your device
port = 5577
# Turn on red color
send_led_command(ip_address, port, bytes.fromhex("56 00 00 00 00 00 0F 00 FF 00 00 FA"))
# Turn on green color
send_led_command(ip_address, port, bytes.fromhex("56 00 00 00 00 00 0F 00 00 FF 00 FA"))
# Turn off all colors
send_led_command(ip_address, port, bytes.fromhex("56 00 00 00 00 00 0F 00 00 00 00 FA"))
Example with ledenet_api Library
from ledenet_api import LedenetController
# Create controller
controller = LedenetController("10.10.123.3")
# Set color (red)
controller.set_color(255, 0, 0)
# Set brightness (50%)
controller.set_brightness(50)
# Turn on device
controller.turn_on()
# Turn off device
controller.turn_off()
Integration with Smart Home Systems
Home Assistant
Home Assistant has an official flux_led integration that allows:
- Automatically scanning the network for LEDNet devices
- Configuring devices through the web interface
- Creating automations based on lighting status
- Integrating with other smart home devices
Other Platforms
- Control4: There are drivers for integrating LEDNet devices
- Homey: Support through third-party applications
- OpenHAB: Through various plugins and scripts
Technical Protocol Details
Command Structure
LEDNet protocol commands have the following structure:
- Start byte: 0x56
- Data: variable length
- Checksum: calculated based on previous bytes
- End byte: 0xFA
Supported Functions
- RGB color control
- Brightness adjustment
- Selection of preset lighting modes
- Music synchronization
- Timers and schedules
Limitations
- Only 2.4GHz WiFi is supported (5GHz does not work)
- No data encryption in standard implementation
- Limited number of simultaneous connections
For developing your own solutions for controlling LEDNet devices from a computer, it is recommended to study the source code of existing libraries on GitHub, where the protocol structure and implementation examples are described in detail.
Sources
- GitHub - Jppx/WIFI-LED-Strip - LEDNet Protocol
- GitHub - sidoh/ledenet_api - API for LEDENET Controllers
- Home Assistant - flux_led Integration
- OneSmartLighting - Magic Home WiFi Controllers Guide
- GitHub - beville/flux_led - Library for Controlling LED Bulbs
Conclusion
The WiFi LEDNet protocol provides simple yet effective methods for controlling RGB devices from a computer. The main advantages are:
- Ease of Implementation: Simple TCP protocol with open source
- No Authentication: Does not require complex access configuration
- Flexibility: Support for various programming languages and platforms
- Integration: Ability to connect with automation systems
For getting started, it is recommended to use existing Python libraries, which significantly simplify development. If you need to create unique functions, you can study the protocol structure and implement custom solutions based on TCP communication.