-
-
Save darrenjrobinson/6bd2cef36e5b1fa9d359c0ca1f22752c to your computer and use it in GitHub Desktop.
Extension to https://gist.github.com/darrenjrobinson/0c0744a9868ff4e36ab776173f0889f4 to control multiple lights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Collection of lights | |
$lights = @() | |
$lights +=4 | |
$lights +=5 | |
$lights +=6 | |
foreach ($light in $lights){ | |
$status = Invoke-RestMethod -Method Get -Uri "$($hueBridge)/$($username)/lights" | |
$currentState = $status.$light | select state | |
If ($currentState.state.on.Equals($false)){ | |
$body = @{"on"=$true} | ConvertTo-Json | |
write-host "Light $($light) is OFF, turning it ON" | |
} else { | |
$body = @{"on"=$false} | ConvertTo-Json | |
write-host "Light $($light) is ON, turning it OFF" | |
} | |
$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