This is a module aimed at controlling Lifx devices on your LAN right from PowerShell. Cmdlets are not comprehensive in their control but pull requests are welcome!
Cmdlet | Purpose |
---|---|
Get-LifxDevice | Discovers Lifx devices on the LAN. Returns IP/Port |
Initialize-LifxDevice | Obtains the device Name and Group of a device |
Get-LifxDevicePower | Obtains the current power state of a device |
Get-LifxDeviceSetting | Obtains the details of a device such as it's Lifx Identifier, Product Name, and capabilities such as Infrared, Multizone, and HEV support |
Get-LifxDeviceColor | Obtains the HSBK values of a device |
Get-LifxDeviceWifi | Obtains the current wifi signal and strength of a device |
Get-LifxProduct | Returns a specific Lifx Product's capabilities |
Set-LifxDevicePower | Turns a device on or off |
Set-LifxDeviceColor | Defines the color of a device in: RGB + Saturation + Brightness, Kelvin + Brightness, White Palette as seen in the app, and finally all support an the time to takes to change in seconds |
Install from the module from the PowerShell Gallery by using the following at a PowerShell prompt
Install-Module -Name LifxLAN -AllowPrerelease
To begin to controlling lights on your LAN start a discovery with
$devices = Get-LifxDevice | Initialize-LifxDevice
This returns a list of Lifx devices on your network by their IP Address, Name, and Group
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceSetting
This updates devices returned with properties for [PSCustomObject] Product details and [Version] Firmware Version. For example:
#Example Product information
[PSCustomObject]@{
[int]Id=91;
[string]Name=LIFX Color;
[bool]Color=True;
[bool]Infrared=False;
[bool]Multizone=False;
[bool]HEV=False}
#Example Version
[Version]3.70
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceWifi
The current power state of devices can be obtained/refreshed with:
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDevicePower
Devices can be turned on individually or through the pipeline
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDevicePower -Power $true
or
$devices = Get-LifxDevice | Initialize-LifxDevice
Set-LifxDevicePower -Device $devices[0] -Power $false
Just like the app, the HSBK (Hue, Saturation, Brightness, Kelvin) can all be controlled independently.
- Hue is provided in degrees between 0-360
- Brightness/Saturdation are provided in terms of 0-100 percent, defaults to 0 if not provided.
- RGB 0-255, defaults to 0 if not provided.
- Kelvin 1000-12000
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceColor
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Red 200 -Blue 13 -Brightness 75 -Saturation 100
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Brightness 100 -White 'Sunset' -SecondsToTransition 1.5
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Kelvin 7500 -Brightness 100
This PowerShell module is made possible the following GitHub repositories and projects around controlling Lifx devices via .NET as well as examining Lifx packets over Wireshark.
And of course Lifx documentation: