Expand description
§wiz_lights_rs
An async Rust library for controlling Philips Wiz smart lights over UDP.
This crate provides a runtime-agnostic async API to communicate with Wiz smart bulbs on your local network. It supports setting colors, brightness, color temperature, scenes, and power states.
§Quick Start
ⓘ
use std::net::Ipv4Addr;
use std::str::FromStr;
use wiz_lights_rs::{Light, Payload, Color};
// Works with any async runtime!
async fn control_light() -> Result<(), Box<dyn std::error::Error>> {
// Create a light instance with the bulb's IP address
let light = Light::new(Ipv4Addr::from_str("192.168.1.100")?, Some("Living Room"));
// Set the light to blue
let mut payload = Payload::new();
payload.color(&Color::from_str("0,0,255")?);
light.set(&payload).await?;
Ok(())
}§Features
- Runtime Agnostic: Works with tokio, async-std, or smol async runtimes
- RGB Colors: Set any RGB color using the
Colortype - Brightness: Control brightness from 10-100% using
Brightness - Color Temperature: Set warm to cool white (1000K-8000K) using
Kelvin - Scenes: Use preset lighting scenes with
SceneMode - Power Control: Turn lights on/off or reboot with
PowerMode - Room Grouping: Organize lights into
Rooms for batch operations - Discovery: Find bulbs on your network with
discover_bulbs - Hue/Saturation: Alternative color mode with
HueSaturation - Push Notifications: Real-time state updates via
push::PushManager
§Communication
All communication with Wiz bulbs occurs over UDP on port 38899. The bulbs must be on the same local network and ideally have static IP addresses assigned.
§Runtime Selection
This library is runtime-agnostic. Select your preferred runtime using feature flags:
§Using tokio (default)
[dependencies]
wiz-lights-rs = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }§Using async-std
[dependencies]
wiz-lights-rs = { version = "0.1", default-features = false, features = ["runtime-async-std"] }
async-std = { version = "1.12", features = ["attributes"] }§Using smol
[dependencies]
wiz-lights-rs = { version = "0.1", default-features = false, features = ["runtime-smol"] }
smol = "2"§Feature Flags
runtime-tokio(default): Use the tokio async runtimeruntime-async-std: Use the async-std runtimeruntime-smol: Use the smol runtime
Modules§
- push
- Push notification support for real-time state updates via syncPilot.
- runtime
- Runtime-agnostic async abstractions.
Structs§
- Brightness
- Brightness level from 10 to 100 percent.
- Bulb
Type - Complete type information for a Wiz bulb.
- Color
- An RGB color with red, green, and blue components (0-255 each).
- ColorRGBW
- An RGBW color (RGB + warm white, 0-255 each).
- ColorRGBWW
- An RGBWW color (RGB + cool white + warm white, 0-255 each).
- Discovered
Bulb - A discovered Wiz bulb.
- Extended
White Range - Extended white range (CCT range) - typically [warm_min, warm_max, cool_min, cool_max].
- FanSpeed
- Fan speed (typically 1-6).
- Features
- Feature flags for a Wiz bulb.
- History
Entry - A recorded message in the history.
- History
Summary - Summary of message history for diagnostics.
- HueSaturation
- Hue and Saturation color representation.
- Kelvin
- Color temperature in Kelvin, with valid values from 1000K to 8000K.
- Kelvin
Range - Color temperature range (Kelvin).
- Light
- Represents a single Wiz smart light bulb.
- Light
Status - Tracks the last known settings for a light bulb.
- Lighting
Response - A response from a lighting command.
- Message
History - Tracks message history for debugging.
- Payload
- A configuration payload to send to Wiz lights.
- Ratio
- Ratio for dual-head fixtures, controlling the balance between up and down lights.
- Room
- A grouping of lights for batch operations.
- Speed
- Animation speed for dynamic scenes, with valid values from 20 to 200 percent.
- System
Config - System configuration of a Wiz bulb.
- White
- White LED intensity for cool or warm white channels, from 1 to 100 percent.
- White
Range - White range values from user config.
Enums§
- Bulb
Class - Classification of Wiz bulb types.
- Error
- All error types that can occur when interacting with Wiz lights.
- FanDirection
- Fan rotation direction.
- FanMode
- Fan operating mode.
- FanState
- Fan power state.
- LastSet
- The last context set on the light that the API is aware of.
- Message
Type - Type of message in the history.
- Power
Mode - Power state for a light.
- Scene
Mode - Preset lighting scenes with static colors or dynamic animations.
Functions§
- discover_
bulbs - Discovers Wiz bulbs using UDP broadcast.