Skip to content

AdhocAdam/LifxLAN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



LifxLAN

Overview

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!

Available cmdlets

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

Getting Started

Install from the module from the PowerShell Gallery by using the following at a PowerShell prompt

Install-Module -Name LifxLAN -AllowPrerelease

Discovering Lifx devices on your network

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

Get product details and firmware

$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

Get device Wifi Signal and Strength

$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceWifi

Controlling Power

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

Working with Color

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

Get-LifxDeviceColor

$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Get-LifxDeviceColor

Set-LifxDeviceColor via RGB

$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Red 200 -Blue 13 -Brightness 75 -Saturation 100

Set-LifxDeviceColor via predefined white palette as seen in the app (supports tab complete)

$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Brightness 100 -White 'Sunset' -SecondsToTransition 1.5

Set-LifxDeviceColor via white palette as defined in Kelvin range

$devices = Get-LifxDevice | Initialize-LifxDevice
$devices | Where-Object {$_.Group -eq "Living Room"} | Set-LifxDeviceColor -Kelvin 7500 -Brightness 100

Credits

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: