Skip to content

Instantly share code, notes, and snippets.

@poiriersimon
Last active December 20, 2023 07:29
Show Gist options
  • Save poiriersimon/eaee208ce8ea79f30b4cc7d3a078c3bc to your computer and use it in GitHub Desktop.
Save poiriersimon/eaee208ce8ea79f30b4cc7d3a078c3bc to your computer and use it in GitHub Desktop.
Logitech Litra Glow Beam Powershell Function
#Litra Glow and Litra Beam Powershell Controller
#Download hidapitester here : https://github.com/todbot/hidapitester/releases
#Based on https://www.reddit.com/r/LogitechG/comments/sacz2x/comment/j7doia4/?utm_source=share&utm_medium=web2x&context=3
#Change to point to the extract folder
$HIDAPItesterFolderPath = "C:\Users\username\Scripts\"
#HIDAPItester
$global:HIDAPItesterPath = $HIDAPItesterFolderPath + "hidapitester.exe"
Function Set-HIDAPItester {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $vidpid,
[Parameter(Mandatory = $true)]
[string] $OpenPath,
[Parameter(Mandatory = $true)]
[string] $output,
[Parameter(Mandatory = $true)]
[string] $usagePage,
[string] $HIDAPItesterPath = $global:HIDAPItesterPath
)
$null = &($HIDAPItesterPath) --vidpid $vidpid --usagePage $usagePage --open-path $OpenPath --send-output $output
}
Function Get-LitraLight {
[CmdletBinding()]
param (
[switch] $Beam,
[switch] $Glow
)
if($Beam){
$LitraRaw= &($HIDAPItesterPath) --vidpid 046d/c901 --usagePage FF43 --list-detail
}
elseif($Glow){
$LitraRaw= &($HIDAPItesterPath) --vidpid 046d/c900 --usagePage FF43 --list-detail
}else{
$LitraRaw= &($HIDAPItesterPath) --usagePage FF43 --list-detail
}
#$litraRaw
$i=0
[Array]$LitraLights = @()
$LitraLight = New-Object PSObject
foreach($line in $litraRaw){
$i++
if($i -eq 1){
$name = "vidpid"
$value = $line.split(":")[0].trim()
}else{
$name = $line.split(":")[0].trim()
$value = $line.split(":")[-1].trim()
}
if(!$([string]::IsNullOrempty($name))){
$LitraLight | Add-Member NoteProperty -Name $name -Value $value
}
if($i -gt 8){
$i=0
[Array]$LitraLights+=$LitraLight
$LitraLight = New-Object PSObject
}
}
return $LitraLights
}
function Set-LitraLight {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $vidpid,
[Parameter(Mandatory = $true)]
[string] $OpenPath,
[ValidateRange(1, 100)]
[int] $Brightness,
[ValidateRange(2700, 6500)]
[int] $temperature
)
if($Brightness -gt 0){
[int]$brightnessvalue = [math]::floor(31 + ($Brightness/100*368))
$brightnessvalue
$hex = $brightnessvalue | Format-Hex
$hex
$output= "0x11,0xFF,0x04,0x4F,0x"+ $hex.HexBytes.Split(" ")[1] +",0x"+ $hex.HexBytes.Split(" ")[0]
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output
}
if($temperature -gt 0){
$hex = $temperature | Format-Hex
$hex
$output = "0x11,0xFF,0x04,0x9D,0x"+ $hex.HexBytes.Split(" ")[1] +",0x" + $hex.HexBytes.Split(" ")[0]
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output
}
}
Function Start-LitraLight {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $vidpid,
[Parameter(Mandatory = $true)]
[string] $OpenPath
)
$output = "0x11,0xFF,0x04,0x1D,0x01"
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output
}
Function Stop-LitraLight {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $vidpid,
[Parameter(Mandatory = $true)]
[string] $OpenPath
)
$output = "0x11,0xFF,0x04,0x1D,0x00"
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output
}
#Exemple:
Write-host "All Off"
$lights = Get-LitraLight
foreach($Light in $Lights){
Stop-LitraLight -vidpid $light.vidpid -OpenPath $light.path
}
Write-host "All On"
$lights = Get-LitraLight
foreach($Light in $Lights){
start-LitraLight -vidpid $light.vidpid -OpenPath $light.path
}
Write-host "Beam On"
$lights = Get-LitraLight -Beam
foreach($Light in $Lights){
start-LitraLight -vidpid $light.vidpid -OpenPath $light.path
}
@rigiddesign
Copy link

Thank you for the reply. I managed to get it working with Bluetooth, that was not the issue.

I believe it was due to these lights being brand new, and seemingly a newer iteration, or at least a different version.

I had to use the --read-input-forever of hidapitester to monitor the hex values being passed when I manually turned the lights off and on, to work out the required hex values to pass.

In case it helps anyone else:

To Turn the RGB lights ON:

Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output "0x11,0xFF,0x0A,0x4E,0x01" -HIDAPItesterPath $HIDAPItesterPath

To Turn the RGB lights OFF:

Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output "0x11,0xFF,0x0A,0x4E,0x00" -HIDAPItesterPath $HIDAPItesterPath

To Turn the White lights ON:

Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output "0x11,0xFF,0x06,0x1E,0x01" -HIDAPItesterPath $HIDAPItesterPath

To Turn the White lights OFF:

Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output "0x11,0xFF,0x06,0x1E,0x00" -HIDAPItesterPath $HIDAPItesterPath

@poiriersimon
Copy link
Author

poiriersimon commented Dec 19, 2023 via email

@rigiddesign
Copy link

No problem 😊. Thank you again for creating this in the first place!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment