Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extension to https://gist.github.com/darrenjrobinson/6bd2cef36e5b1fa9d359c0ca1f22752c to turn them on and make them PINK
foreach ($light in $lights){
$status = Invoke-RestMethod -Method Get -Uri "$($hueBridge)/$($username)/lights"
$currentState = $status.$light | select state
# "hue" = 46920 BLUE 56100 RED 25500 GREEN 12750 YELLOW 56100 PINK
If ($currentState.state.on.Equals($false)){
$body = @{"on"=$true; "hue" = 56100} | ConvertTo-Json
write-host "Light $($light) is OFF, turning it ON and change color to PINK"
} else {
$body = @{"on"=$true; "hue" = 56100} | ConvertTo-Json
write-host "Light $($light) is already ON, changing color to PINK"
}
$result = Invoke-RestMethod -Method PUT -Uri "$($hueBridge)/$($username)/lights/$($light)/state" -Body $body
$result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment