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 the module from the PowerShell Gallery by using the following at a PowerShell prompt
Installing on PowerShell versions 6+ (black background, downloaded from Microsoft's PowerShell Github)
Install-Module -Name LifxLAN -AllowPrereleaseIf you're installing on an older version of PowerShell, you might get an error that states "A parameter cannot be found that matches parameter name 'allowprerelease'". This is due to changes made in the PowerShellGet module updated in versions 6 onward. You'll need to update PowerShellGet first (as seen below) per Microsoft documentation and then you'll be able to install the module.
Install-Module PowerShellGet -Force -AllowClobber
Install-Module LifxLAN -AllowPrereleaseImport-Module LifxLANTo begin to controlling lights on your LAN start a discovery with
$devices = Get-LifxDevice | Initialize-LifxDeviceThis returns a list of Lifx devices on your network by their IP Address, Name, and Group
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceSettingThis updates devices with Product details [PSCustomObject] and Firmware Versions [Version] from a product list as defined within the module itself. In the event product details are not defined in the module, they are retrieved from LIFX's official GitHub repo (products.json). 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-LifxDeviceWifiThe current power state of devices can be obtained/refreshed with:
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDevicePowerDevices can be turned on individually or through the pipeline
$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDevicePower -Power $trueor
$devices = Get-LifxDevice | Initialize-LifxDevice
Set-LifxDevicePower -Device $devices[0] -Power $falseJust like the app, the HSBK (Hue, Saturation, Brightness, Kelvin) can all be controlled independently. However to keep things simple, you can provide RGB values and the module will convert them to the required HSBK values.
- 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 100This 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:
